ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

Strange problem with ROSLaunchParent

asked 2018-06-07 04:16:54 -0500

sebh gravatar image

Hello all, my first post on this forum!

I have a strange problem trying to launch a launch file using ROSLaunchParent.

I have a node I am trying to launch using a launch file:

<launch>

    <!-- Launch the robot_localization node -->
    <node pkg="robot_localization" type="ekf_localization_node" name="ekf_symeter" clear_params="true">
        <rosparam command="load" file="$(find symeter2)/config/ekf_config.yaml" />

    </node>
</launch>

which is named symeter2_nav.launch, and which belongs to a package named symeter2.

If I attempt to launch through the command line interface, all goes well:

$ roslaunch symeter2 symeter2_nav.launch 
... logging to /home/tellus-user/.ros/log/1eef2bb4-68a6-11e8-b842-48e2444fe644/roslaunch-pcrouge-720.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://pcrouge:37605/

SUMMARY
========

CLEAR PARAMETERS
 * /ekf_symeter/

PARAMETERS
 * /ekf_symeter/acceleration_gains: [1.0, 0.0, 0.0, 0...
 * /ekf_symeter/acceleration_limits: [20, 20, 20, 3, 3...
.....

However, if I try to launch the exact same launch file programmatically using the following code:

import roslaunch

class MyPlugin(Plugin):

 ...
    def startnav_pressed(self):
        self.launch_startnav()
        return

...

    def launch_startnav(self):
        uuid = roslaunch.rlutil.get_or_generate_uuid(None, False)
        roslaunch.configure_logging(uuid)

        cli_args = ['symeter2', 'symeter2_nav.launch']
        roslaunch_file = roslaunch.rlutil.resolve_launch_arguments(cli_args)
        roslaunch_arg = []
        launch = roslaunch.parent.ROSLaunchParent(uuid, [(roslaunch_file, roslaunch_arg)])

        rospy.loginfo("roslaunch_file is %s", roslaunch_file)

        launch.start()

the calling node crashes with the following message:

[INFO] [1528297147.923750, 6.622000]: roslaunch_file is ['/home/tellus-user/Bureau/StageSebh/repos/testgazebo/src/symeter2/launch/symeter2_nav.launch']
Traceback (most recent call last):
  File "/home/tellus-user/Bureau/StageSebh/repos/testgazebo/src/symeter2_gui/src/symeter2_gui/my_module.py", line 80, in startnav_pressed
    self.launch_startnav()
  File "/home/tellus-user/Bureau/StageSebh/repos/testgazebo/src/symeter2_gui/src/symeter2_gui/my_module.py", line 114, in launch_startnav
    launch.start()
  File "/opt/ros/lunar/lib/python2.7/dist-packages/roslaunch/parent.py", line 271, in start
    self._start_infrastructure()
  File "/opt/ros/lunar/lib/python2.7/dist-packages/roslaunch/parent.py", line 220, in _start_infrastructure
    self._load_config()
  File "/opt/ros/lunar/lib/python2.7/dist-packages/roslaunch/parent.py", line 135, in _load_config
    roslaunch_strs=self.roslaunch_strs, verbose=self.verbose)
  File "/opt/ros/lunar/lib/python2.7/dist-packages/roslaunch/config.py", line 459, in load_config_default
    raise RLException(e)
roslaunch.core.RLException: Invalid roslaunch XML syntax: 'list' object has no attribute 'read'

which is strange as my launch file has no list object. Has anybody got any idea to what is going on?

My environment is * /rosdistro: lunar * /rosversion: 1.13.6 on Ubuntu 16.04

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-12-04 09:02:35 -0500

jannkar gravatar image

Same error happens in Melodic as well. Since you don't pass any launch arguments, you can just simply start the launch file in a similar way as specified in wiki:

import rospkg
rospack = rospkg.RosPack()
...
launch_path = rospack.get_path('symeter2') + '/symeter2_nav.launch'
cli_args = [launch_path]
roslaunch_file = roslaunch.rlutil.resolve_launch_arguments(cli_args)
launch = roslaunch.parent.ROSLaunchParent(uuid, roslaunch_file)

I believe this same solution works for Lunar as well.

For the people who receive this error when trying to launch multiple launch files at the same time, there seems to be error in wiki. As suggested by @kawa, changing

roslaunch_file = roslaunch.rlutil.resolve_launch_arguments(cli_args)

to

roslaunch_file = roslaunch.rlutil.resolve_launch_arguments(cli_args)[0]

helped me to solve the error.

edit flag offensive delete link more
0

answered 2019-07-02 16:13:06 -0500

zultron gravatar image

I'm guessing you're using Kinetic or earlier. Launch file arguments were only added to the roslaunch API in Lunar, as stated on the wiki.

We're still on Kinetic, and I wasn't paying attention to the docs and hit the same error. The original exception is caught and re-raised (a couple of times!), which covers up the real location of the problem, and the mismatched error and traceback don't make sense anymore.

edit flag offensive delete link more

Comments

4

I'm having this problem on Melodic, too.

Karl_Costa gravatar image Karl_Costa  ( 2019-10-28 05:28:07 -0500 )edit

Same problem here on Melodic. Using the API examples, I can get a single launchfile to work but run into this problem with multiple launchfiles.

voltron gravatar image voltron  ( 2020-01-29 11:11:20 -0500 )edit

same problem on Melodic. Anyone has got a solution?

azerila gravatar image azerila  ( 2020-05-11 09:25:46 -0500 )edit
2

I was sucsessed when I changed "roslaunch_file = roslaunch.rlutil.resolve_launch_arguments(cli_args)" to "roslaunch_file = roslaunch.rlutil.resolve_launch_arguments(cli_args)[0]"

kawa gravatar image kawa  ( 2020-05-23 12:45:31 -0500 )edit
1

still gives strange errors like: _compile_info(code, p, flags) File "/usr/lib/python2.7/sre_compile.py", line 536, in _compile_info _compile_charset(charset, flags, code) File "/usr/lib/python2.7/sre_compile.py", line 232, in _compile_charset flags & SRE_FLAG_UNICODE): KeyboardInterrupt Arguments = namedtuple('Arguments', 'args varargs keywords') File "/usr/lib/python2.7/collections.py", line 386, in namedtuple exec class_definition in namespace File "<string>", line 1, in <module> KeyboardInterrupt

But I don't do any keyboard intrupt.

azerila gravatar image azerila  ( 2020-05-28 15:47:38 -0500 )edit

i just add
while not rospy.is_shutdown(): rospy.sleep(0.1) after parent.start() and solved the problem parent.start() while not rospy.is_shutdown(): rospy.sleep(0.1)

hansolo111 gravatar image hansolo111  ( 2022-11-28 21:01:34 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-06-07 04:16:54 -0500

Seen: 1,446 times

Last updated: Dec 04 '20