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

Issue with subscriber launch

asked 2020-08-18 11:07:44 -0500

jimc91 gravatar image

updated 2020-08-18 11:09:12 -0500

I am working through tutorials and am having issues with launching my subscriber launch file.

I have created a launch file named odom_subscriber.launch and have the following text in the launch file:

<launch>
    <node pkg="read_odometry" type="odom_subscriber.py" name="odom_sub_node" output="screen" />
</launch>

I have created my python file named odom_subscriber.py and have the following text in it:

    #! /usr/bin/env python

    import rospy

    from nav_msgs.msg import Odometry

    def callback(msg): 

      print msg 

    rospy.init_node('odom_sub_node')

sub = rospy.Subscriber('/odom', Odometry, callback)

rospy.spin()

However, when I try to launch the launch file I get an error. I know I am not subscribing to anything just yet but I wanted to test it to see if all was good at this stage.

To launch the file I used the command:

roslaunch odom_subscriber.launch

I then get the error:

[odom_subscriber.launch] is not a launch file name
The traceback for the exception was written to the log file

Does anyone know where I have gone wrong?

edit retag flag offensive close merge delete

Comments

I actually had this in my notes that I had taken and never spotted that I had to add the package also, how silly of me....

jimc91 gravatar image jimc91  ( 2020-08-19 03:50:30 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-08-19 03:45:35 -0500

rfn123 gravatar image

updated 2020-08-19 04:37:38 -0500

EDIT: as corrected by @gvdhoorn

The syntax for running a launchfile is

roslaunch <package_name> <launchfile_name>

OR

roslaunch /path/to/file.launch

So in your case it would be sth like this:

roslaunch your_package odom_subscriber.launch or roslaunch /path/to/odom_subscriber.launch

See the roslaunch wiki

edit flag offensive delete link more

Comments

1

It could be this helped the OP, but for completeness: roslaunch does support launching .launch files not hosted by packages. So you could actually roslaunch /path/to/my.launch.

gvdhoorn gravatar image gvdhoorn  ( 2020-08-19 04:11:49 -0500 )edit

Question Tools

Stats

Asked: 2020-08-18 11:07:44 -0500

Seen: 259 times

Last updated: Aug 19 '20