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

ROS2/Ubuntu 20.04 rosservice getting "cannot import name 'Log' from 'rosgraph_msgs.msg'"

asked 2020-12-16 11:48:29 -0500

pimenoff gravatar image

Hello, I'm trying to run rosservice and getting this error:

$ rosservice 

Traceback (most recent call last):
  File "/usr/bin/rosservice", line 34, in <module>
    import rosservice
  File "/usr/lib/python3/dist-packages/rosservice/__init__.py", line 60, in <module>
    import rospy
  File "/usr/lib/python3/dist-packages/rospy/__init__.py", line 49, in <module>
    from .client import spin, myargv, init_node, \
  File "/usr/lib/python3/dist-packages/rospy/client.py", line 54, in <module>
    import rospy.core
  File "/usr/lib/python3/dist-packages/rospy/core.py", line 75, in <module>
    from rosgraph_msgs.msg import Log
ImportError: cannot import name 'Log' from 'rosgraph_msgs.msg' (/opt/ros/foxy/lib/python3.8/site-packages/rosgraph_msgs/msg/__init__.py)

Seems all the required packages are installed. What is missing?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2021-10-22 01:46:07 -0500

prjoh gravatar image

Anyone coming to this thread because they tried to run rosbridge_server on ros2:

Instead of running

roslaunch rosbridge_server rosbridge_websocket.launch

you should run

ros2 launch rosbridge_server rosbridge_websocket_launch.xml
edit flag offensive delete link more
0

answered 2020-12-18 13:12:24 -0500

jacobperron gravatar image

updated 2020-12-18 13:13:09 -0500

Based on the error message, it looks like you've sourced a ROS 1 installation and a ROS 2 installation in the same shell. This is not recommended (except for a shell where you are running ros1_bridge).

Since rosservice is a ROS 1 command, you should not source any ROS 2 installation in the same shell, then the command should work as expected.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2020-12-16 11:46:31 -0500

Seen: 8,792 times

Last updated: Dec 18 '20