Running a Python file from a ROS Launch file : Cant Find it
So I have the following Launch file, when I run the launch file it errors saying it cant find the Python file
<?xml version="1.0"?>
<launch>
<node name="brickpi.py" pkg="brickpi" type="brickpi.py" output="screen">
<node pkg="xv_11_laser_driver" type="neato_laser_publisher" name="xv_11_node">
<!--<param name="port" value="/dev/tty.usbserial-A9UXLBBR"/>-->
<param name="port" value="/dev/tty.ACM0"/>
<param name="firmware_version" value="2"/>
<param name="frame_id" value="laser"/>
</node>
<node pkg="tf" type="static_transform_publisher" name="base_frame_2_laser" args="0 0 0 0 0 0 /base_frame /laser 100"/>
<include file="default_mapping.launch"/>
<include file="$(find hector_geotiff)/launch/geotiff_mapper.launch"/>
</launch>
The file is in the same directory as the launch file, I have also copied it in to
- /home/pi/catkin_ws/src/brickpi/brickpi.py
- /home/pi/catkin_ws/src/brickpi/src/brickpi.py
- /home/pi/catkin_ws/src/brickpi.py
- /home/pi/catkin_ws/build/brickpi/brickpi.py
error:
ERROR: cannot launch node of type [brickpi/brickpi.py]: brickpi
ROS path
[0]=/opt/ros/indigo/share/ros ROS path
[1]=/home/pi/catkin_ws/src ROS path
[2]=/opt/ros/indigo/share ROS path
[3]=/opt/ros/indigo/stacks
Update I have done chmod +x to the file but I must point out I have not made a package.xml, CMakeText or anything, I can run the file on its own via python and all works so maybe my issue is for a Launch file to use it, I must make a Package?
All code can be found here https://github.com/burf2000/ROS_Robot
Did you make the Python file executable?
In your CMakeLists.txt do you have you Python program listed in the
catkin_install_python
section?I have a working example here: https://gitlab.com/bradanlane/locoro
@burf2000: I think you'll only get (well intended) guesses from other board members, unless we can get access to (a minimal working example of) your code. In principle, this should all work, but there is probably a minor thing missing or not setup correctly which causes problems.
@suforeman: that is good advice, but installing artefacts is not needed when working with the
devel
space (asrosrun
et al. will typically resolve Python packages to thesrc
space).Thanks @gvdhoorn, I'm still learning. My example still my shed some light. At least it's working for me. I also recall a situation similar to the OP that happened early on in my project. I had forgotten to
source devel/setup.bash
.Yes, I was thinking something like that may have happened here (as it should just be enough to
chmod +x
a Python script torosrun
it, as long as it's in a ROS pkg), but the OP claim(s)(ed) that he already did that.I have not chmod +x the file, all I have done is dumped the file in a new directory called brickpi? Do I need to make a cmaketxt?