ROS exploration Summary (IV)-simple Robot Simulation

Source: Internet
Author: User

We have already introduced the basic information about ROS and the basic tutorial for getting started with ROS. Now we have to use ROS to enter the robot world. Many of the routines involved in the next step are the content of the book ROS by Example. I bought them from Amazon outside China with a few people in the group, which is of great reference value, the premise is that you are familiar with the previous tutorials.

I. ROS by Example
This book is the first book about ROS published abroad. It mainly targets Electric and Fuerte versions and uses robots mainly TurtleBot. The book details the robot's basic simulation, navigation, path planning, image processing, speech recognition, and so on. It also released all the code on google's svn, you can use the following command to download and compile:
Svn checkout http://ros-by-example.googlecode.com/svn/trunk/rbx_vol_1rosmake rbx_vol_1rospack profile // Add ROS package path
Ii. rviz simple robot simulation 1. Installing the robot simulator rviz is a tool used to display robot entities. It does not have simulated functions and requires installing a simulator arbotix.
svn checkout http://vanadium-ros-pkg.googlecode.com/svn/trunk/arbotixrosmake arbotix

2. The simulation of the TurtleBot has already written the simulation code for us in the rbx_vol_1 package in the book. We will first conduct an experiment and then study the code carefully.
Robot Simulation:

roscoreroslaunch rbx1_bringup fake_pi_robot.launch

Then you can see in the terminal that the robot has started running. Open the rviz interface to see the robot entity.

rosrun rviz rviz -d `rospack find rbx1_nav`/sim_fuerte.vcg

The following parameter loads the configuration file sim_fuerte.vcg of rviz. The effect is as follows:

At this time, the robot is static, and a message needs to be published to make it dynamic.

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}}'


To stop the robot, press Ctrl + c in the interrupt and enter:
rostopic pub -1 /cmd_vel geometry_msgs/Twist '{}'

You can also change the sent topic information so that the robot can go through different tracks.
Iii. Implementation analysis according to the above simulation process, we analyze the code implementation in each step in detail. 1. The TurtleBot runs the launch file. First, open the fake_turtlebot.launch file.

<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>

The file can be divided into four parts:
(1) load the urdf file from the specified package
(2) Start the arbotix Simulator
(3) launch a node
(4) tf Coordinate System Configuration
2. When opening rviz, The rviz configuration file needs to load a. vcg configuration file, which mainly configures the plug-in options in rviz by default. The sim_fuerte.vcg file is opened here. Because the file is long, only the key parts are listed here.

Background\ ColorB=0.12549Background\ ColorG=0.12549Background\ ColorR=0.12549Camera\ Config=158.108 0.814789 0.619682 -1.57034Camera\ Type=rviz::FixedOrientationOrthoViewControllerFixed\ Frame=/odomGrid.Alpha=0.5Grid.Cell\ Size=0.5Grid.ColorB=0.941176Grid.ColorG=0.941176Grid.ColorR=0.941176Grid.Enabled=1Grid.Line\ Style=0Grid.Line\ Width=0.03Grid.Normal\ Cell\ Count=0Grid.OffsetX=0Grid.OffsetY=0Grid.OffsetZ=0Grid.Plane=0

The above code configures the background color and grid attributes, corresponding to the options in rviz, as shown in.

One of the most important options is the Camera type, which controls the developer's viewing angle. The book uses the FixedOrientationOrthoViewController method, that is, the view angle in the figure above, you cannot see the 3D panorama of the robot, so you can change it to OrbitViewController, as shown in:

3. To publish a topic to make the robot move, you also need to provide him with the information required by the motion. The information is published through the topic.
The topic here is the speed command. For this topic, we need to publish the speed information. In ROS, we have prepared some available data structures for us, the data structure of Twist information is used here. On the terminal, we can see that the Twist structure is as follows:
Use the following command to publish messages, including the force size and direction.

Background\ ColorB=0.12549Background\ ColorG=0.12549Background\ ColorR=0.12549Camera\ Config=158.108 0.814789 0.619682 -1.57034Camera\ Type=rviz::FixedOrientationOrthoViewControllerFixed\ Frame=/odomGrid.Alpha=0.5Grid.Cell\ Size=0.5Grid.ColorB=0.941176Grid.ColorG=0.941176Grid.ColorR=0.941176Grid.Enabled=1Grid.Line\ Style=0Grid.Line\ Width=0.03Grid.Normal\ Cell\ Count=0Grid.OffsetX=0Grid.OffsetY=0Grid.OffsetZ=0Grid.Plane=0

4. node Relationship Diagram

----------------------------------------------------------------

You are welcome to repost my article.

Reprinted, please note: transferred from ancient-month

Http://blog.csdn.net/hcx25909

Continue to follow my blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.