ROS2学习记录

虽然以前学习过ROS1,但是由于其固有的一些弱点,如roscore瓶颈问题,实时性问题等,决定换装ROS2,据说很牛。

最近换装ROS2 humble,主要参照了鱼香ROS的博文,确实很不错,从ROS2的一键安装 (动手学ROS2 (fishros.com) ),ROS2的概要,以及在ROS2上对机器人建模,仿真,过程都很详实,省了不少时间。

但在仿真时,安装gazebo环节,出现了一点问题,按照步骤输入如下命令:

sudo apt install ros-humble-gazebo-ros

在launch仿真时报错,说找不到一些plugin,如两轮差速、传感器、惯导等。到ros中看,发现plugin很少:

frank@Chen1AI:cd /opt/ros/humble/lib

frank@Chen1AI:/opt/ros/humble/lib$ ls libgazebo_ros*
libgazebo_ros_factory.so       libgazebo_ros_init.so  libgazebo_ros_properties.so  libgazebo_ros_utils.so
libgazebo_ros_force_system.so  libgazebo_ros_node.so  libgazebo_ros_state.so

最后研究发现ROS2中用于与Gazebo交互的一组ROS 2软件包是包含在一个名为gazebo_ros_pkgs的元软件包中,应该安装这个软件包,安装后问题解决。

sudo apt install ros-humble-gazebo-ros-pkgs

再次查看ros中与gazebo相关的插件,发现了很多新增插件,所选要的插件也在其中了:

frank@Chen1AI:~$ cd /opt/ros/humble/lib
frank@Chen1AI:/opt/ros/humble/lib$ ls libgazebo_ros*
libgazebo_ros_ackermann_drive.so  libgazebo_ros_force.so         libgazebo_ros_imu_sensor.so             libgazebo_ros_planar_move.so  libgazebo_ros_tricycle_drive.so
libgazebo_ros_bumper.so           libgazebo_ros_force_system.so  libgazebo_ros_init.so                   libgazebo_ros_projector.so    libgazebo_ros_utils.so
libgazebo_ros_camera.so           libgazebo_ros_ft_sensor.so     libgazebo_ros_joint_pose_trajectory.so  libgazebo_ros_properties.so   libgazebo_ros_vacuum_gripper.so
libgazebo_ros_diff_drive.so       libgazebo_ros_gps_sensor.so    libgazebo_ros_joint_state_publisher.so  libgazebo_ros_ray_sensor.so   libgazebo_ros_video.so
libgazebo_ros_elevator.so         libgazebo_ros_hand_of_god.so   libgazebo_ros_node.so                   libgazebo_ros_state.so        libgazebo_ros_wheel_slip.so
libgazebo_ros_factory.so          libgazebo_ros_harness.so       libgazebo_ros_p3d.so                    libgazebo_ros_template.so

再次运行仿真,一切正常:

frank@Chen1AI:~$ ros2 launch fishbot_description gazebo.launch.py
[INFO] [launch]: All log files can be found below /home/frank/.ros/log/2022-11-08-17-40-10-266882-Chen1AI-10640
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [gazebo-1]: process started with pid [10641]
[INFO] [spawn_entity.py-2]: process started with pid [10643]
[gazebo-1] Gazebo multi-robot simulator, version 11.10.2
[gazebo-1] Copyright (C) 2012 Open Source Robotics Foundation.
[gazebo-1] Released under the Apache 2 License.
[gazebo-1] http://gazebosim.org
[gazebo-1]
[spawn_entity.py-2] [INFO] [1667900410.570573989] [spawn_entity]: Spawn Entity started
[spawn_entity.py-2] [INFO] [1667900410.570858633] [spawn_entity]: Loading entity XML from file /home/frank/fishros/chapter8/chapter8_ws/install/fishbot_description/share/fishbot_description/urdf/fishbot_gazebo.urdf
[spawn_entity.py-2] [INFO] [1667900410.571355755] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
[spawn_entity.py-2] [INFO] [1667900410.571559127] [spawn_entity]: Waiting for service /spawn_entity
[gazebo-1] Gazebo multi-robot simulator, version 11.10.2
[gazebo-1] Copyright (C) 2012 Open Source Robotics Foundation.
[gazebo-1] Released under the Apache 2 License.
[gazebo-1] http://gazebosim.org
[gazebo-1]
[spawn_entity.py-2] [INFO] [1667900411.325002607] [spawn_entity]: Calling service /spawn_entity
[spawn_entity.py-2] [INFO] [1667900411.495162610] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [fishbot]
[gazebo-1] [INFO] [1667900411.604246456] [diff_drive]: Wheel pair 1 separation set to [0.200000m]
[gazebo-1] [INFO] [1667900411.604533524] [diff_drive]: Wheel pair 1 diameter set to [0.065000m]
[gazebo-1] [INFO] [1667900411.605222106] [diff_drive]: Subscribed to [/cmd_vel]
[gazebo-1] [INFO] [1667900411.606428117] [diff_drive]: Advertise odometry on [/odom]
[gazebo-1] [INFO] [1667900411.607548909] [diff_drive]: Publishing odom transforms between [odom] and [base_footprint]
[gazebo-1] [INFO] [1667900411.612540911] [fishbot_joint_state]: Going to publish joint [right_wheel_joint]
[gazebo-1] [INFO] [1667900411.612559265] [fishbot_joint_state]: Going to publish joint [left_wheel_joint]
[INFO] [spawn_entity.py-2]: process has finished cleanly [pid 10643]
[gazebo-1] [Msg] Waiting for master.
[gazebo-1] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
[gazebo-1] [Msg] Publicized address: 192.168.32.22
[gazebo-1] [Msg] Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
[gazebo-1] [Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call

搞定!!!Cheer!!!

你可能感兴趣的:(机器人)