[ros-users] spawn multiple nodes from rospy node

Ugo Cupcic ugo at shadowrobot.com
Fri Aug 27 17:01:08 UTC 2010


 Ok, I tried using the roslaunch.scriptapi but encountered a problem:

in my "parent node", I have something like this:
 self.roslauncher = roslaunch.ROSLaunch()
 self.roslauncher.start()

 for i in range(0,10):

    motor_node = roslaunch.Node(package =
"sr_three_fingers_dynamixel_hand",

                                          node_type="motor.py",
name="dynamixel_motor_"+str(servo))

    self.roslauncher.launch(motor_node)



However if in my spawn child nodes I have:
 rospy.init_node( 'dynamixel_motor_'+str(motor_id) )

 
Then ros complains that the node is already initialized. (raise
rospy.exceptions.ROSException("rospy.init_node() has already been called
with different arguments: "+str(_init_node_args)))

If i comment the rospy.init_node then ros doesn't complain and the
parent node seems to be starting properly, but I don't see my child node
in the system. rosnode list return the parent node only.

Any idea of what I am doing wrong?

Cheers,

Ugo

On 26/08/10 17:02, Ugo Cupcic wrote:
>  Thanks Ken.
>
> On 26/08/10 16:33, Ken Conley wrote:
>> Multiple ways, yes.
>>
>> Spawning a ros node is no different from just running a process. So
>> the standard Python subprocess module will work.
>>
>> If you want to get fancier, there are two Python APIs for running
>> roslaunch within your own process:
>>
>>  * roslaunch.scriptapi [1]
>>  * roslaunch_caller (unsupported)
>>
>> [1]: http://www.ros.org/doc/api/roslaunch/html/roslaunch.scriptapi.ROSLaunch-class.html
>>
>> On Thu, Aug 26, 2010 at 1:04 AM, Ugo Cupcic <ugo at shadowrobot.com> wrote:
>>>  Hi all,
>>>
>>> Is there a way to spawn multiple nodes directly from a python node?
>>>
>>> Cheers,
>>>
>>> Ugo
>>>
>>> --
>>> Ugo Cupcic         |  Shadow Robot Company | ugo at shadowrobot.com
>>> Software Engineer  |    251 Liverpool Road |
>>> need a Hand?       |    London  N1 1LX     | +44 20 7700 2487
>>> http://www.shadowrobot.com/hand/              @shadowrobot
>>>
>>> _______________________________________________
>>> ros-users mailing list
>>> ros-users at code.ros.org
>>> https://code.ros.org/mailman/listinfo/ros-users
>>>
>> _______________________________________________
>> ros-users mailing list
>> ros-users at code.ros.org
>> https://code.ros.org/mailman/listinfo/ros-users
>>

-- 
Ugo Cupcic         |  Shadow Robot Company | ugo at shadowrobot.com
Software Engineer  |    251 Liverpool Road |
need a Hand?       |    London  N1 1LX     | +44 20 7700 2487
http://www.shadowrobot.com/hand/              @shadowrobot

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20100827/9e57c84e/attachment-0003.html>


More information about the ros-users mailing list