Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Nodehandle destroyed and shutdown the ros node

Hi all

I was wondering what would happen to the previously created subscriptions and publications and services after the nodehandle is destroyed? I have experieced such case: create a nodehandle in the constructor of the class and in my main() I just create a object of the class. The constructor will be called when the object is created and the nodehandle will experience starting the node, subscribe and publish, and shutting down the node as the life of circle of the nodehande is within the constructor and after that the nodehandle (lets assume it is the only one nodehandle in this example) will be destroyed and the shutdown() will be invoked.

Will this work? Will the publish and subcribe work in this way below? Thank you all.

Class A {

A

{ ros::NodeHandle private_nh("~"); pub = private_nh.advertise... sub_ = private_nh.subscribe...

}

}

int main()

{

ros::init(...);

A a;

ros::spin();

}

click to hide/show revision 2
retagged

Nodehandle destroyed and shutdown the ros node

Hi all

I was wondering what would happen to the previously created subscriptions and publications and services after the nodehandle is destroyed? I have experieced such case: create a nodehandle in the constructor of the class and in my main() I just create a object of the class. The constructor will be called when the object is created and the nodehandle will experience starting the node, subscribe and publish, and shutting down the node as the life of circle of the nodehande is within the constructor and after that the nodehandle (lets assume it is the only one nodehandle in this example) will be destroyed and the shutdown() will be invoked.

Will this work? Will the publish and subcribe work in this way below? Thank you all.

Class A {

A

{ ros::NodeHandle private_nh("~"); pub = private_nh.advertise... sub_ = private_nh.subscribe...

}

}

int main()

{

ros::init(...);

A a;

ros::spin();

}