(i) New robot model in ROS (URDF format) and Rviz display _ros

Source: Internet
Author: User

In the robotic operating system (ROS), often need to simulate the movement of robots, then first need to create a new robot.
The steps to create a simple robot model are as follows:
(1) Create a hardware description package
(2) Establishment of URDF documents
(3) Establish launch command file
(4) Effect Demo

Detailed steps are as follows:
(1) Create a hardware description package in the workspace, using the following command

Roscreate-pkg  smartcar_description  URDF  

(2) The description file for the new model is SMARTCAR.URDF,URDF called (Unified Robot Description Format), which is a description of the robot, and the following code indicates that the SmartCar has a fuselage and four wheels.
This Code reference http://blog.csdn.net/hcx25909/article/details/8904292

<?xml version= "1.0"?> <robot name= "SmartCar" > <link name= "Base_link" > <visual> <geo 
    metry> <box size= "0.25"/> </geometry> <origin rpy= "0 0 1.57075" xyz= "0 0 0"/> <material name= "Blue" > <color rgba= "0 0.8 1"/> </material> </visual> </l ink> <link name= "Right_front_wheel" > <visual> <geometry> <cylinder length= ". 02
      "radius=" 0.025 "/> </geometry> <material name=" Black "> <color rgba=" 0 0 0 1 "/> </material> </visual> </link> <joint name= "Right_front_wheel_joint" type= "continuous"
    ; <axis xyz= "0 0 1/> <parent link=" Base_link "/> <child link=" Right_front_wheel "/> <origin rpy= "0 1.57075 0" xyz= "0.08 0.1-0.03"/> <limit effort= "M" velocity= "/> <joint_properties" g= "0.0" friction= "0.0 "/> </joint> <link name=" Right_back_wheel "> <visual> <geometry> <c Ylinder length= "." radius= "0.025"/> </geometry> <material name= "BLACK" > <color RGB A= "0 0 0 1"/> </material> </visual> </link> <joint name= "Right_back_wheel_joint" Ty pe= "continuous" > <axis xyz= "0 0 1"/> <parent link= "Base_link"/> <child link= "Right_back_whee" L "/> <origin rpy=" 0 1.57075 0 "xyz=" 0.08-0.1-0.03 "/> <limit effort=" "velocity=" "/>" ; joint_properties damping= "0.0" friction= "0.0"/> </joint> <link name= "Left_front_wheel" > <visual&
      Gt <geometry> <cylinder length= "radius=" 0.025 "/> </geometry> <material name=" bl Ack "> <color rgba=" 0 0 0 1 "/> </material> </visual> </link> <joint na Me= "Left_front_wheel_joint "type=" continuous "> <axis xyz=" 0 0 1 "/> <parent link=" Base_link "/> <child, link= "Left_front_wheel"/> <origin rpy= "0 1.57075 0" xyz= " -0.08 0.1-0.03"/> <limit effort= "velocity=" 1 "/> <joint_properties damping=" 0.0 "friction=" 0.0 "/> </joint> <link name=" Left_back_wheel "
    ;
      <visual> <geometry> <cylinder length= "." radius= "0.025"/> </geometry> <material name= "Black" > <color rgba= "0 0 0 1"/> </material> </visual> </lin k> <joint name= "Left_back_wheel_joint" type= "continuous" > <axis xyz= "0 0 1"/> <parent link= "b
    Ase_link "/> <child link=" Left_back_wheel "/> <origin rpy=" 0 1.57075 0 "xyz=" -0.08-0.1-0.03 "/>

  <limit effort= "velocity="/> <joint_properties damping= "0.0" friction= "0.0"/> </joint> <link name= "HeaD "> <visual> <geometry> <box size=",/> </geometry> ; material name= "white" > <color rgba= "1 1 1 1"/> </material> </visual> </link > <joint name= "tobox" type= "fixed" > <parent link= "base_link"/> <child link= "Head"/> T;origin xyz= "0 0.08 0.025"/> </joint> </robot>

(3) Establish launch command file
The. Launch file works by starting multiple nodes at the same time, using the Roslaunch command to run the node specified in the. launch file.
To establish the launch command file step below, set up the launch folder under the Smartcar_description folder, create the description file of the Smart car Base.urdf.rviz.launch, the Ros version of this article is hydro, Therefore, you need to change the Base.urdf.rviz.launch file in the blog http://blog.csdn.net/hcx25909/article/details/8904292 as follows, only the last line has changed, the change is the parameter item args.

<launch>
    <arg name= "model"/>
    <arg name= "GUI" default= "False" "/> <param name=
    " robot _description "textfile=" $ (find smartcar_description)/urdf/smartcar.urdf "/> <param name="
    Use_gui "value=" $ (arg gui) "/>
    <node name=" Joint_state_publisher "pkg=" Joint_state_publisher "type=" Joint_state_publisher "></node>
    <node name=" Robot_state_publisher "pkg=" Robot_state_publisher "type=" State_publisher " >
    <node name= "Rviz" pkg= "Rviz" type= "Rviz" args= "-D $ (Find urdf_tutorial)/urdf.rviz"/> </launch
>

Analysis of the above code can be seen, there are 3 tags, indicating the activation of the 3 nodes in Ros. In fact, if you enter the command at the command line 3 times to enter the start node and use Roslaunch is also the same effect.

(4) Display the trolley in the Rviz

Roslaunch  smartcar_description  base.urdf.rviz.launch  gui:=true

The syntax for Roslaunch is
usage:roslaunch [Options] [package] [arg_name:=value ...]
Roslaunch package name FileName Parameter name: = value

Note If you run Roscore, you will still be prompted with the following error

Obviously the hint is not found this package, does not conform to roslaunch syntax, the solution is to add this package to the environment variable Ros_package_path.
1 Enter PWD to print the current project path, for example, the path to the current project is as follows
/root/dev/workspace/cartest/smartcar_description
2) using the command

Export Ros_package_path= $ROS _package_path:/root/dev/workspace/cartest/smartcar_description

Adds the path of the package to the ROS package path.
3) Use
Echo $ROS _package_path
View whether the path of the package is in the global variable Ros_package_path. If successful, the Roslaunch smartcar_description base.urdf.rviz.launch gui:=true can show the car again.

So why do you have to add the path of the package to the Ros_package_path.
My understanding is that because Ros creates a network that connects to all processes at the level of ROS calculation. You don't tell Ros who you are. How Ros connects and manages the package.

To extend, if the example on the Internet under the same error prompts, you can use the same method to solve.
The final effect of the operation is as shown

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.