1. 运行master节点
roscore
2. 打开 ROS-Academy-for-Beginners 的模拟场景
输入命令
roslaunch robot_sim_demo robot_spawn_launch
我们看到仿真的模拟环境。该launch 文件启动了模拟场景、机器人。
3. 查看当前模拟器中存在的topic
输入命令:
rostopic list
可以看到许多topic,它们可以视为模拟器与外界交互的接口。结果如下
$ rostopic list
/camera/depth/camera_info
/camera/depth/image_raw
/camera/depth/points
/camera/parameter_descriptions
/camera/parameter_updates
/camera/rgb/camera_info
/camera/rgb/image_raw
/camera/rgb/image_raw/compressed
/camera/rgb/image_raw/compressed/parameter_descriptions
/camera/rgb/image_raw/compressed/parameter_updates
/camera/rgb/image_raw/compressedDepth
/camera/rgb/image_raw/compressedDepth/parameter_descriptions
/camera/rgb/image_raw/compressedDepth/parameter_updates
/camera/rgb/image_raw/theora
/camera/rgb/image_raw/theora/parameter_descriptions
/camera/rgb/image_raw/theora/parameter_updates
/clock
/cmd_vel
/cmd_vel_mux/active
/cmd_vel_mux/input/avoid
/cmd_vel_mux/input/navi
/cmd_vel_mux/input/safety_controller
/cmd_vel_mux/input/switch
/cmd_vel_mux/input/teleop
/cmd_vel_mux/parameter_descriptions
/cmd_vel_mux/parameter_updates
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/set_link_state
/gazebo/set_model_state
/gazebo_gui/parameter_descriptions
/gazebo_gui/parameter_updates
/imu
/joint_states
/mobile_base_nodelet_manager/bond
/odom
/rosout
/rosout_agg
/scan
/tf
/tf_static
/xbot/joint_states
/xbot/pitch_platform_position_controller/command
/xbot/pitch_platform_position_controller/pid/parameter_descriptions
/xbot/pitch_platform_position_controller/pid/parameter_updates
/xbot/pitch_platform_position_controller/state
/xbot/yaw_platform_position_controller/command
/xbot/yaw_platform_position_controller/pid/parameter_descriptions
/xbot/yaw_platform_position_controller/pid/parameter_updates
/xbot/yaw_platform_position_controller/state
4. 查询topic /camera/rgb/image_raw 的相关信息
$ rostopic info /camera/rgb/image_raw
Type: sensor_msgs/Image
Publishers:
* /gazebo (http://gangma:38359/)
Subscribers: None
则会显示类型信息type,发布者和订阅者的信息。
5. 控制机器人运动
打开新窗口运行命令:
rosrun robot_sim_demo robot_keyboard_teleop.py
通过上面的快捷键可以实现控制机器人的运动。
6. 打开RGB摄像头捕获窗口
在新的terminal中输入命令:
rosrun image_view image_view image:=/camera/rgb/image_raw
7. 打开depth捕获窗口
在新的terminal中输入命令:
rosrun image_view image_view image:/camera/depth/image_raw