Hi Dirk, <br><br><div class="gmail_quote">On Fri, Jan 7, 2011 at 12:03 PM, Dirk Thomas <span dir="ltr"><<a href="mailto:dthomas@sim.tu-darmstadt.de">dthomas@sim.tu-darmstadt.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div class="im"> > I'm not sure if you need to un-init to stop and start ROS (for example, to contact multiple masters, etc). The ros::init() function only processes command line arguments.<br>
 ><br>
 > There's some example code in wgtest_status_indicator that runs a persistent node that can reacquire the ROS Master, and start and stop ROS.<br>
 ><br>
 > <a href="https://code.ros.org/svn/wg-ros-pkg/stacks/wg_hardware_test/trunk/wgtest_status_indicator/src/nodes" target="_blank">https://code.ros.org/svn/wg-ros-pkg/stacks/wg_hardware_test/trunk/wgtest_status_indicator/src/nodes</a><br>


<br>
</div>@Kevin: actually i want to be able to restart the ROS node. This may include<br>
different command line arguments, mappings, whatever. Therefore the cycle should<br>
cover all aspect including the initialization.<br>
<div class="im"><br>
<br>
> Out of curiosity, what's your use case?<br>
<br>
</div>@Blaise: good question, difficult answer :-)<br>
Currently it is more a prototype and testing than a real world application.<br>
I build a ROS node (or a ROS Nodeletmanager) in a shared library. This library<br>
is then loaded and run from an other binary. This binary should be capable of<br>
restarting the ROS node with e.g. modified command line arguments if needed.<br>
If the library is rebuild the binary must unload/reload the modified lib. But<br>
if only command line arguments are changed it should keep the current lib<br>
loaded and just perform a second cycle.<br>
I will post more details of the use case when i am some steps further...<br>
<br></blockquote><div> </div><div>I'm not sure that restructuring the roscpp node to be reinitted regularly is actually the best way to do this.   Since you're not actually passing new command line arguments, it doesn't make much sense to simulate the arguments.  In the default nodelet manager there is examples of how to replicated everything the command line parsing does w/o recalling ros::init.  <br>

<br>Using the arguments to NodeHandle constructor, as nodelets do,  instead of recalling ros::init does not set the default NodeHandle constructor which means that you cannot use that.  However if you are planning to write libraries which are expected to use seperate remappings than other parts of the same process it is much cleaner to pass that library a NodeHandle at construction, and the library will then base all it's communications off of the namespace embedded in the NodeHandle passed to it.  <br>

<br>Stopping and restarting the entire roscpp infrastructure is also dangerous to do if you might have other ROS based libraries elsewhere in the process that you could side effect. And you can only have one ROS node per process, which if the entire node is built into the library it is mutually exclusive with any other library which wants to use ROS.  <br>

<br>If you could explain your use case more fully we might be able to suggest an approach which would be easier to implement.  We've done several libraries with the approach I suggested above, for example classes in the tf library are all use this design pattern for portability.  <a href="http://www.ros.org/doc/api/tf/html/c++/classtf_1_1TransformListener.html#a40d8462819c4e5280e8553080c4bd908">http://www.ros.org/doc/api/tf/html/c++/classtf_1_1TransformListener.html#a40d8462819c4e5280e8553080c4bd908</a>  <br>

<br>Tully<br> <br>PS For clarity when we refer to ROS Nodes, that actually refers to the executable.  <a href="http://www.ros.org/wiki/Nodes">http://www.ros.org/wiki/Nodes</a><br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Currently i am dealing with multiple issues:<br>
<br>
- after the first cycle of init(), start() and shutdown() i can't perform a<br>
   uninit() and therefore no second init(), etc. cycle<br>
<br>
- when unloading the library containing the ROS node (which uses log4cxx) my<br>
   application crashes with a segfault due to some internals of log4cxx<br>
<br>
- likely more to come...<br>
<div><div></div><div class="h5"><br>
Dirk<br>
_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Tully Foote<br>Systems Engineer<br>Willow Garage, Inc.<br><a href="mailto:tfoote@willowgarage.com">tfoote@willowgarage.com</a><br>(650) 475-2827<br>