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.
I tried googling for an answer but it seems like the answers are targeted for rospy and not roscpp. Also, I am using ros indigo.
The code I am trying to run is pretty simple:
#include "generate_global_map.hpp"
#include <iostream>
int main(int argc, char **argv) {
ros::init(argc, argv, "test_generate_global_map");
std::cout << "hello world" << std::endl;
ros::Rate loop_rate(5); //10hz loop rate
while (ros::ok()){
ros::spinOnce(); //ros spin is to ensure that ros threading does not leave subscribes un processed
loop_rate.sleep();
}
return 0;
}
When I try to rosrun this I get this error:
hello world
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()
Aborted (core dumped)
Anyone know what the issue is?