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

Launching a Python program without a #! at the top

asked 2011-09-15 06:25:17 -0500

John Hoare gravatar image

updated 2014-01-28 17:10:23 -0500

ngrennan gravatar image

I am currently porting some of our code/infrastructure to electric from diamondback. When trying to launch my new electric stuff, I get a problem being able to launch one of our third party libraries (dynamixel_controllers) It looks like all the python programs in this package do not have the #!/usr/bin/python at the top of the files, and now they will not launch with the following error message:

If it is a script, you may be missing a '#!' declaration at the top.

I haven't changed anything related to this, and while I can add the #! to the top of each file, I'd rather not as it is an external library, and I don't want to be running our own fork of it. Is there something new to electric that I must do to launch python files?

[Update]

The specific file I'm attempting to run is the joint_trajectory_action_controller.py file from the dynamixel_controllers package. Should this be launched instead by the controller spawner or something? Here's the associated (failing) launch file:

<launch>
    <!-- Load joint names from yaml file -->
    <rosparam file="$(find cyton_arm_driver)/config/joint_controllers.yaml" command="load"/>

    <node name="cyton_joint_action_controller" pkg="dynamixel_controllers" type="joint_trajectory_action_controller.py" required="true">
        <param name="~controller_namespace" type="str" value=""/>
    </node>
</launch>
edit retag flag offensive close merge delete

Comments

John, what files are you trying to run that don't have #! line? The two nodes that are designed to run as a script have that line (controller_manager.py and controller_spawner.py), all other modules are not supposed to be run standalone.
arebgun gravatar image arebgun  ( 2011-09-15 06:29:30 -0500 )edit
Please see my update, I am trying to run the joint_trajectory_action_controller.py file.
John Hoare gravatar image John Hoare  ( 2011-09-15 07:25:59 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
2

answered 2011-09-15 07:45:41 -0500

arebgun gravatar image

updated 2011-09-15 10:05:49 -0500

You are correct, joint_trajectory_action_controller was redesigned in electric version of dynamixel_controllers package. In Diamondback version it was a standalone node that communicated with joint controllers through ROS topics. In Electric version it was rewritten to be more like a standard joint controller to gain direct access to serial port. New version is much smoother than the old one because commands (both velocity and position) for all controlled joints are packed into a single packet that gets sent over the serial bus (before we had to send a separate command for each velocity/position change for each joint).

With that said, the way you start joint_trajectory_action_controller is also different in Electric, now you have to use controller_spawner.py script to start it up. When trajectory controller starts up it expects joint controllers for all joint it will control to be up and running. I haven't yet written proper documentation for it, but there's a couple of examples for 2 different arms that will help you to get started:

Wubble robot's arm: launch file, joint controllers configuration and trajectory controller configuration

Pi robot's arm: launch file, joint controller configuration (also includes trajectory controller configuration at the very bottom)

Basically, when launching joint trajectory controller you need to specify all its dependencies (all joint controllers that it will use to carry out the desired trajectory).

Let me know if you have any problems running this.

edit flag offensive delete link more

Comments

Thanks, following this post and those examples I've successfully ported everything over to the Electric version. Thanks.
John Hoare gravatar image John Hoare  ( 2011-09-15 10:31:47 -0500 )edit
Great! Send some videos, I'd like to see how Cyton arm works :)
arebgun gravatar image arebgun  ( 2011-09-15 10:33:52 -0500 )edit
0

answered 2011-09-15 07:28:25 -0500

John Hoare gravatar image

updated 2011-09-15 07:30:02 -0500

Okay, upon looking at this again, it looks like the version or joint_trajectory_action_controller.py I had before did have the #! in it, and the one that is distributed with electric no longer has the #!/usr/bin/env python line.

So this actually had nothing to do with ROS, and everything to do with something changing between the version of the dynamixel I was using to the one that is being distributed now.

edit flag offensive delete link more
0

answered 2011-09-15 06:33:42 -0500

kwc gravatar image

I don't recall changing anything in roslaunch in electric with regards to this. I am surprised you were ever able to do this as files with out the #! would not be run correctly with the Python interpreter. You can test for yourself by simply trying to execute the scripts at the commandline, e.g.

./scriptname.py
edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-09-15 06:25:17 -0500

Seen: 4,105 times

Last updated: Sep 15 '11