Error using sensor_msgs global variable
Hi everyone,
When trying to use global variables of type sensor_msgs I'm getting some errors running the code (compilation is done without errors), and I don't know what it referes. I declared the variables out of main:
const sensor_msgs::ImageConstPtr left_image;
And when trying to run the code, calling it in main, with any code (either std::cout , publish ....):
std::cout << "Time stamp (left image): "<< left_image->header.stamp << std::endl;
I get:
topic_sync2: /usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr<T>::operator->() const [with T = const sensor_msgs::Image_<std::allocator<void> >]: Assertion `px != 0' failed.
Aborted (core dumped
If anyone could help me I would be very grateful.