Ailibot2仿真入门教程-控制-键盘控制
文章说明
- 本教程主要介绍如何在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
为原地右转,,
为后退效果图如下:
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号