Ros node startup and shutdown

 

1. ros run Unit:

Ros unit is running ros node.

 

2. ros node startup:

(1) Initialization ros nodes: by calling ros :: init () interface; you can specify a default node name, the reason for the default parameter, is because the command line program, it can modify the node name.

(2) Start ros node: When NodeHnadle create NodeHnadle instance by calling ros :: nh achieve, create an instance for the first time, will call ros :: start (), this time starting this node.

 

3. ros node goes down:

(1) by calling :: ros shutdown () interface, a close ros node, this interface will close the subscription topic, publish topics, request services, and to provide services.

(2) the last time ros :: NodeHnadle object is destroyed, it will automatically call ros :: shutdown (), in order to close the ros node.

 

4. ros detecting whether the node has closed:

(1) ros :: ok () Interface: returns false, indicates that the node has been shut down.

(2) ros :: isShuttingDown () Interface: returns true, explain ros :: shutdown () is called, but it must end node ratio.

Note: it is generally use ros :: ok () judgment, but does not end node, such as "prolonged service callback", you can only use ros :: isShuttingDown (), because this node does not close, wondering which is What nodes?

 

5. Break:

( 1) In ros :: init () options, options a ros :: init_options :: NoSigintHandler, SIGINT decide whether to install the default handler, if with this parameter, the installation program in the received signal SIGINT (ctrl + c time), ros :: ok () returns false, the node can go close process. If with this parameter, you need to install their own SIGINT handler to ensure that the nodes can end.

Guess you like

Origin www.cnblogs.com/long5683/p/11298509.html