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

ros2 run bash script from Python package

asked 2023-01-05 11:53:11 -0600

jbarry gravatar image

updated 2023-01-05 13:16:34 -0600

Hi,

I would like to be able to run a bash script using ros2 run <my package> <my shell script>. I have added the shell script (estop_nogui.sh) to the setup.py of the package (it's a Python package) as follows:

entry_points={
    'console_scripts': [
        'spot_ros2 = spot_driver.spot_ros2:main',
        'spot_commander = spot_driver.spot_commander:main',
        'estop_gui = spot_driver.estop_gui:main',
    ],
},
scripts = [
    'scripts/estop_nogui.sh',
],

This results in the file installed at install/spot_driver/lib/spot_driver/. It's an executable file but ros2 run can't find it. What else do I need to do for this?

Thanks!

-Jenny

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-01-05 14:08:13 -0600

jbarry gravatar image

updated 2023-01-05 14:08:35 -0600

Turns out I had two problems:

1) I had built in the wrong directory. Once I built in the correct directory ros2 run was able to find the script.

2) Once ros2 run did find it I get an "Exec format error" because I was missing #! /bin/bash at the top of the script.

With these two fixes, this is working!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-01-05 11:53:11 -0600

Seen: 705 times

Last updated: Jan 05 '23