Ask Your Question

Error using sensor_msgs global variable

asked 2015-03-25 05:14:21 -0500

aba92 gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-03-25 05:41:26 -0500

Wolf gravatar image

You declare a NULL pointer here:

const sensor_msgs::ImageConstPtr left_image;

You have to assign the pointer to something before using it or create an object it can point to, like e. g.:

const sensor_msgs::ImageConstPtr left_image( new sensor_msgs::Image() );
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-03-25 05:14:21 -0500

Seen: 97 times

Last updated: Mar 25 '15