6.1 安装模拟器
$ sudo apt-get install ros-indigo-arbotix-*
$ rospack profile # 更新
6.2 测试模拟器
- 首先要保证 roscore 已经在运行.然后用如下命令测试
$ roslaunch rbx1_bringup fake_turtlebot.launch
或者用一个 Pi Robot 测试
roslaunch rbx1_bringup fake_pi_robot.launch
- 用 RViz 来可视化的查看机器人的运动
rosrun rviz rviz -d `rospack find rbx1_nav`/sim.rviz
- 为了测试模拟,在另一个命令行下运行如下代码,应该会导致模拟机器人转圈圈
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}}'
用
Ctrl-C
来停止,然后发布空Twist
消息:rostopic pub -1 /cmd_vel geometry_msgs/Twist '{}'
6.3 Running the Simulator with Your Own Robot
If you have a URDF
model of your own robot, you can run it in the ArbotiX simulator
instead of the TurtleBot or Pi Robot. First, make a copy of the fake TurtleBot launch
file:
roscd rbx1_bringup/launch
cp fake_turtlebot.launch fake_my_robot.launch
Then bring up your launch file in your favorite editor. At first it will look like this:
<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
rbx1_description)/urdf/turtlebot.urdf.xacro'" />
<param name="robot_description" command="$(arg urdf_file)" />
<node name="arbotix" pkg="arbotix_python" type="arbotix_driver"
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>
</launch>
As you can see, the URDF
model is loaded near the top of the file. Simply replace the
package and path names to point to your own URDF/Xacro
file. You can leave most of
the rest of the launch file the same. The result would look something like this:
<launch>
<!-- Load the URDF/Xacro model of our robot -->
<arg name="urdf_file" default="$(find xacro)/xacro.py '$(find
YOUR_PACKAGE_NAME)/YOUR_URDF_PATH'" />
<param name="robot_description" command="$(arg urdf_file)" />
<node name="arbotix" pkg="arbotix_python" type="arbotix_driver"
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>
</launch>
If your robot has an arm or a pan-and-tilt head, you can start with the
fake_pi_robot.launch
file as a template.