1. 程式人生 > >解決方案:terminate called after throwing an instance of 'ros::TimeNotInitializedException'

解決方案:terminate called after throwing an instance of 'ros::TimeNotInitializedException'

在ROS中使用ros::Time和ros::Duration時出現瞭如下錯誤:

terminate called after throwing an instance of 'ros::TimeNotInitializedException'
  what():  Cannot use ros::Time::now() before the first NodeHandle has been created or ros::start() has been called.  If this is a standalone app or test that just uses ros::Time and does not communicate over ROS, you may also call ros::Time::init()
已放棄 (核心已轉儲)

解決方案:

在建立ros::Time和ros::Duration物件之前,採用ros::Time::init();語句進行初始化。