Gazebo的是ROS使用的一个重要的仿真工具,环境配置与“机器人操作系统ROS笔记–从仿真开始”相同,只是采用Gazebo而不是Arbotix(Rviz)做仿真;如果需要模拟物理现象和传感器反馈,需要使用Gazebo。
roslaunch mybot_gazebo mybot_world.launch
roslaunch mybot_description mybot_rviz.launch
分别打开Gazebo和Rviz,
仿真窗口出现小车
执行以下命令:
rostopic pub /cmd_vel geometry_msgs/Twist “linear:
x: 0.2
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.1”
可以观察到机器人在Gazebo和Rviz窗口中同时运动。
Simulating a robot’s controllers in Gazebo can be accomplished using ros_control and a simple Gazebo plugin adapter. An overview of the relationship between simulation, hardware, controllers and transmissions is shown below:
机器人在实际环境中运行至少需要以下模块:
- sensors to reveal the surrounding environment
- planning to figure out what to do
- actuators that make the robot move
仿真摄像头
在myrobot包的基础上增加两个模块:
- mybot_description/urdf/mybot.xacro - Add the camera model
- mybot_description/urdf/mybot.gazebo - Add the camera plugin
> roslaunch mybot_gazebo mybot_world.launch
> rosrun image_view image_view image:=/mybot/camera1/image_raw
> roslaunch mybot_description mybot_rviz.launch
仿真激光器
增加两个模块:
1. mybot_description/urdf/mybot.xacro - Add the laser model
2. mybot_description/urdf/mybot.gazebo - Add the laser plugin
3. mybot_description/meshes/hokuyo.dae (optional) - Fancy hokuyo laser model
在 Gazebo 和 rviz 中仿真实验。