Launching multiple nodes




Launching multiple nodes

Postby joma » Tue 29. Jul 2014, 15:26

Hello,
I have tried to start multiple ROS nodes to solve a challenge by a launch file. This works well so far.
I'm now facing problems while automatically starting this nodes by /opt/euroc_c2s1/startup script. I replaced "rosrun euroc_c2_demos euroc_c2_demo "$@"" with "roslaunch mypackage mylaunch.launch" in the script. The problem now is that even if my nodes are terminating after all challenges the roslaunch task still keeps running and so the next line in the script given by "rosrun euroc_c2_demos euroc_c2_demo "$@"" is never called.
How is it supposed to start more then one node to solve the tasks by not calling rosrun for every single node from the startup script?
Is there any workaround so that I can use launchfiles instead of starting every single node by hand?

Thanks

Johannes
joma
 
Posts: 12
Joined: Tue 29. Jul 2014, 15:15

by Advertising » Tue 29. Jul 2014, 15:26

Advertising
 

Re: Launching multiple nodes

Postby Peter Lehner » Wed 30. Jul 2014, 09:34

Hello Johannes,

I would suggest to start the launch file in the background. Then start a blocking node via rosrun which waits for some condition (message on a topic / service call) of your other nodes. Once the condition triggers the node terminates and unblocks the script. E.g:

Code: Select all
...
roslaunch your_package your.launch &  # Launching your nodes in the background
rosrun your_package blocking_node # Running the blocking node which waits for the condition
...


blocking_node could then look something like this (message example):

Code: Select all
#!/usr/bin/env python

import rospy
from std_msgs.msg import Empty
   
def blocker():
    rospy.init_node("blocker")
    rospy.wait_for_message("tasks_completed", Empty)
       
if __name__ == '__main__':
    blocker()


The node waits for the first message published to the "tasks_completed" topic and then terminates.
Peter Lehner
 
Posts: 53
Joined: Fri 27. Jun 2014, 14:33

Re: Launching multiple nodes

Postby joma » Fri 1. Aug 2014, 21:11

Hi,
thanks for the hint. I think this will work for us. I will test it on Monday and give some feedback.

Best Regards
Johannes
joma
 
Posts: 12
Joined: Tue 29. Jul 2014, 15:15


Return to Stage 1 - Simulation

Who is online

No registered users

cron