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

Revision history [back]

click to hide/show revision 1
initial version

My best guess (and verified on my machine): You forgot the Shebang (https://en.wikipedia.org/wiki/Shebang_(Unix)) to set the interpreter and thereby try to interpret the script as bash/shell script.

This should work:

#!/usr/bin/env python
from robot_control_class import RobotControl

robotcontrol = RobotControl()

laser1 = robotcontrol.get_laser(0)
print ("The laser value received is: ", laser1)

laser2 = robotcontrol.get_laser(360)
print ("The laser value received is: ", laser2)

laser2 = robotcontrol.get_laser(719)
print ("The laser value received is: ", laser2)

My best guess (and verified on my machine): You forgot the Shebang (https://en.wikipedia.org/wiki/Shebang_(Unix)) to set the interpreter and thereby try to interpret the script as bash/shell script.

This should work:

#!/usr/bin/env python
from robot_control_class import RobotControl

robotcontrol = RobotControl()

laser1 = robotcontrol.get_laser(0)
print ("The laser value received is: ", laser1)

laser2 = robotcontrol.get_laser(360)
print ("The laser value received is: ", laser2)

laser2 = robotcontrol.get_laser(719)
print ("The laser value received is: ", laser2)

edit: the other option would be to explicitly run the interpreter with your script (python variables.py) but this won't work using rosrun my_awesome_package variables.py which relies on the shebang.

I'm not sure how XML comes into place here, so maybe think about another title to help others with similar issues find your question.

If you want to work with python3 (generally recommended, but a pain in kinetic or melodic) the shebang has to be #!/usr/bin/env python3