借助ROS的工具箱让turtlebot在gazebo中运行起来.
roslaunch turtlebot_gazebo turtlebot_world.launch
默认加载了一个playground 的world文件.
roslaunch turtlebot_teleop keyboard_teleop.launch --screen
Moving around:
u i o
j k l
m , .
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%
space key, k : force stop
anything else : stop smoothly
可以通过以上方式控制机器人的运动了.
roslaunch turtlebot_rviz_launchers view_robot.launch --screen
在rviz的现实中,为了便于显示我只添加了camera rgb图像 (topic: /camera/rgb/image_raw)和 PointCloud2 (topic:/camera/depth/points). 同样也可以在左边的列表中添加laserscan (topic: /scan), DepthCloud (topic:/camera/depth/image_raw)等等.
关于Kinect2 (RGBD) 如何转换成laserscan, 以及点云转换都会在接下来的部分有所介绍.
roscd turtlebot_gazebo
进入
/opt/ros/indigo/share/turtlebot_gazebo
├── cmake
│ ├── turtlebot_gazeboConfig.cmake
│ └── turtlebot_gazeboConfig-version.cmake
├── launch
│ ├── amcl_demo.launch
│ ├── gmapping_demo.launch
│ ├── includes
│ │ ├── create.launch.xml
│ │ ├── kobuki.launch.xml
│ │ └── roomba.launch.xml
│ └── turtlebot_world.launch
├── maps
│ ├── playground.pgm
│ └── playground.yaml
├── package.xml
└── worlds
├── corridor.world
├── empty.world
└── playground.world
可以找到我们加载的playground.world的文件.
在* turtlebot_world.launch*文件中, 通过加载gazebo_ros包中的empty.launch启动Gazebo, 通过名为world_name 的参数可以修改仿真的Gazebo环境.
将
"world_name" value="$(arg world_file)"/>
替换为
"world_name" value="$(find turtlebot_gazebo)/worlds/corridor.world"/>
可将Gazebo仿真环境替换为corridor. 通过在Gazebo中编辑环境也可以很轻松的可以生成自己的world.
哈哈, 现在可以不同的Gazebo物理环境中实现仿真了, 满足感溢出.
接下来我们看看Kinect2 (RGBD) 如何转换成laserscan, 我们会在下面发现name = "depthimage_to_laserscan"
, 通过remap
from="image" to="/camera/depth/image_raw"/>
from="scan" to="/scan"/>
我们找到了在rviz中显示的topic了.
除了上述提到的控制方法外,也可以采用
roslaunch kobuki_keyop keyop.launch
查看keyboard_teleop.launch文件,
<launch>
<node pkg="turtlebot_teleop" type="turtlebot_teleop_key" name="turtlebot_teleop_keyboard" output="screen">
<param name="scale_linear" value="0.5" type="double"/>
<param name="scale_angular" value="1.5" type="double"/>
<remap from="turtlebot_teleop_keyboard/cmd_vel" to="cmd_vel_mux/input/teleop"/>
node>
launch>
可以发现速度命令的topic映射到了主题cmd_vel_mux/input/teleop
, 查看主题类型
rostopic type cmd_vel_mux/input/teleop
geometry_msgs/Twist
通过rostopic pub 命令
rostopic pub /cmd_vel_mux/input/teleop geometry_msgs/Twist "linear:
x: 0.1
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.1"
可以发送角速度0.1rad/s, 线速度0.1m/s, 可进一步查看 REP 103:Standard Units of Measure and Coordinate ConventionsREP 103:Standard Units of Measure and Coordinate Conventions .
rviz的显示可以很大程度的帮助ROS开发过程中的调试工作. 除了rviz外,还有一些其他的工具.
rosrun image_view image_view image:=/camera/rgb/image_raw
rosrun rqt_graph rqt_graph
rosrun rqt_reconfigure rqt_reconfigure
rqt