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

unable to run ros package executable

asked 2018-10-14 06:58:46 -0500

meddy gravatar image

updated 2018-10-14 10:53:47 -0500

Hello, I am trying to run a python script using the rosrun command, but each time I attempt to do this I get this message

Usage: rosrun [--prefix cmd] [--debug] PACKAGE EXECUTABLE [ARGS]
rosrun will locate PACKAGE and try to find
an executable named EXECUTABLE in the PACKAGE tree.
If it finds it, it will run it with ARGS.

The command I use to run my python script is rosrun assignment_subscriber.py

I have tried the following:

$ source devel/setup.bash

chmod +x assignment_subscriber.py

but ros will still not run the script. I am very new to ros so I may be overlooking something very simple as far as configuration, but I still haven't figured it out. Please help. Thanks

assignement_subscriber.py

#!/usr/bin/env python

import rospy
import turtle


def poseCallback(pose_message):

rospy.loginfo(" Postion:%s, %d, %z" % (data.x, data.y, data.theta))
print ("pose callback")
print ('y = %z' %)    
print ('y = %f' %)
print ('yaw = '.%) 

if __name__ == '__main__':
  try:

    rospy.init_node('turtlesim_motion_pose', anonymous=True)        

    rospy.Subscriber("turtle_position", Position, poseCallback)

    rospy.spin()


except rospy.ROSInterruptException:
    rospy.loginfo("node terminated.")
edit retag flag offensive close merge delete

Comments

You don't show us the most important thing: the exact command line you use to try and run your script.

Please add that to your question (use the edit button/link).

gvdhoorn gravatar image gvdhoorn  ( 2018-10-14 09:09:35 -0500 )edit

Additionally: this may just be the formatting of your code in this question, but all lines in the poseCallback(..) function are incorrectly indented.

gvdhoorn gravatar image gvdhoorn  ( 2018-10-14 09:10:34 -0500 )edit

do you create pkg or only write python scrip?

Hamid Didari gravatar image Hamid Didari  ( 2018-10-14 09:11:35 -0500 )edit

Thank you all for your responses. I clone a repo that already contained source files and other folders. I did run a catkin_make to build the project and have already ran a few programs from the clone repo. The problem lies when I try to add my own source file such as assignment_subscriber.py

meddy gravatar image meddy  ( 2018-10-14 10:47:03 -0500 )edit

here is a link to the repo: https://github.com/aniskoubaa/ros_ess... The command I use to run my python script is rosrun assignment_subscriber.py

meddy gravatar image meddy  ( 2018-10-14 10:49:36 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-10-14 14:01:47 -0500

gvdhoorn gravatar image

The command I use to run my python script is rosrun assignment_subscriber.py

That is not how rosrun works, and is the reason you are seeing the message that you describe.

rosrun requires as the first argument a package name, the second argument is the executable (a script or a binary).

So you'll have to place your script in a ROS package. Then you can use rosrun to start it.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2018-10-14 06:58:46 -0500

Seen: 13,901 times

Last updated: Oct 14 '18