Ask Your Question
0

Cannot solve error in XML document

asked 2020-07-21 05:47:21 -0600

jimc91 gravatar image

updated 2020-07-21 09:27:45 -0600

I am working through Python 3 for Robotics on Robot Ignite website and am having issues when trying to execute a script.

The below .py script contains the following:

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)

When I try execute the script I get the following errors:

user:~/catkin_ws/src/robot_control$ ./variables.py

from: can't read /var/mail/robot_control_class

./variables.py: line 3: syntax error near unexpected token `('

./variables.py: line 3: `robotcontrol = RobotControl()'

I have tried to find the solution using XML validation through a website here https://www.xmlvalidation.com/

The error is at the first line of code. The XML validator states that "Content is not allowed in prolog" for the first line:

from robot_control_class import RobotControl

Does anyone know what I am doing wrong?

Edit:

Robot_control_class and RobotControl are classes and modules created and provided by Robot Ignite for training purposes.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-07-21 10:11:20 -0600

ipa-jba gravatar image

updated 2020-07-21 10:26:06 -0600

My best guess (and verified on my machine): You forgot the Shebang (https://en.wikipedia.org/wiki/Shebang...) 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

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-07-21 05:47:21 -0600

Seen: 73 times

Last updated: Jul 21 '20