Making my own autonomous Robot in Ros/gazebo

Source: Internet
Author: User

Day 1:setting up
    • Ros:indigo
    • Os:ubuntu 14.04
    • Os:gazebo 7.0.0
Initialize the workspace

To create the basic skeleton of the directory structure, we begin with a workspace {workspace}_ws, where we set the C2>{workspace}=mybot.

CD ~mkdir-p MYBOT_WS/SRCCD MYBOT_WS/SRCCATKIN_INIT_WORKSPACECD. Catkin_makeecho "Source ~/mybot_ws/devel/setup.bash" >> ~/.BASHRC # Adds workspace to search path

In the SRC folder is three main packages, {Model}_control, {model}_description, {model}_gazebo . We set {MODEL} = Mybot. To create a package:catkin_create_pkg {pkg_name} {pkg_dependencies}. In this case, we have no {pkg_dependencies} = "".

CD ~/mybot_ws/src/catkin_create_pkg mybot_controlcatkin_create_pkg mybot_descriptioncatkin_create_pkg Mybot_gazebo
Creating your own World

Let's start with the Gazebo package, go in there and create the following subfolders:

ROSCD Mybot_gazebo mkdir Launch Worlds

At first we want to create a world for our gazebo server. Therefore we switch to our worlds directory and create a new World file.

CD Worldsgedit Mybot.world

A basic world file defines at least a name:

<?xml version= "1.0"? ><sdf version= "1.4" ><world name= "MyWorld" ></world></sdf>

Here are could directly add models and object with their position. Also The laws of physics may is defined in a world. A important step to understand, because in the this file you could also attach a specific plugin to an object. The plugin itself contains ROS and Gazebo specific code for more complex behaviors.

At first we just want to add some basic objects, like a ground and a basic illumination source inside the world tag.

<include><uri>model://sun</uri></include><include><uri>model://ground_ Plane</uri></include>

Check your "~/.gazebo/models" directory, as this was a default path for saved models. If This path does not exist a try to find /usr/share/gazebo/setup.sh where gazebo looks for models. Otherwise add it to your model path.

As the ground plane and the sun is basic models that is also on the gazebo server they would be downloaded on startup if They cannot be found locally. If you want to know which object is available on the Gazebo server, take a look at Gazebo model database. To start the Gazebo server there is several methods. As it is a good practice to use a launch file, we'll create one now. This could later also is used for multiple nodes.

Change to the launch directory of your project:

ROSCD Mybot_gazebo/launch

Create a new file:

Gedit Mybot_world.launch

and insert:

<launch>  <include file= "$ (find Gazebo_ros)/launch/empty_world.launch" >    <arg name= "World_ Name "Value=" $ (find Mybot_gazebo)/worlds/mybot.world "/>    <arg name=" GUI "value=" true "/>  </ Include></launch>

This launch file would just execute a default launch file provided by Gazebo, and the IT to load we world file and show T He Gazebo client. You can launch it by doing:

Roslaunch Mybot_gazebo Mybot_world.launch

Now your should see the Gazebo server and the GUI starting with a world This contains a ground plane and a sun (which is no t obviously visible without objects). If not, the it can is that there is some connections problems with the server.

If That's happens, start gazebo without the launch file, go to the models, you should find the one you want in the server. Click on them, they'll is put in the cache. Now, if you close gazebo and start it again with the launch file, it should work.

If you would press ' save world as ' in ' File ' in your gazebo client and save the ' world in a ' text File, you could investigat E The full world description.

If you want to watch a more complex and beautiful world environment then add the following inside your World tag:

  <include><uri>model://willowgarage</uri></include>

This one shows your office of Willow Garage, be careful, it's huge and may make your simulation extremely slow.

Create the Robot Model (URDF)

In ~/MYBOT_WS/SRC/MYBOT_DESCRIPTION/URDF, there is four files:

    • mybot.xacro: Primary file, loads the other three files and contains only URDF items like joints and links
    • Mybot.gazebo: Contains gazebo-specific labels that is wrapped within Gaz
    • Materials.xacro: Maps strings to Colors
    • Macros.xacro: macros to help simplify
Run the Models

Load the Gazebo simulator and Rviz in separate terminals

Roslaunch Mybot_gazebo mybot_world.launchroslaunch mybot_description mybot_rviz.launch

Send a base controller command and ensure that the robot moves in both Gazebo and Rviz

Rostopic pub/cmd_vel geometry_msgs/twist "linear:  x:0.2  y:0.0  z:0.0angular:  x:0.0  y:0.0 z:0.1 "

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

Reference:

[Tutorial] Getting starting with autonomous Robots in ROS via simulations

Making my own autonomous Robot in Ros/gazebo

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.