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

SyntaxError: invalid syntax during launching move_it

asked 2020-03-18 00:24:59 -0500

Augustine_Sena gravatar image

Hey i'm new in ROS. I've been tried to launch moveit! roslaunch moveit_setup_assistant setup_assistant.launch i'd got these error "SyntaxError: invalid syntax ". These are my traceback:

Traceback (most recent call last):
  File "/opt/ros/melodic/bin/roslaunch", line 34, in <module>
    import roslaunch
  File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/__init__.py", line 62, in <module>
    from .scriptapi import ROSLaunch
  File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/scriptapi.py", line 42, in <module>
    import roslaunch.parent
  File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/parent.py", line 54, in <module>
    import roslaunch.server
  File "/opt/ros/melodic/lib/python2.7/dist-packages/roslaunch/server.py", line 79, in <module>
    from rosgraph_msgs.msg import Log
  File "/opt/ros/dashing/lib/python3.6/site-packages/rosgraph_msgs/msg/__init__.py", line 1, in <module>
    from rosgraph_msgs.msg._clock import Clock  # noqa: F401
  File "/opt/ros/dashing/lib/python3.6/site-packages/rosgraph_msgs/msg/_clock.py", line 56
    class Clock(metaclass = Metaclass_Clock):
                          ^
SyntaxError: invalid syntax

And these might be related error but i've feel doesn't help :https://answers.ros.org/question/221035/ros-scripts-and-python-related-error/ Please I need help, and anybody have suggestion ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2020-03-18 03:34:04 -0500

gvdhoorn gravatar image

updated 2020-03-18 04:48:41 -0500

We see this:

File "/opt/ros/melodic/bin/roslaunch",

and:

File "/opt/ros/dashing/lib/python3.6

which suggests you have both ROS 1 Melodic and ROS 2 Dashing installed on your machine.

Moreover, you probably also have both ROS versions sourced in the same shell. Do you have two source /opt/ros/.../setup.bash lines in your .bashrc by any chance?

If so, remove the one for ROS 2 for now and see whether things start working.

edit flag offensive delete link more
1

answered 2020-03-18 04:40:23 -0500

sbambula gravatar image

It is probably because you are running ROS under python 2.7 and in your code you are using Python 3 syntax for metaclass definition. So i would say there is a mixure of Python versions.

edit flag offensive delete link more

Comments

The traceback makes reference to ROS Dashing, which is a ROS 2 version which makes use of Python 3. So that would be expected.

What the OP needs to do is sort out in which order he sources things, and/or whether he even needs to source both ROS versions at the same time.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-18 04:48:33 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-03-18 00:24:59 -0500

Seen: 1,324 times

Last updated: Mar 18 '20