respawn parameter problem

asked 2018-08-20 02:15:19 -0500

Chickenman gravatar image

updated 2018-09-10 05:02:15 -0500


I am starting my launchfiles using this tutorial (Part2). I have problem when I configured node parameter respawn = True in my launch file. Launch is not able to respawn node automatically when node is shutdown. I don't think this is normal behavior.

Thank you for your help.

EDIT: Here is my launchfile

<?xml version="1.0"?>

    <!--First specific robot need to be connected -->

    <rosparam command="load" ns="bp" file="$(find test_package)/config/test_config.yaml" />

    <include file="$(find test_package)/launch/test.launch">
        <arg name="load_params" default="false"/>


And here is the launchfile that is included

    <arg name="gui" default="true"/>
    <arg name="robot_ip" default="" />
    <arg name="scene_source_type" default="XXX" />
    <arg name="gazebo_gripper" default="false" />
    <!--arg name="scanner_ID" default="InstalledExamples" /-->
    <arg name="load_params" default="true"/>

    <node pkg="test_node" type="test_node" name="test_node" respawn= "true" args="$(arg gui)" output="screen">

        <param name="gui" type="bool" value="$(arg gui)" />
        <param name="gazebo_gripper" type="bool" value="$(arg gazebo_gripper)" />
        <param name="robot_ip" type="str" value="$(arg robot_ip)" />
        <param name="scene_source_type" type="str" value="$(arg scene_source_type)" />
        <!--param name="scanner_ID" type="str" value="$(arg scanner_ID)" /-->

    <node name="symmetry_parser" pkg="symmetry_parser" type="symmetry_parser" />

Point is that when I launch the launchfile through the terminal and node dies it could be restarted normally. When I launch the launchfile through the rospy interface after node dies it is not able to restart itself.

Here is my python code

 def __init__(self, name, launch_path, autorestart=True):
        self.launch_path = launch_path = name
        self.running = False
        self.autorestart = autorestart

        #initializing roslaunch UID
        self.uuid = roslaunch.rlutil.get_or_generate_uuid(None, True)
        self.launch = roslaunch.parent.ROSLaunchParent(self.uuid, [self.launch_path])
        self.node_names = []
        xml_data = xmltree.parse(launch_path).getroot()
        for node in xml_data.findall('node'):
            self.node_names.append(str("/") + node.get('name'))

    def start(self):
        if not path.exists(self.launch_path):
            raise Exception("Launchfile " + self.launch_path + " does not exist!")

        if self.running and not self.autorestart:
            print("restart rejected")

        # if this node is running, shut it down
        if self.running:

        # this ensures that UUID will be regenerated upon every restart
        self.uuid = roslaunch.rlutil.get_or_generate_uuid(None, True)
        self.launch = roslaunch.parent.ROSLaunchParent(self.uuid, [self.launch_path])

        if self.launch.start() != None:  # if process is launched and has not exitted, it returns None
            raise Exception("Cannot start required launchfile with Launcher!")
            print("\"{}\" successfully launched").format(
self.running = True

and I use it like this

launchers['test_launcher'] = Launcher("test_launcher",
**"launcher path"**)
edit retag flag offensive close merge delete


Can you your launchfile here? (or as much of it as is relevant.)

etappan gravatar image etappan  ( 2018-09-04 08:26:07 -0500 )edit

I added my scripts for better understanding the problem

Chickenman gravatar image Chickenman  ( 2018-09-10 05:02:33 -0500 )edit