[ros-users] spawn multiple nodes from rospy node

Ugo Cupcic ugo at shadowrobot.com
Sun Aug 29 08:13:21 UTC 2010


Hi,

I copy pasted part of my code and forgot to modify it, but servo is an
int index in my real program.

So in theory it should work? :S I'll test with a simple parent node /
child on Tuesday.

Cheers,

Ugo

On 27/8/2010, "Ken Conley" <kwc at willowgarage.com> wrote:

>Hi Ugo,
>
>I can't reproduce your error, but there is a bug in your script:
>
>    motor_node = roslaunch.Node(package = "sr_three_fingers_dynamixel_hand",
>                                          node_type="motor.py",
>name="dynamixel_motor_"+str(servo))
>
>I assume that you meant str(i):
>
>    motor_node = roslaunch.Node(package = "sr_three_fingers_dynamixel_hand",
>                                          node_type="motor.py",
>name="dynamixel_motor_"+str(i))
>
>Otherwise you are launching nodes with the same name repeatedly, and
>all but one will get killed.
>
>That shouldn't result in the error message your are getting. The error
>message you are getting should only happen if you are calling
>init_node more than once in your program.
>
> - Ken
>
>
>On Fri, Aug 27, 2010 at 10:01 AM, Ugo Cupcic <ugo at shadowrobot.com> wrote:
>> 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
>>
>> _______________________________________________
>> 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
>



More information about the ros-users mailing list