ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There is nothing wrong with your example as described; in fact it's a typical usage. The NodeHandle is not created until you create the instance of Z, which happens after the call to ros::init(), so there should be no problem.

Most likely you are declaring a global instance of Z (or some other class containing a NodeHandle) either in your main.cpp or in the library. Since globals are created before main(), ros::init() has not yet been called and you get the error.

Get a stack trace from the failed assertion to see where the NodeHandle is being created.