前边我们已经介绍了ROS的基本情况,以及新手入门ROS的初级教程,现在就要真正的使用ROS进入机器人世界了。接下来我们涉及到的很多例程都是《ROS by Example》这本书的内容,我是和群里的几个人一起从国外的亚马逊上买到的,还是很有参考价值的,不过前提是你已经熟悉之前的新手教程了。
一、ROS by Example
svn checkout http://ros-by-example.googlecode.com/svn/trunk/rbx_vol_1
rosmake rbx_vol_1
rospack profile //加入ROS package路径
二、rviz简单机器人模拟
1、安装机器人模拟器
svn checkout http://vanadium-ros-pkg.googlecode.com/svn/trunk/arbotix
rosmake arbotix
2、TurtleBot机器人的模拟
roscore
roslaunch rbx1_bringup fake_pi_robot.launch
rosrun rviz rviz -d `rospack find rbx1_nav`/sim_fuerte.vcg
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.2, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0.5}}'
rostopic pub -1 /cmd_vel geometry_msgs/Twist '{}'
三、实现分析
1、TurtleBot机器人运行
<launch>
<param name="/use_sim_time" value="false" />
<!-- Load the URDF/Xacro model of our robot -->
<arg name="urdf_file" default="$(find xacro)/xacro.py '$(find turtlebot_description)/urdf/turtlebot.urdf.xacro'" />
<param name="robot_description" command="$(arg urdf_file)" />
<node name="arbotix" pkg="arbotix_python" type="driver.py" output="screen">
<rosparam file="$(find rbx1_bringup)/config/fake_turtlebot_arbotix.yaml" command="load" />
<param name="sim" value="true"/>
</node>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher">
<param name="publish_frequency" type="double" value="20.0" />
</node>
<!-- We need a static transforms for the wheels -->
<node pkg="tf" type="static_transform_publisher" name="odom_left_wheel_broadcaster" args="0 0 0 0 0 0 /base_link /left_wheel_link 100" />
<node pkg="tf" type="static_transform_publisher" name="odom_right_wheel_broadcaster" args="0 0 0 0 0 0 /base_link /right_wheel_link 100" />
</launch>
2、rviz配置文件
Background\ ColorB=0.12549
Background\ ColorG=0.12549
Background\ ColorR=0.12549
Camera\ Config=158.108 0.814789 0.619682 -1.57034
Camera\ Type=rviz::FixedOrientationOrthoViewController
Fixed\ Frame=/odom
Grid.Alpha=0.5
Grid.Cell\ Size=0.5
Grid.ColorB=0.941176
Grid.ColorG=0.941176
Grid.ColorR=0.941176
Grid.Enabled=1
Grid.Line\ Style=0
Grid.Line\ Width=0.03
Grid.Normal\ Cell\ Count=0
Grid.OffsetX=0
Grid.OffsetY=0
Grid.OffsetZ=0
Grid.Plane=0
3、发布topic
[plain] view plain copy Background\ ColorB=0.12549
Background\ ColorG=0.12549
Background\ ColorR=0.12549
Camera\ Config=158.108 0.814789 0.619682 -1.57034
Camera\ Type=rviz::FixedOrientationOrthoViewController
Fixed\ Frame=/odom
Grid.Alpha=0.5
Grid.Cell\ Size=0.5
Grid.ColorB=0.941176
Grid.ColorG=0.941176
Grid.ColorR=0.941176
Grid.Enabled=1
Grid.Line\ Style=0
Grid.Line\ Width=0.03
Grid.Normal\ Cell\ Count=0
Grid.OffsetX=0
Grid.OffsetY=0
Grid.OffsetZ=0
Grid.Plane=0
评论(274)
您还未登录,请登录后发表或查看评论