爱折腾-创客智造实验室 - Ailibot2仿真机器人入门教程
通过Ailibot2仿真机器人入门教程学习，了解gazebo，软ailibot件，系统，固件，建图，导航等多个方面（来自爱折腾）
文章说明 本教程主要介绍如何搭建Ailibot2的仿真环境 测试环境：Ubuntu 20.04 + ROS2 Galactic 操作步骤 系统安装：Ubuntu20.04安装教程 RCM是开源代码部署工具，非常便于部署代码， RCM工具介绍 RCM安装： $ curl https://www.ncnynl.com/rcm.sh | bash - ROS2安装：ROS2 galactic安装教程 $ rcm ros2 install_ros2_now 使用RCM工具安装ailibot2仿真包 $ rcm ros2_ailibot2 install_ros2_ailibot2_sim $ source ~/ros2_ailibot2_sim_ws/install/local_setup.bash
文章说明 本教程主要介绍如何在gazebo上设计新的gazebo场景 测试环境：Ubuntu 20.04 + Gazebo11 操作步骤 启动gazebo $ gazebo 按下ctrl+b打开模型编辑界面 通过拖动侧边栏的Wall到白色编辑框，此处简单围了7x8m的空间作为测试 可根据需要添加相应的特征 点击右上角File->Save的按钮保存模型，同时退出模型编辑模式 当前回到主界面，点击上方十字按钮可以移动模型 同时可添加一些简单的障碍 最后点击右上角File->Save World As到ailibot2_gazebo/worlds文件夹下，且命名为test.world 参考资料 http://www.autolabor.com.cn/book/ROSTutorials/di-6-zhang-ji-qi-ren-xi-tong-fang-zhen/66-urdfji-cheng-gazebo/664-gazebofang-zhen-huan-jing-da-jian.html https://blog.csdn.net/qq_33742147/article/details/105437418
文章说明 本教程主要介绍如果使用gazebo插件生成场景的截面地图 测试环境： Ubuntu 20.04 + Gazebo 11 + collision_map_creator_plugin插件 操作步骤 此处使用本站RCM工具部署代码 # 安装rcm curl https://www.ncnynl.com/rcm.sh | bash - # 安装gazebo插件,ros1和ros2通用 rcm ros1_gazebo install_ros1_map_creator_plugin 测试 使用插件包中自带的world场景测试 加载场景 $ export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:~/tools/collision_map_creator_plugin/build $ gazebo ~/tools/collision_map_creator_plugin/world/simple.world --verbose Gazebo multi-robot simulator, version 11.11.0 Copyright (C) 2012 Open Source Robotics Foundation. Released under the Apache 2 License. http://gazebosim.org [Msg] Waiting for master. Gazebo multi-robot simulator, version 11.11.0 Copyright (C) 2012 Open Source Robotics Foundation. Released under the Apache 2 License. http://gazebosim.org [Msg] Waiting for master. [Msg] Connected to gazebo master @ http://127.0.0.1:11345 [Msg] Publicized address: 192.168.0.18 [Msg] Loading world file [/home/lalala/tools/collision_map_creator_plugin/world/./simple.world] Subscribing to: ~/collision_map/command [Msg] Connected to gazebo master @ http://127.0.0.1:11345 [Msg] Publicized address: 192.168.0.18 [Wrn] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/user_camera/pose, deleting message. This warning is printed only once. 指定--verbose参数，显示启动的详细信息，了解加载插件 新开终端，请求建图 $ export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:~/tools/collision_map_creator_plugin/build $ cd ~/tools/collision_map_creator_plugin/build $ ./request_publisher "(-5,5)(5,5)(5,-5)(-5,-5)" 0.1 0.05 $(pwd)/map.png 255 ground_plane::link::collision Request: LL.x: -5 LL.y: -3 UR.x: 4 UR.y: 5 Height: 0.1 Resolution: 0.05 Filename: /home/lalala/tools/collision_map_creator_plugin/build/map.png Threshold: 255 GroundEntityName: ground_plane::link::collision MinHeight: 0 done1done2done3 参数说明 "(-5,5)(5,5)(5,-5)(-5,-5)" 表示要建图的范围（单位：米），通常等于Gazebo中的栅格数； 0.1 表示垂直投影的高度； 0.05 地图分辨率，即每个像素代表0.01m； $(pwd)/cloister.png 生成地图图片的位置和名称 office_desk::link::collision 被视为地面，以白色显示，其余位置以黑色（255-255=0）着色 查看输出的地图 $ eog ~/tools/collision_map_creator_plugin/build/map.png 使用上一个教程设计的world场景进行测试 在world文件中尾部添加插件 $ rosed ailibot_gazebo test.world ... <plugin filename="libcollision_map_creator.so" name="collision_map_creator"/> </world> </sdf> 加载场景 $ export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:~/tools/collision_map_creator_plugin/build $ roscd ailibot_gazebo/worlds $ gazebo test.world --verbose 创建地图 $ export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:~/tools/collision_map_creator_plugin/build $ cd ~/tools/collision_map_creator_plugin/build $ ./request_publisher "(-5,5)(5,5)(5,-5)(-5,-5)" 0.1 0.05 $(pwd)/map.png 255 ground_plane::link::collision 如果需要在rviz上的加载这个地图，则需要翻转地图才跟gazebo的地图进行匹配，否则rviz上的小车方向是反的 翻转地图同时查看输出的地图 $ sudo apt install imagemagick $ convert map.png -flip map_flip.png $ eog ~/tools/collision_map_creator_plugin/build/map.png 创建一个地图对应的yaml文件 $ vim map_flip.yaml image: map_flip.png resolution: 0.050000 origin: [-5.000000, -5.000000, 0.000000] negate: 0 occupied_thresh: 0.65 free_thresh: 0.196 参考资料 参考资料1 参考资料2
文章说明 本教程主要介绍如何在gazebo上加载Gazebo场景 测试环境：Ubuntu 20.04 + Gazebo11 操作步骤 上篇文章中，我们制作了一个简单的场景，现在加载Gazebo场景 进入到ailibot2_gazebo/launch文件夹下，新建test_world.launch.py import os from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription from launch.conditions import IfCondition, UnlessCondition from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import Command, LaunchConfiguration, PythonExpression from launch_ros.actions import Node from launch_ros.substitutions import FindPackageShare def generate_launch_description(): # Set the path to the Gazebo ROS package pkg_gazebo_ros = FindPackageShare(package='gazebo_ros').find('gazebo_ros') # Set the path to this package. pkg_share = FindPackageShare(package='ailibot2_gazebo').find('ailibot2_gazebo') # Set the path to the world file world_file_name = 'test.world' world_path = os.path.join(pkg_share, 'worlds', world_file_name) # Set the path to the SDF model files. gazebo_models_path = os.path.join(pkg_share, 'models') os.environ["GAZEBO_MODEL_PATH"] = gazebo_models_path ########### YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE ############## # Launch configuration variables specific to simulation headless = LaunchConfiguration('headless') use_sim_time = LaunchConfiguration('use_sim_time') use_simulator = LaunchConfiguration('use_simulator') world = LaunchConfiguration('world') declare_simulator_cmd = DeclareLaunchArgument( name='headless', default_value='False', description='Whether to execute gzclient') declare_use_sim_time_cmd = DeclareLaunchArgument( name='use_sim_time', default_value='true', description='Use simulation (Gazebo) clock if true') declare_use_simulator_cmd = DeclareLaunchArgument( name='use_simulator', default_value='True', description='Whether to start the simulator') declare_world_cmd = DeclareLaunchArgument( name='world', default_value=world_path, description='Full path to the world model file to load') # Specify the actions # Start Gazebo server start_gazebo_server_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py')), condition=IfCondition(use_simulator), launch_arguments={'world': world}.items()) # Start Gazebo client start_gazebo_client_cmd = IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(pkg_gazebo_ros, 'launch', 'gzclient.launch.py')), condition=IfCondition(PythonExpression([use_simulator, ' and not ', headless]))) # Create the launch description and populate ld = LaunchDescription() # Declare the launch options ld.add_action(declare_simulator_cmd) ld.add_action(declare_use_sim_time_cmd) ld.add_action(declare_use_simulator_cmd) ld.add_action(declare_world_cmd) # Add any actions ld.add_action(start_gazebo_server_cmd) ld.add_action(start_gazebo_client_cmd) return ld 编译 $ ~/cd ros2_ailibot2_sim_ws $ colcon build --symlink-install 启动加载Gazebo场景同时加载机器人模型 $ ros2 launch ailibot2_gazebo test_world.launch.py 效果图如下
文章说明 本教程主要介绍如何加载ailibot2的URDF模型到gazebo 测试环境：Ubuntu 20.04 + Gazebo11 操作步骤 启动gazebo仿真，加载Ailibot2的urdf模型 $ ros2 launch ailibot2_bringup robot_sim.launch.py use_rviz:=true [INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2023-09-07-18-08-51-720475-ailibotOS-VM-26766 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [gzserver-1]: process started with pid [26769] [INFO] [gzclient -2]: process started with pid [26772] [INFO] [spawn_entity.py-3]: process started with pid [26774] [INFO] [robot_state_publisher-4]: process started with pid [26777] [robot_state_publisher-4] Link base_link had 8 children [robot_state_publisher-4] Link camera_bottom_screw_frame had 1 children [robot_state_publisher-4] Link camera_link had 1 children [robot_state_publisher-4] Link camera_depth_frame had 4 children [robot_state_publisher-4] Link camera_color_frame had 1 children [robot_state_publisher-4] Link camera_color_optical_frame had 0 children [robot_state_publisher-4] Link camera_depth_optical_frame had 0 children [robot_state_publisher-4] Link camera_left_ir_frame had 1 children [robot_state_publisher-4] Link camera_left_ir_optical_frame had 0 children [robot_state_publisher-4] Link camera_right_ir_frame had 1 children [robot_state_publisher-4] Link camera_right_ir_optical_frame had 0 children [robot_state_publisher-4] Link caster_back_link had 0 children [robot_state_publisher-4] Link caster_front_link had 0 children [robot_state_publisher-4] Link imu_link had 0 children [robot_state_publisher-4] Link laser_link had 0 children [robot_state_publisher-4] Link sonar_front_link had 0 children [robot_state_publisher-4] Link wheel_left_link had 0 children [robot_state_publisher-4] Link wheel_right_link had 0 children [robot_state_publisher-4] [INFO] [1694081332.651374226] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-4] [INFO] [1694081332.651822593] [robot_state_publisher]: got segment base_link [robot_state_publisher-4] [INFO] [1694081332.652175479] [robot_state_publisher]: got segment camera_bottom_screw_frame [robot_state_publisher-4] [INFO] [1694081332.652513127] [robot_state_publisher]: got segment camera_color_frame [robot_state_publisher-4] [INFO] [1694081332.652525611] [robot_state_publisher]: got segment camera_color_optical_frame [robot_state_publisher-4] [INFO] [1694081332.652531300] [robot_state_publisher]: got segment camera_depth_frame [robot_state_publisher-4] [INFO] [1694081332.652536279] [robot_state_publisher]: got segment camera_depth_optical_frame [robot_state_publisher-4] [INFO] [1694081332.652541354] [robot_state_publisher]: got segment camera_left_ir_frame [robot_state_publisher-4] [INFO] [1694081332.652546264] [robot_state_publisher]: got segment camera_left_ir_optical_frame [robot_state_publisher-4] [INFO] [1694081332.652551285] [robot_state_publisher]: got segment camera_link [robot_state_publisher-4] [INFO] [1694081332.652556349] [robot_state_publisher]: got segment camera_right_ir_frame [robot_state_publisher-4] [INFO] [1694081332.652561148] [robot_state_publisher]: got segment camera_right_ir_optical_frame [robot_state_publisher-4] [INFO] [1694081332.652565856] [robot_state_publisher]: got segment caster_back_link [robot_state_publisher-4] [INFO] [1694081332.652570584] [robot_state_publisher]: got segment caster_front_link [robot_state_publisher-4] [INFO] [1694081332.652575705] [robot_state_publisher]: got segment imu_link [robot_state_publisher-4] [INFO] [1694081332.652580548] [robot_state_publisher]: got segment laser_link [robot_state_publisher-4] [INFO] [1694081332.652585332] [robot_state_publisher]: got segment sonar_front_link [robot_state_publisher-4] [INFO] [1694081332.652590051] [robot_state_publisher]: got segment wheel_left_link [robot_state_publisher-4] [INFO] [1694081332.652594854] [robot_state_publisher]: got segment wheel_right_link [spawn_entity.py-3] [INFO] [1694081332.986670358] [spawn_entity]: Spawn Entity started [spawn_entity.py-3] [INFO] [1694081332.987017877] [spawn_entity]: Loading entity published on topic robot_description [spawn_entity.py-3] [INFO] [1694081332.988619300] [spawn_entity]: Waiting for entity xml on robot_description [spawn_entity.py-3] [INFO] [1694081332.991390178] [spawn_entity]: Waiting for service /spawn_entity, timeout = 5 [spawn_entity.py-3] [INFO] [1694081332.991757938] [spawn_entity]: Waiting for service /spawn_entity [spawn_entity.py-3] [INFO] [1694081333.746737075] [spawn_entity]: Calling service /spawn_entity [spawn_entity.py-3] [INFO] [1694081333.809630889] [spawn_entity]: Spawn status: Entity pushed to spawn queue, but spawn service timed outwaiting for entity to appear in simulation under the name [ailibot2] [spawn_entity.py-3] [ERROR] [1694081333.809957909] [spawn_entity]: Spawn service failed. Exiting. [spawn_entity.py-3] /opt/ros/galactic/lib/python3.8/site-packages/rclpy/qos.py:307: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead. [gzserver-1] [INFO] [1694081335.182281015] [ailibot_d2_controller]: Wheel pair 1 separation set to [0.325140m] [gzserver-1] [INFO] [1694081335.183276018] [ailibot_d2_controller]: Wheel pair 1 diameter set to [0.115000m] [gzserver-1] [INFO] [1694081335.184341736] [ailibot_d2_controller]: Subscribed to [/cmd_vel] [gzserver-1] [INFO] [1694081335.186874128] [ailibot_d2_controller]: Advertise odometry on [/odom] [gzserver-1] [INFO] [1694081335.189886092] [ailibot_d2_controller]: Publishing odom transforms between [odom] and [base_footprint] [gzserver-1] [INFO] [1694081335.201464472] [bytes_joint_state]: Going to publish joint [wheel_left_joint] [gzserver-1] [INFO] [1694081335.202114651] [bytes_joint_state]: Going to publish joint [wheel_right_joint] [gzserver-1] [INFO] [1694081335.237499690] [GazeboRealsenseNode]: Realsense Gazebo ROS plugin loading. [gzserver-1] [gzserver-1] RealSensePlugin: The realsense_camera plugin is attach to model ailibot2 [gzserver-1] [INFO] [1694081335.296541972] [GazeboRealsenseNode]: Loaded Realsense Gazebo ROS plugin. [gzclient -2] context mismatch in svga_surface_destroy [gzclient -2] context mismatch in svga_surface_destroy 效果图如下： 查看话题 $ ros2 topic list /camera/color/camera_info /camera/color/image_raw /camera/color/image_raw/compressed /camera/depth/camera_info /camera/depth/image_rect_raw /camera/depth/image_rect_raw/compressed /camera/infra1/camera_info /camera/infra1/image_raw /camera/infra1/image_raw/compressed /camera/infra2/camera_info /camera/infra2/image_raw /camera/infra2/image_raw/compressed /clock /cmd_vel /imu/data /joint_states /odom /parameter_events /performance_metrics /robot_description /rosout /scan /sensor/sonar_front /tf /tf_static 查看对应的tf树 $ ros2 run rqt_tf_tree rqt_tf_tree 效果图如下：
文章说明 本教程主要介绍如何加载Ailibot2的SDF模型到gazebo 操作步骤 启动gazebo仿真，加载Ailibot2的SDF模型 $ ros2 launch ailibot2_bringup robot_sim_with_sdf.launch.py use_rviz:=true [INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2023-09-07-12-05-31-122302-ailibotOS-VM-8978 [INFO] [launch]: Default logging verbosity is set to INFO GAZEBO_MODEL_PATH: /usr/share/gazebo-11/models::/home/ubuntu/ros2_ailibot2_sim_ws/install/ailibot2_description/share/ailibot2_description/meshes [INFO] [robot_state_publisher-1]: process started with pid [8981] [INFO] [gzserver-2]: process started with pid [8983] [INFO] [gzclient -3]: process started with pid [8985] [INFO] [spawn_entity.py-4]: process started with pid [8988] [robot_state_publisher-1] Link base_link had 8 children [robot_state_publisher-1] Link camera_bottom_screw_frame had 1 children [robot_state_publisher-1] Link camera_link had 1 children [robot_state_publisher-1] Link camera_depth_frame had 4 children [robot_state_publisher-1] Link camera_color_frame had 1 children [robot_state_publisher-1] Link camera_color_optical_frame had 0 children [robot_state_publisher-1] Link camera_depth_optical_frame had 0 children [robot_state_publisher-1] Link camera_left_ir_frame had 1 children [robot_state_publisher-1] Link camera_left_ir_optical_frame had 0 children [robot_state_publisher-1] Link camera_right_ir_frame had 1 children [robot_state_publisher-1] Link camera_right_ir_optical_frame had 0 children [robot_state_publisher-1] Link caster_back_link had 0 children [robot_state_publisher-1] Link caster_front_link had 0 children [robot_state_publisher-1] Link imu_link had 0 children [robot_state_publisher-1] Link laser_link had 0 children [robot_state_publisher-1] Link sonar_front_link had 0 children [robot_state_publisher-1] Link wheel_left_link had 0 children [robot_state_publisher-1] Link wheel_right_link had 0 children [robot_state_publisher-1] [INFO] [1694059532.660441133] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-1] [INFO] [1694059532.660568092] [robot_state_publisher]: got segment base_link [robot_state_publisher-1] [INFO] [1694059532.660581127] [robot_state_publisher]: got segment camera_bottom_screw_frame [robot_state_publisher-1] [INFO] [1694059532.660586826] [robot_state_publisher]: got segment camera_color_frame [robot_state_publisher-1] [INFO] [1694059532.660591711] [robot_state_publisher]: got segment camera_color_optical_frame [robot_state_publisher-1] [INFO] [1694059532.660610149] [robot_state_publisher]: got segment camera_depth_frame [robot_state_publisher-1] [INFO] [1694059532.660617151] [robot_state_publisher]: got segment camera_depth_optical_frame [robot_state_publisher-1] [INFO] [1694059532.660621725] [robot_state_publisher]: got segment camera_left_ir_frame [robot_state_publisher-1] [INFO] [1694059532.660626340] [robot_state_publisher]: got segment camera_left_ir_optical_frame [robot_state_publisher-1] [INFO] [1694059532.660630679] [robot_state_publisher]: got segment camera_link [robot_state_publisher-1] [INFO] [1694059532.660635211] [robot_state_publisher]: got segment camera_right_ir_frame [robot_state_publisher-1] [INFO] [1694059532.660639759] [robot_state_publisher]: got segment camera_right_ir_optical_frame [robot_state_publisher-1] [INFO] [1694059532.660644230] [robot_state_publisher]: got segment caster_back_link [robot_state_publisher-1] [INFO] [1694059532.660648655] [robot_state_publisher]: got segment caster_front_link [robot_state_publisher-1] [INFO] [1694059532.660652978] [robot_state_publisher]: got segment imu_link [robot_state_publisher-1] [INFO] [1694059532.660657278] [robot_state_publisher]: got segment laser_link [robot_state_publisher-1] [INFO] [1694059532.660661839] [robot_state_publisher]: got segment sonar_front_link [robot_state_publisher-1] [INFO] [1694059532.660666095] [robot_state_publisher]: got segment wheel_left_link [robot_state_publisher-1] [INFO] [1694059532.660670503] [robot_state_publisher]: got segment wheel_right_link [spawn_entity.py-4] [INFO] [1694059533.453061905] [spawn_entity]: Spawn Entity started [spawn_entity.py-4] [INFO] [1694059533.453582284] [spawn_entity]: Loading entity XML from file /home/ubuntu/ros2_ailibot2_sim_ws/install/ailibot2_gazebo/share/ailibot2_gazebo/models/ailibot2/d2/ailibot_d2.sdf [spawn_entity.py-4] [INFO] [1694059533.466719430] [spawn_entity]: Waiting for service /spawn_entity, timeout = 5 [spawn_entity.py-4] [INFO] [1694059533.467070718] [spawn_entity]: Waiting for service /spawn_entity [spawn_entity.py-4] [INFO] [1694059535.376824884] [spawn_entity]: Calling service /spawn_entity [spawn_entity.py-4] [INFO] [1694059536.590096599] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [ailibot2] [INFO] [spawn_entity.py-4]: process has finished cleanly [pid 8988] [gzserver-2] [INFO] [1694059537.684684673] [GazeboRealsenseNode]: Realsense Gazebo ROS plugin loading. [gzserver-2] [gzserver-2] RealSensePlugin: The realsense_camera plugin is attach to model ailibot2 [gzserver-2] [INFO] [1694059538.412087799] [GazeboRealsenseNode]: Loaded Realsense Gazebo ROS plugin. [gzserver-2] [INFO] [1694059538.537634923] [diff_drive]: Wheel pair 1 separation set to [0.325140m] [gzserver-2] [INFO] [1694059538.537767828] [diff_drive]: Wheel pair 1 diameter set to [0.115000m] [gzserver-2] [INFO] [1694059538.539091745] [diff_drive]: Subscribed to [/cmd_vel] [gzserver-2] [INFO] [1694059538.572421130] [diff_drive]: Advertise odometry on [/odom] [gzserver-2] [INFO] [1694059538.610411054] [diff_drive]: Publishing odom transforms between [odom] and [base_footprint] [gzserver-2] [INFO] [1694059538.678657658] [joint_state]: Going to publish joint [wheel_left_joint] [gzserver-2] [INFO] [1694059538.678744839] [joint_state]: Going to publish joint [wheel_right_joint] [gzclient -3] context mismatch in svga_surface_destroy [gzclient -3] context mismatch in svga_surface_destroy 可选参数： 场景类型：world_type:=basic robot类型：robot_type:=d2，可选择d2/d4/o3/o4/m4 模型类型：model_type:=d2，可选择d2或d2_ekf等 查看话题 $ ros2 topic list /camera/color/camera_info /camera/color/image_raw /camera/color/image_raw/compressed /camera/depth/camera_info /camera/depth/color/points /camera/depth/image_rect_raw /camera/depth/image_rect_raw/compressed /camera/infra1/camera_info /camera/infra1/image_raw /camera/infra1/image_raw/compressed /camera/infra2/camera_info /camera/infra2/image_raw /camera/infra2/image_raw/compressed /clock /cmd_vel /imu/data /joint_states /odom /parameter_events /performance_metrics /robot_description /rosout /scan /sensor/sonar_front /tf /tf_static 当前展示ailibot2-d2SDF模型的具体代码 <?xml version="1.0" ?> <sdf version="1.5"> <model name="ailibot_d2"> <static>false</static> <pose>0.0 0.0 0 0.0 0.0 0.0</pose> <collision name="base_collision"> <pose>0 0 0.0448 0 0 0</pose> <geometry> <cylinder> <radius>0.12657</radius> <length>0.09</length> </cylinder> </geometry> </collision> <visual name="base_visual"> <pose>0 0 0 0 0 0</pose> <geometry> <mesh> <uri>model://d2/d2_base.STL</uri> </mesh> </geometry> <material> <ambient>1.0 0.0 0.0 1.0</ambient> <diffuse>1.0 0.0 0.0 1.0</diffuse> <specular>0.0 0.0 0.0 1.0</specular> <emissive>0.0 0.0 0.0 1.0</emissive> </material> </visual> <gravity>true</gravity> <sensor name="twr_imu" type="imu"> <always_on>true</always_on> <update_rate>100</update_rate> <visualize>true</visualize> <imu> <orientation> <x> <noise type="gaussian"> <mean>0.0</mean> <stddev>2e-3</stddev> </noise> </x> <y> <noise type="gaussian"> <mean>0.0</mean> <stddev>2e-3</stddev> </noise> </y> <z> <noise type="gaussian"> <mean>0.0</mean> <stddev>2e-3</stddev> </noise> </z> </orientation> <angular_velocity> <x> <noise type="gaussian"> <mean>0.0</mean> <stddev>2e-4</stddev> </noise> </x> <y> <noise type="gaussian"> <mean>0.0</mean> <stddev>2e-4</stddev> </noise> </y> <z> <noise type="gaussian"> <mean>0.0</mean> <stddev>2e-4</stddev> </noise> </z> </angular_velocity> <linear_acceleration> <x> <noise type="gaussian"> <mean>0.0</mean> <stddev>1.7e-2</stddev> </noise> </x> <y> <noise type="gaussian"> <mean>0.0</mean> <stddev>1.7e-2</stddev> </noise> </y> <z> <noise type="gaussian"> <mean>0.0</mean> <stddev>1.7e-2</stddev> </noise> </z> </linear_acceleration> </imu> <plugin name="imu" filename="libgazebo_ros_imu_sensor.so"> <initial_orientation_as_reference>false</initial_orientation_as_reference> <frame_name>imu_link</frame_name> <ros> <namespace>/imu</namespace> <remapping>~/out:=data</remapping> </ros> </plugin> </sensor> <inertial> <inertia> <ixx>0.001</ixx> <ixy>0.000</ixy> <ixz>0.000</ixz> <iyy>0.001</iyy> <iyz>0.000</iyz> <izz>0.001</izz> </inertia> <mass>0.114</mass> </inertial> <collision name="laser_collision"> <pose>0 0 0.1685 0 0 0</pose> <geometry> <cylinder> <radius>0.035</radius> <length>0.058</length> </cylinder> </geometry> </collision> <visual name="laser_visual"> <pose>0 0 0.185 0 0 0</pose> <geometry> <mesh> <uri>model://sensors/laser/rplidar-a1.STL</uri> </mesh> </geometry> <material> <ambient>0.0 0.0 0.0 1.0</ambient> <diffuse>0.0 0.0 0.0 1.0</diffuse> <specular>0.0 0.0 0.0 1.0</specular> <emissive>0.0 0.0 0.0 1.0</emissive> </material> </visual> <sensor name="laser" type="ray"> <always_on>true</always_on> <visualize>false</visualize> <update_rate>5</update_rate> <ray> <scan> <horizontal> <samples>360</samples> <resolution>1.000000</resolution> <min_angle>-3.14159</min_angle> <max_angle>3.14159</max_angle> </horizontal> </scan> <range> <min>0.3</min> <max>15.0</max> <resolution>0.015</resolution> </range> <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.01</stddev> </noise> </ray> <plugin name="scan" filename="libgazebo_ros_ray_sensor.so"> <ros> <remapping>~/out:=scan</remapping> </ros> <output_type>sensor_msgs/LaserScan</output_type> <frame_name>laser_link</frame_name> </plugin> </sensor> <pose>0.0929 0 0.1325 0 0 0</pose> <visual name="realsense_link_visual"> <pose>0 0 0 1.57 0 1.57</pose> <geometry> <mesh> <uri>model://sensors/camera/realsense_d435.stl</uri> </mesh> </geometry> </visual> <collision name="realsense_link_collision"> <pose>-0.0149 0 0 0 0 0</pose> <geometry> <box> <size>0.03 0.090 0.025</size> </box> </geometry> </collision> <inertial> <pose>0 0 0 0 0 0</pose> <inertia> <ixx>0.001</ixx> <ixy>0.000</ixy> <ixz>0.000</ixz> <iyy>0.001</iyy> <iyz>0.000</iyz> <izz>0.001</izz> </inertia> <mass>0.1</mass> </inertial> <sensor name="cameradepth" type="depth"> <camera name="camera"> <horizontal_fov>1.57</horizontal_fov> <image> <width>1280</width> <height>720</height> </image> <clip> <near>0.1</near> <far>100</far> </clip> <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.100</stddev> </noise> </camera> <always_on>1</always_on> <update_rate>30</update_rate> <visualize>0</visualize> </sensor> <sensor name="cameracolor" type="camera"> <camera name="camera"> <horizontal_fov>1.57</horizontal_fov> <image> <width>1280</width> <height>720</height> <format>RGB_INT8</format> </image> <clip> <near>0.1</near> <far>100</far> </clip> <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.007</stddev> </noise> </camera> <always_on>1</always_on> <update_rate>30</update_rate> <visualize>0</visualize> </sensor> <sensor name="cameraired1" type="camera"> <camera name="camera"> <horizontal_fov>1.57</horizontal_fov> <image> <width>1280</width> <height>720</height> <format>L_INT8</format> </image> <clip> <near>0.1</near> <far>100</far> </clip> <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.05</stddev> </noise> </camera> <always_on>1</always_on> <update_rate>1</update_rate> <visualize>0</visualize> </sensor> <sensor name="cameraired2" type="camera"> <camera name="camera"> <horizontal_fov>1.57</horizontal_fov> <image> <width>1280</width> <height>720</height> <format>L_INT8</format> </image> <clip> <near>0.1</near> <far>100</far> </clip> <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.05</stddev> </noise> </camera> <always_on>1</always_on> <update_rate>1</update_rate> <visualize>0</visualize> </sensor> <joint name="camera_joint" type="fixed"> <parent>base_link</parent> <child>camera_link</child> <pose>0 0 0 0 0 0</pose> </joint> <plugin name="camera" filename="librealsense_gazebo_plugin.so"> <prefix>camera</prefix> <depthUpdateRate>30.0</depthUpdateRate> <colorUpdateRate>30.0</colorUpdateRate> <infraredUpdateRate>1.0</infraredUpdateRate> <depthTopicName>/camera/depth/image_rect_raw</depthTopicName> <depthCameraInfoTopicName>/camera/depth/camera_info</depthCameraInfoTopicName> <colorTopicName>/camera/color/image_raw</colorTopicName> <colorCameraInfoTopicName>/camera/color/camera_info</colorCameraInfoTopicName> <infrared1TopicName>/camera/infra1/image_raw</infrared1TopicName> <infrared1CameraInfoTopicName>/camera/infra1/camera_info</infrared1CameraInfoTopicName> <infrared2TopicName>/camera/infra2/image_raw</infrared2TopicName> <infrared2CameraInfoTopicName>infra2/camera_info</infrared2CameraInfoTopicName> <colorOpticalframeName>camera_color_optical_frame</colorOpticalframeName> <depthOpticalframeName>camera_depth_optical_frame</depthOpticalframeName> <infrared1OpticalframeName>camera_left_ir_optical_frame</infrared1OpticalframeName> <infrared2OpticalframeName>camera_right_ir_optical_frame</infrared2OpticalframeName> <rangeMinDepth>0.3</rangeMinDepth> <rangeMaxDepth>3.0</rangeMaxDepth> <pointCloud>true</pointCloud> <pointCloudTopicName>/camera/depth/color/points</pointCloudTopicName> <pointCloudCutoff>0.3</pointCloudCutoff> </plugin> <pose>0 0 0 0 0 0</pose> <visual name="sonar_front_visual"> <pose>0.11297 0 0.045 0 0 0</pose> <geometry> <mesh> <uri>model://sensors/sonar/sonar.STL</uri> </mesh> </geometry> </visual> <collision name="sonar_front_collision"> <pose>0.11297 0 0.045 0 0 0</pose> <geometry> <box> <size>0.01 0.01 0.01</size> </box> </geometry> </collision> <inertial> <pose>0 0 0 0 0 0</pose> <inertia> <ixx>0.001</ixx> <ixy>0.000</ixy> <ixz>0.000</ixz> <iyy>0.001</iyy> <iyz>0.000</iyz> <izz>0.001</izz> </inertia> <mass>0.1</mass> </inertial> <sensor name="sonar_front" type="ray"> <pose>0.11297 -0.013 0.045 0 0 0</pose> <always_on>true</always_on> <visualize>false</visualize> <update_rate>5</update_rate> <ray> <scan> <horizontal> <samples>5</samples> <resolution>1.000000</resolution> <min_angle>-0.14835</min_angle> <max_angle>0.14835</max_angle> </horizontal> <vertical> <samples>5</samples> <resolution>1.000000</resolution> <min_angle>-0.01</min_angle> <max_angle>0.01</max_angle> </vertical> </scan> <range> <min>0.02</min> <max>4</max> <resolution>0.01</resolution> </range> <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.01</stddev> </noise> </ray> <plugin name="sonar_front" filename="libgazebo_ros_ray_sensor.so"> <ros> <namespace>sensor</namespace> <remapping>~/out:=sonar_front</remapping> </ros> <output_type>sensor_msgs/Range</output_type> <radiation_type>ultrasound</radiation_type> <frame_name>sonar_front</frame_name> </plugin> </sensor> <pose>0 0.16257 0.0177 0 0 0</pose> <inertial> <inertia> <ixx>0.001</ixx> <ixy>0.000</ixy> <ixz>0.000</ixz> <iyy>0.001</iyy> <iyz>0.000</iyz> <izz>0.001</izz> </inertia> <mass>1.0</mass> </inertial> <collision name="wheel_left_collision"> <pose>0 0 0 1.57 1.57 0</pose> <geometry> <cylinder> <radius>0.0575</radius> <length>0.055</length> </cylinder> </geometry> </collision> <visual name="wheel_left_visual"> <geometry> <mesh> <uri>model://d2/wheel_left.STL</uri> </mesh> </geometry> </visual> <pose>0 -0.16257 0.0177 0 0 0</pose> <inertial> <inertia> <ixx>0.001</ixx> <ixy>0.000</ixy> <ixz>0.000</ixz> <iyy>0.001</iyy> <iyz>0.000</iyz> <izz>0.001</izz> </inertia> <mass>1.0</mass> </inertial> <collision name="wheel_right_collision"> <pose>0 0 0 1.57 1.57 0</pose> <geometry> <cylinder> <radius>0.0575</radius> <length>0.055</length> </cylinder> </geometry> </collision> <visual name="wheel_right_visual"> <geometry> <mesh> <uri>model://d2/wheel_right.STL</uri> </mesh> </geometry> </visual> <pose>0.111999999999997 0 -0.027302434610445 0 0 0</pose> <inertial> <inertia> <ixx>0.001</ixx> <ixy>0.000</ixy> <ixz>0.000</ixz> <iyy>0.001</iyy> <iyz>0.000</iyz> <izz>0.001</izz> </inertia> <mass>0.2</mass> </inertial> <collision name='caster_front_collision'> <geometry> <sphere> <radius>0.012</radius> </sphere> </geometry> <surface> <friction> <ode> <mu>0.01</mu> <mu2>0.01</mu2> <slip1>1.0</slip1> <slip2>1.0</slip2> </ode> </friction> </surface> </collision> <visual name="caster_front_visual"> <geometry> <mesh> <uri>model://d2/caster_front.STL</uri> </mesh> </geometry> </visual> <pose>-0.111999999999997 0 -0.027302434610445 0 0 0</pose> <inertial> <inertia> <ixx>0.001</ixx> <ixy>0.000</ixy> <ixz>0.000</ixz> <iyy>0.001</iyy> <iyz>0.000</iyz> <izz>0.001</izz> </inertia> <mass>0.2</mass> </inertial> <collision name='caster_back_collision'> <geometry> <sphere> <radius>0.012</radius> </sphere> </geometry> <surface> <friction> <ode> <mu>0.01</mu> <mu2>0.01</mu2> <slip1>1.0</slip1> <slip2>1.0</slip2> </ode> </friction> </surface> </collision> <visual name="caster_back_visual"> <geometry> <mesh> <uri>model://d2/caster_back.STL</uri> </mesh> </geometry> </visual> <joint name="base_joint" type="fixed"> <parent>base_footprint</parent> <child>base_link</child> <pose>0 0 0 0 0 0</pose> </joint> <joint name="wheel_left_joint" type="revolute"> <parent>base_link</parent> <child>wheel_left_link</child> <pose>0 0 0 0 0 0</pose> <axis> <xyz>0 1 0</xyz> </axis> </joint> <joint name="wheel_right_joint" type="revolute"> <parent>base_link</parent> <child>wheel_right_link</child> <pose>0 0 0 0 0 0</pose> <axis> <xyz>0 1 0</xyz> </axis> </joint> <joint name='caster_front_joint' type='fixed'> <parent>base_link</parent> <child>caster_front_link</child> <pose>0 0 0 0 0 0</pose> </joint> <joint name='caster_back_joint' type='fixed'> <parent>base_link</parent> <child>caster_back_link</child> <pose>0 0 0 0 0 0</pose> </joint> <joint name="imu_joint" type="fixed"> <parent>base_link</parent> <child>imu_link</child> <pose>0 0 0 0 0 0</pose> </joint> <joint name="laser_joint" type="fixed"> <parent>base_link</parent> <child>laser_link</child> <pose>0 0 0 0 0 0</pose> </joint> <joint name="sonar_front_joint" type="fixed"> <parent>base_link</parent> <child>sonar_front_link</child> <pose>0 0 0 0 0 0</pose> </joint> <plugin name="diff_drive" filename="libgazebo_ros_diff_drive.so"> <update_rate>30</update_rate> <left_joint>wheel_left_joint</left_joint> <right_joint>wheel_right_joint</right_joint> <wheel_separation>0.32514</wheel_separation> <wheel_diameter>0.115</wheel_diameter> <max_wheel_torque>20</max_wheel_torque> <max_wheel_acceleration>1.0</max_wheel_acceleration> <command_topic>cmd_vel</command_topic> <publish_odom>true</publish_odom> <publish_odom_tf>true</publish_odom_tf> <publish_wheel_tf>false</publish_wheel_tf> <odometry_topic>odom</odometry_topic> <odometry_frame>odom</odometry_frame> <robot_base_frame>base_footprint</robot_base_frame> <odometry_source>1</odometry_source> <ros> <!-- <remapping>odom:=wheel/odometry</remapping> --> <!-- <remapping>odom:=whe</remapping> --> </ros> </plugin> <plugin name="joint_state" filename="libgazebo_ros_joint_state_publisher.so"> <ros> <remapping>~/out:=joint_states</remapping> </ros> <update_rate>30</update_rate> <joint_name>wheel_left_joint</joint_name> <joint_name>wheel_right_joint</joint_name> </plugin> </model> </sdf>
文章说明 本教程主要介绍如何加载ailibot2的URDF模型到gazebo 测试环境：Ubuntu 20.04 + Gazebo11 + ROS2 Galactic 操作步骤 $ ros2 launch ailibot2_bringup robot_sim_with_ekf.launch.py [INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2023-09-07-18-36-21-627170-ailibotOS-VM-28302 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [gzserver-1]: process started with pid [28306] [INFO] [gzclient -2]: process started with pid [28308] [INFO] [spawn_entity.py-3]: process started with pid [28311] [INFO] [robot_state_publisher-4]: process started with pid [28314] [INFO] [ekf_node-5]: process started with pid [28316] [robot_state_publisher-4] Link base_link had 6 children [robot_state_publisher-4] Link caster_back_link had 0 children [robot_state_publisher-4] Link caster_front_link had 0 children [robot_state_publisher-4] Link imu_link had 0 children [robot_state_publisher-4] Link laser_link had 0 children [robot_state_publisher-4] Link wheel_left_link had 0 children [robot_state_publisher-4] Link wheel_right_link had 0 children [robot_state_publisher-4] [INFO] [1694082982.529842060] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-4] [INFO] [1694082982.529904860] [robot_state_publisher]: got segment base_link [robot_state_publisher-4] [INFO] [1694082982.529913754] [robot_state_publisher]: got segment caster_back_link [robot_state_publisher-4] [INFO] [1694082982.529919142] [robot_state_publisher]: got segment caster_front_link [robot_state_publisher-4] [INFO] [1694082982.529923927] [robot_state_publisher]: got segment imu_link [robot_state_publisher-4] [INFO] [1694082982.529928443] [robot_state_publisher]: got segment laser_link [robot_state_publisher-4] [INFO] [1694082982.529932945] [robot_state_publisher]: got segment wheel_left_link [robot_state_publisher-4] [INFO] [1694082982.529937518] [robot_state_publisher]: got segment wheel_right_link [spawn_entity.py-3] [INFO] [1694082982.860998491] [spawn_entity]: Spawn Entity started [spawn_entity.py-3] [INFO] [1694082982.861365252] [spawn_entity]: Loading entity published on topic robot_description [spawn_entity.py-3] [INFO] [1694082982.863082087] [spawn_entity]: Waiting for entity xml on robot_description [spawn_entity.py-3] [INFO] [1694082982.865577551] [spawn_entity]: Waiting for service /spawn_entity, timeout = 5 [spawn_entity.py-3] [INFO] [1694082982.865911081] [spawn_entity]: Waiting for service /spawn_entity [spawn_entity.py-3] [INFO] [1694082983.620555067] [spawn_entity]: Calling service /spawn_entity [spawn_entity.py-3] [INFO] [1694082983.683293283] [spawn_entity]: Spawn status: Entity pushed to spawn queue, but spawn service timed outwaiting for entity to appear in simulation under the name [ailibot2] [spawn_entity.py-3] [ERROR] [1694082983.683632180] [spawn_entity]: Spawn service failed. Exiting. [spawn_entity.py-3] /opt/ros/galactic/lib/python3.8/site-packages/rclpy/qos.py:307: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead. [spawn_entity.py-3] warnings.warn( [gzserver-1] [INFO] [1694082984.073103611] [ailibot_d2_controller]: Wheel pair 1 separation set to [0.325140m] [gzserver-1] [INFO] [1694082984.073816952] [ailibot_d2_controller]: Wheel pair 1 diameter set to [0.115000m] [gzserver-1] [INFO] [1694082984.075420133] [ailibot_d2_controller]: Subscribed to [/cmd_vel] [gzserver-1] [INFO] [1694082984.078038886] [ailibot_d2_controller]: Advertise odometry on [/wheel/odometry] [gzserver-1] [INFO] [1694082984.091534683] [bytes_joint_state]: Going to publish joint [wheel_left_joint] [gzserver-1] [INFO] [1694082984.091591341] [bytes_joint_state]: Going to publish joint [wheel_right_joint] [gzclient -2] context mismatch in svga_surface_destroy [gzclient -2] context mismatch in svga_surface_destroy 查看话题 $ ros2 topic list /clock /cmd_vel /diagnostics /imu/data /joint_states /odom /parameter_events /performance_metrics /robot_description /rosout /scan /set_pose /tf /tf_static /wheel/odometry 模型直接发布的里程话题为/wheel/odometry 通过robot_localization融合/wheel/odometry和imu的/scan数据后，获取新的里程数据/odom
文章说明 本教程主要介绍如何在gazebo仿真中使用键盘控制Ailibot2 操作步骤 启动gazebo仿真，加载Ailibot2模型 $ ros2 launch ailibot2_bringup robot_sim.launch.py [INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2023-09-07-12-05-31-122302-ailibotOS-VM-8978 [INFO] [launch]: Default logging verbosity is set to INFO GAZEBO_MODEL_PATH: /usr/share/gazebo-11/models::/home/ubuntu/ros2_ailibot2_sim_ws/install/ailibot2_description/share/ailibot2_description/meshes [INFO] [robot_state_publisher-1]: process started with pid [8981] [INFO] [gzserver-2]: process started with pid [8983] [INFO] [gzclient -3]: process started with pid [8985] [INFO] [spawn_entity.py-4]: process started with pid [8988] [robot_state_publisher-1] Link base_link had 8 children [robot_state_publisher-1] Link camera_bottom_screw_frame had 1 children [robot_state_publisher-1] Link camera_link had 1 children [robot_state_publisher-1] Link camera_depth_frame had 4 children [robot_state_publisher-1] Link camera_color_frame had 1 children [robot_state_publisher-1] Link camera_color_optical_frame had 0 children [robot_state_publisher-1] Link camera_depth_optical_frame had 0 children [robot_state_publisher-1] Link camera_left_ir_frame had 1 children [robot_state_publisher-1] Link camera_left_ir_optical_frame had 0 children [robot_state_publisher-1] Link camera_right_ir_frame had 1 children [robot_state_publisher-1] Link camera_right_ir_optical_frame had 0 children [robot_state_publisher-1] Link caster_back_link had 0 children [robot_state_publisher-1] Link caster_front_link had 0 children [robot_state_publisher-1] Link imu_link had 0 children [robot_state_publisher-1] Link laser_link had 0 children [robot_state_publisher-1] Link sonar_front_link had 0 children [robot_state_publisher-1] Link wheel_left_link had 0 children [robot_state_publisher-1] Link wheel_right_link had 0 children [robot_state_publisher-1] [INFO] [1694059532.660441133] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-1] [INFO] [1694059532.660568092] [robot_state_publisher]: got segment base_link [robot_state_publisher-1] [INFO] [1694059532.660581127] [robot_state_publisher]: got segment camera_bottom_screw_frame [robot_state_publisher-1] [INFO] [1694059532.660586826] [robot_state_publisher]: got segment camera_color_frame [robot_state_publisher-1] [INFO] [1694059532.660591711] [robot_state_publisher]: got segment camera_color_optical_frame [robot_state_publisher-1] [INFO] [1694059532.660610149] [robot_state_publisher]: got segment camera_depth_frame [robot_state_publisher-1] [INFO] [1694059532.660617151] [robot_state_publisher]: got segment camera_depth_optical_frame [robot_state_publisher-1] [INFO] [1694059532.660621725] [robot_state_publisher]: got segment camera_left_ir_frame [robot_state_publisher-1] [INFO] [1694059532.660626340] [robot_state_publisher]: got segment camera_left_ir_optical_frame [robot_state_publisher-1] [INFO] [1694059532.660630679] [robot_state_publisher]: got segment camera_link [robot_state_publisher-1] [INFO] [1694059532.660635211] [robot_state_publisher]: got segment camera_right_ir_frame [robot_state_publisher-1] [INFO] [1694059532.660639759] [robot_state_publisher]: got segment camera_right_ir_optical_frame [robot_state_publisher-1] [INFO] [1694059532.660644230] [robot_state_publisher]: got segment caster_back_link [robot_state_publisher-1] [INFO] [1694059532.660648655] [robot_state_publisher]: got segment caster_front_link [robot_state_publisher-1] [INFO] [1694059532.660652978] [robot_state_publisher]: got segment imu_link [robot_state_publisher-1] [INFO] [1694059532.660657278] [robot_state_publisher]: got segment laser_link [robot_state_publisher-1] [INFO] [1694059532.660661839] [robot_state_publisher]: got segment sonar_front_link [robot_state_publisher-1] [INFO] [1694059532.660666095] [robot_state_publisher]: got segment wheel_left_link [robot_state_publisher-1] [INFO] [1694059532.660670503] [robot_state_publisher]: got segment wheel_right_link [spawn_entity.py-4] [INFO] [1694059533.453061905] [spawn_entity]: Spawn Entity started [spawn_entity.py-4] [INFO] [1694059533.453582284] [spawn_entity]: Loading entity XML from file /home/ubuntu/ros2_ailibot2_sim_ws/install/ailibot2_gazebo/share/ailibot2_gazebo/models/ailibot2/d2/ailibot_d2.sdf [spawn_entity.py-4] [INFO] [1694059533.466719430] [spawn_entity]: Waiting for service /spawn_entity, timeout = 5 [spawn_entity.py-4] [INFO] [1694059533.467070718] [spawn_entity]: Waiting for service /spawn_entity [spawn_entity.py-4] [INFO] [1694059535.376824884] [spawn_entity]: Calling service /spawn_entity [spawn_entity.py-4] [INFO] [1694059536.590096599] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [ailibot2] [INFO] [spawn_entity.py-4]: process has finished cleanly [pid 8988] [gzserver-2] [INFO] [1694059537.684684673] [GazeboRealsenseNode]: Realsense Gazebo ROS plugin loading. [gzserver-2] [gzserver-2] RealSensePlugin: The realsense_camera plugin is attach to model ailibot2 [gzserver-2] [INFO] [1694059538.412087799] [GazeboRealsenseNode]: Loaded Realsense Gazebo ROS plugin. [gzserver-2] [INFO] [1694059538.537634923] [diff_drive]: Wheel pair 1 separation set to [0.325140m] [gzserver-2] [INFO] [1694059538.537767828] [diff_drive]: Wheel pair 1 diameter set to [0.115000m] [gzserver-2] [INFO] [1694059538.539091745] [diff_drive]: Subscribed to [/cmd_vel] [gzserver-2] [INFO] [1694059538.572421130] [diff_drive]: Advertise odometry on [/odom] [gzserver-2] [INFO] [1694059538.610411054] [diff_drive]: Publishing odom transforms between [odom] and [base_footprint] [gzserver-2] [INFO] [1694059538.678657658] [joint_state]: Going to publish joint [wheel_left_joint] [gzserver-2] [INFO] [1694059538.678744839] [joint_state]: Going to publish joint [wheel_right_joint] [gzclient -3] context mismatch in svga_surface_destroy [gzclient -3] context mismatch in svga_surface_destroy [gzclient -3] context mismatch in svga_surface_destroy [gzclient -3] context mismatch in svga_surface_destroy [INFO] [gzclient -3]: process has finished cleanly [pid 8985] ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT) [robot_state_publisher-1] [INFO] [1694059778.732434423] [rclcpp]: signal_handler(signal_value=2) [INFO] [robot_state_publisher-1]: process has finished cleanly [pid 8981] [ERROR] [gzserver-2]: process has died [pid 8983, exit code -2, cmd 'gzserver /home/ubuntu/ros2_ailibot2_sim_ws/install/ailibot2_gazebo/share/ailibot2_gazebo/worlds/basic.world -s libgazebo_ros_init.so -s libgazebo_ros_factory.so -s libgazebo_ros_force_system.so ']. ubuntu@ailibotOS-VM:~$ ros2 launch ailibot2_bringup robot_sim.launch.py [INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2023-09-07-12-09-42-542814-ailibotOS-VM-9628 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [gzserver-1]: process started with pid [9631] [INFO] [gzclient -2]: process started with pid [9634] [INFO] [spawn_entity.py-3]: process started with pid [9637] [INFO] [robot_state_publisher-4]: process started with pid [9639] [robot_state_publisher-4] Link base_link had 8 children [robot_state_publisher-4] Link camera_bottom_screw_frame had 1 children [robot_state_publisher-4] Link camera_link had 1 children [robot_state_publisher-4] Link camera_depth_frame had 4 children [robot_state_publisher-4] Link camera_color_frame had 1 children [robot_state_publisher-4] Link camera_color_optical_frame had 0 children [robot_state_publisher-4] Link camera_depth_optical_frame had 0 children [robot_state_publisher-4] Link camera_left_ir_frame had 1 children [robot_state_publisher-4] Link camera_left_ir_optical_frame had 0 children [robot_state_publisher-4] Link camera_right_ir_frame had 1 children [robot_state_publisher-4] Link camera_right_ir_optical_frame had 0 children [robot_state_publisher-4] Link caster_back_link had 0 children [robot_state_publisher-4] Link caster_front_link had 0 children [robot_state_publisher-4] Link imu_link had 0 children [robot_state_publisher-4] Link laser_link had 0 children [robot_state_publisher-4] Link sonar_front_link had 0 children [robot_state_publisher-4] Link wheel_left_link had 0 children [robot_state_publisher-4] Link wheel_right_link had 0 children [robot_state_publisher-4] [INFO] [1694059783.413443475] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-4] [INFO] [1694059783.413528422] [robot_state_publisher]: got segment base_link [robot_state_publisher-4] [INFO] [1694059783.413538178] [robot_state_publisher]: got segment camera_bottom_screw_frame [robot_state_publisher-4] [INFO] [1694059783.413544103] [robot_state_publisher]: got segment camera_color_frame [robot_state_publisher-4] [INFO] [1694059783.413549180] [robot_state_publisher]: got segment camera_color_optical_frame [robot_state_publisher-4] [INFO] [1694059783.413553963] [robot_state_publisher]: got segment camera_depth_frame [robot_state_publisher-4] [INFO] [1694059783.413558553] [robot_state_publisher]: got segment camera_depth_optical_frame [robot_state_publisher-4] [INFO] [1694059783.413563117] [robot_state_publisher]: got segment camera_left_ir_frame [robot_state_publisher-4] [INFO] [1694059783.413567778] [robot_state_publisher]: got segment camera_left_ir_optical_frame [robot_state_publisher-4] [INFO] [1694059783.413572524] [robot_state_publisher]: got segment camera_link [robot_state_publisher-4] [INFO] [1694059783.413577216] [robot_state_publisher]: got segment camera_right_ir_frame [robot_state_publisher-4] [INFO] [1694059783.413581850] [robot_state_publisher]: got segment camera_right_ir_optical_frame [robot_state_publisher-4] [INFO] [1694059783.413586420] [robot_state_publisher]: got segment caster_back_link [robot_state_publisher-4] [INFO] [1694059783.413591307] [robot_state_publisher]: got segment caster_front_link [robot_state_publisher-4] [INFO] [1694059783.413595920] [robot_state_publisher]: got segment imu_link [robot_state_publisher-4] [INFO] [1694059783.413600479] [robot_state_publisher]: got segment laser_link [robot_state_publisher-4] [INFO] [1694059783.413604985] [robot_state_publisher]: got segment sonar_front_link [robot_state_publisher-4] [INFO] [1694059783.413609597] [robot_state_publisher]: got segment wheel_left_link [robot_state_publisher-4] [INFO] [1694059783.413614277] [robot_state_publisher]: got segment wheel_right_link [spawn_entity.py-3] [INFO] [1694059783.752047129] [spawn_entity]: Spawn Entity started [spawn_entity.py-3] [INFO] [1694059783.752894242] [spawn_entity]: Loading entity published on topic robot_description [spawn_entity.py-3] [INFO] [1694059783.756851589] [spawn_entity]: Waiting for entity xml on robot_description [spawn_entity.py-3] [INFO] [1694059783.758992884] [spawn_entity]: Waiting for service /spawn_entity, timeout = 5 [spawn_entity.py-3] [INFO] [1694059783.759566372] [spawn_entity]: Waiting for service /spawn_entity [spawn_entity.py-3] [INFO] [1694059784.514260691] [spawn_entity]: Calling service /spawn_entity [spawn_entity.py-3] [INFO] [1694059784.566101753] [spawn_entity]: Spawn status: Entity pushed to spawn queue, but spawn service timed outwaiting for entity to appear in simulation under the name [ailibot2] [spawn_entity.py-3] [ERROR] [1694059784.566456776] [spawn_entity]: Spawn service failed. Exiting. [spawn_entity.py-3] /opt/ros/galactic/lib/python3.8/site-packages/rclpy/qos.py:307: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead. [spawn_entity.py-3] warnings.warn( [ERROR] [spawn_entity.py-3]: process has died [pid 9637, exit code 1, cmd '/opt/ros/galactic/lib/gazebo_ros/spawn_entity.py -entity ailibot2 -topic robot_description -x 0.0 -y 0.0 -z 0.0 -Y 0.0 --ros-args']. [gzserver-1] [INFO] [1694059785.941366963] [ailibot_d2_controller]: Wheel pair 1 separation set to [0.325140m] [gzserver-1] [INFO] [1694059785.942681646] [ailibot_d2_controller]: Wheel pair 1 diameter set to [0.115000m] [gzserver-1] [INFO] [1694059785.944114157] [ailibot_d2_controller]: Subscribed to [/cmd_vel] [gzserver-1] [INFO] [1694059785.945960256] [ailibot_d2_controller]: Advertise odometry on [/odom] [gzserver-1] [INFO] [1694059785.949307520] [ailibot_d2_controller]: Publishing odom transforms between [odom] and [base_footprint] [gzserver-1] [INFO] [1694059785.964256454] [bytes_joint_state]: Going to publish joint [wheel_left_joint] [gzserver-1] [INFO] [1694059785.965869886] [bytes_joint_state]: Going to publish joint [wheel_right_joint] [gzserver-1] [INFO] [1694059786.000841706] [GazeboRealsenseNode]: Realsense Gazebo ROS plugin loading. [gzserver-1] [gzserver-1] RealSensePlugin: The realsense_camera plugin is attach to model ailibot2 [gzserver-1] [INFO] [1694059786.058554975] [GazeboRealsenseNode]: Loaded Realsense Gazebo ROS plugin. [gzclient -2] context mismatch in svga_surface_destroy [gzclient -2] context mismatch in svga_surface_destroy 启动键盘控制节点 $ ros2 launch ailibot2_teleop keyboard.launch.py This node takes keypresses from the keyboard and publishes them as Twist messages. It works best with a US keyboard layout. --------------------------- Moving around: u i o j k l m , . For Holonomic mode (strafing), hold down the shift key: --------------------------- U I O J K L M < > t : up (+z) b : down (-z) anything else : stop q/z : increase/decrease max speeds by 10% w/x : increase/decrease only linear speed by 10% e/c : increase/decrease only angular speed by 10% CTRL-C to quit currently: speed 0.5 turn 1.0 按下对应的按键，机器人就会进行对应的移动操作 i 为前进，j 为原地左转，k 为停止，l 为原地右转， , 为后退 效果图如下：
文章说明 本教程主要介绍Ailibot2在gazebo仿真中进行gmapping算法建图的操作流程 如果没有安装gmapping，则通过下面方式安装 rcm ros2_algorithm install_ros2_gmapping_source 操作步骤 启动gazebo仿真，加载Ailibot2模型 $ ros2 launch ailibot2_bringup robot_sim.launch.py 启动gmapping算法建图节点 $ ros2 launch ailibot2_slam gmapping.launch.py use_rviz:=true 启动键盘控制节点，移动建图 $ ros2 launch ailibot2_teleop keyboard.launch.py 保存地图 # 根目录下新建一个map文件夹，如果根目录下有map文件夹，请忽略该步骤 $ mkdir ~/map # 启动保存地图节点 $ ros2 run nav2_map_server map_saver_cli -f ~/map/map --ros-args -p save_map_timeout:=10000.00 查看保存好的地图 $ eog ~/map/map.pgm 演示视频
文章说明 本教程主要介绍Ailibot2在gazebo仿真中进行slam_toolbox算法建图的操作流程 操作步骤 启动gazebo仿真，加载Ailibot2模型 $ ros2 launch ailibot2_bringup robot_sim.launch.py 启动slam_toolbox算法建图节点 $ ros2 launch ailibot2_slam slam_toolbox.launch.py use_rviz:=true 启动键盘控制节点，移动建图 $ ros2 launch ailibot2_teleop keyboard.launch.py 保存地图 # 根目录下新建一个map文件夹，如果根目录下有map文件夹，请忽略该步骤 $ mkdir ~/map # 启动保存地图节点 $ ros2 run nav2_map_server map_saver_cli -f ~/map/map --ros-args -p save_map_timeout:=10000.00 查看保存好的地图 $ eog ~/map/map.pgm 演示视频