Strange problem with ROSLaunchParent
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
Asked by sebh on 2018-06-07 04:16:54 UTC
Answers
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.
Asked by zultron on 2019-07-02 16:13:06 UTC
Comments
I'm having this problem on Melodic, too.
Asked by Karl_Costa on 2019-10-28 05:28:07 UTC
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.
Asked by voltron on 2020-01-29 12:11:20 UTC
same problem on Melodic. Anyone has got a solution?
Asked by azerila on 2020-05-11 09:25:46 UTC
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]"
Asked by kawa on 2020-05-23 12:45:31 UTC
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 "
But I don't do any keyboard intrupt.
Asked by azerila on 2020-05-28 15:47:38 UTC
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)
Asked by hansolo111 on 2022-11-28 22:01:34 UTC
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.
Asked by jannkar on 2020-12-04 09:44:55 UTC
Comments