让gazebo classic版本的小车,通过发布ros2话题动起来
编程环境:Ubuntu20.04+ROS2 Foxy
在Gazebo11的官方教程中,Installing gazebo_ros_pkgs (ROS 2)介绍了怎样通过ros2发布cmd_vel话题来控制差速小车,在安装好需要的工具包后,教程中给出了一条命令,用来唤起Gazebo界面。
gazebo --verbose /opt/ros/foxy/share/gazebo_plugins/worlds/gazebo_ros_diff_drive_demo.world
实际上并不能唤起界面,输出提示:
[INFO] [1711608501.395137352] [gazebo_ros_node]: ROS was initialized without arguments.
正确的命令应该是
gazebo --verbose /opt/ros/foxy/share/gazebo_plugins/worlds/gazebo_ros_diff_drive_demo.world -s libgazebo_ros_init.so
你应该会看到下面的输出
[INFO] [1711606843.044762953] [demo.diff_drive]: Wheel pair 1 separation set to [1.250000m]
[INFO] [1711606843.044924607] [demo.diff_drive]: Wheel pair 1 diameter set to [0.600000m]
[INFO] [1711606843.045360212] [demo.diff_drive]: Subscribed to [/demo/cmd_demo]
[INFO] [1711606843.045766619] [demo.diff_drive]: Advertise odometry on [/demo/odom_demo]
[INFO] [1711606843.046170216] [demo.diff_drive]: Publishing odom transforms between [odom_demo] and [chassis]
[INFO] [1711606843.046183276] [demo.diff_drive]: Publishing wheel transforms between [chassis], [left_wheel_joint] and [right_wheel_joint]
这时你将会看到gazebo的界面,并且使用ros2 topic list
也应该可以看到相应的话题