ROS2报错:ImportError: cannot import name ‘Log‘ from ‘rosgraph_msgs.msg‘

在使用ros2的bag命令查看数据集信息时报错

Traceback (most recent call last):
  File "/opt/ros/noetic/bin/rosbag", line 34, in 
    import rosbag
  File "/opt/ros/noetic/lib/python3/dist-packages/rosbag/__init__.py", line 33, in 
    from .bag import Bag, Compression, ROSBagException, ROSBagFormatException, ROSBagUnindexedException
  File "/opt/ros/noetic/lib/python3/dist-packages/rosbag/bag.py", line 69, in 
    import rospy
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/__init__.py", line 49, in 
    from .client import spin, myargv, init_node, \
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/client.py", line 54, in 
    import rospy.core
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/core.py", line 75, in 
    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)

排查原因后发现命令写错了,ROS1用习惯了,使用的rosbag
正确的命令:

ros2 bag info ins_imu_lidar_bag_0.db3

错误的命令:

rosbag info ins_imu_lidar_bag_0.db3

你可能感兴趣的:(ROS,自动驾驶,c++)