[Gazebo in 5 minutes] 004 – How to create a gazebo model using SDF

[Gazebo in 5 minutes] 004 – How to create a gazebo model using SDF

What you will learn

  • Learn how to  create a gazebo model using the SDF Format

List of resources used in this post:

Preparing the environment

In order to load gazebo using ROS, you need to have Gazebo and ROS installed. If you don’t want to install everything, we highly recommend using ROSDS (ROS Development Studio) which gives you access to an online environment with ROS already installed. Indeed, we are going to use that tool for easiness. You can follow the same steps on your computer as well if you don’t want to use ROSDS.

To use ROSDS, you can just create an account and start using it.

Once you have your account created, you have to create a ROSject by clicking on the New ROSject button:

Creating a new ROSject in ROSDS

Creating a new ROSject in ROSDS

Once you have the ROSject, you can open it by clicking Open:

Opening a ROSject in ROSDS

Creating the ROS Package

In order to run anything using ROS, we need a ROS package, so, let’s create one. For that, you are going to need a terminal/shell. In ROSDS, you can have a terminal by clicking Tools -> Shell.

Let’s first create the workspace. In this case, let’s call it ~/simulation_ws

mkdir ~/simulation_ws/src -p

Now let’s then compile our empty workspace

source /opt/ros/kinetic/setup.bash 
source /usr/share/gazebo/setup.sh

cd ~/simulation_ws/

catkin_make

Now let’s create our ROS package. Let’s call it my_simulations:

source ~/simulation_ws/devel/setup.bash

cd ~/simulation_ws/src

catkin_create_pkg my_simulations

Now, let’s create a launch and a world folder inside the my_simulations package.

cd my_simulations

mkdir launch world

Now, inside the launch folder, let’s create a file named my_world.launch:

touch launch/my_world.launch

In that file, let’s put the following content:

<?xml version="1.0" encoding="UTF-8" ?>
<launch>
        <!-- overwriting these args -->
        <arg name="debug" default="false" />
        <arg name="gui" default="true" />
        <arg name="pause" default="false" />
        <arg name="world" default="$(find my_simulations)/world/empty_world.world" />

        <!-- include gazebo_ros launcher -->
        <include file="$(find gazebo_ros)/launch/empty_world.launch">
                <arg name="world_name" value="$(arg world)" />
                <arg name="debug" value="$(arg debug)" />
                <arg name="gui" value="$(arg gui)" />
                <arg name="paused" value="$(arg pause)" />
                <arg name="use_sim_time" value="true" />
        </include>
</launch>

In order to put the content on that file, you can do it using the code editor. For that, click on Tools -> IDE

"Tools

Now, let’s create a file named empty_world.world in the world folder:

touch world/empty_world.world

In that file, let’s add the following content:

<?xml version="1.0" ?>

<sdf version="1.5">
	<world name="default">
		<!-- A global light source -->
		<include>
			<uri>model://sun</uri>
		</include>

		<!-- A ground plane -->
		<include>
			<uri>model://ground_plane</uri>
		</include>
	</world>
</sdf>

 

If you followed the instructions correctly, you should have the following structure:

user:~/simulation_ws/src$ tree .
.
|-- CMakeLists.txt -> /opt/ros/kinetic/share/catkin/cmake/toplevel.cmake
`-- my_simulations
    |-- CMakeLists.txt
    |-- launch
    |   `-- my_world.launch
    |-- package.xml
    `-- world
        `-- empty_world.world

3 directories, 5 files

Creating our model

Let’s create a model named my1stmodel on the my_simulations package:

~/simulation_ws/src/my_simulations/
mkdir -p models/my1stmodel

Inside the my1stmodel folder, let’s create two files, one named model.config and another named model.sdf.

cd models/my1stmodel/
touch model.config model.sdf

These two files, model.config and model.sdf, are required for every gazebo model. You can find those files in the ground_plane model provided by gazebo, for example.

Let’s paste the following content on our my1stmodel/model.config

<?xml version="1.0"?>

<model>
  <name>My first model</name>
  <version>1.0</version>
  <sdf version="1.5">model.sdf</sdf>

  <author>
    <name>Your name</name>
    <email>your@email.com</email>
  </author>

  <description>
	My first model for gazebo
  </description>
</model>

And in our models/my1stmodel/model.sdf, let’s add the following:

<?xml version="1.0" ?>
<sdf version="1.5">
  <model name="my1stmodel">
    <static>false</static>
    <link name="link">
      <collision name="collision">
        <geometry>
          <box>
            <size>3 2 5</size>
          </gox>
        </geometry>
        <surface>
          <friction>
            <ode>
              <mu>100</mu>
              <mu2>50</mu2>
            </ode>
          </friction>
        </surface>
      </collision>
      <visual name="visual">
        <geometry>
          <box>
            <size>3 2 5</size>
          </gox>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Grey</name>
          </script>
        </material>
      </visual>
    </link>
  </model>
</sdf>

Launching our Gazebo model

Let’s modify our world/empty_world.world file created earlier to add the following:

<!-- A ground plane -->
<include>
 <uri>model://my1stmodel</uri>
</include>

In the end, the final content of the file would be:

<?xml version="1.0" ?>

<sdf version="1.5">
	<world name="default">
		<!-- A global light source -->
		<include>
			<uri>model://sun</uri>
		</include>

		<!-- A ground plane -->
		<include>
			<uri>model://ground_plane</uri>
		</include>

        <!-- Our custom model -->
		<include>
			<uri>model://my1stmodel</uri>
		</include>
        
	</world>
</sdf>

Now that we have everything in place, we can run our package in two ways:

Option one: Click Simulation -> Choose File, then select my_world.launch. This should automatically load the web version of gazebo, called gzweb.

Custom gazebo robot model running in ROSDS

Custom gazebo robot model running in ROSDS

Option two: If you are running the tests on your computer, or you want to manually run the simulation, you can just:

source ~/simulation_ws/devel/setup.bash
roslaunch my_simulations my_world.launch --screen

If you are in ROSDS and chose to run the simulation manually, then you have to manually open the Gazebo Web (gzweb) by clicking on Tools -> Gazebo.

Congratulations. You have successfully launched your first custom Gazebo World using ROS.

Youtube video

If you didn’t understand well all the steps explained here or need more understanding of the files we created, remember that we have the live version of this post on YouTube. Also, if you liked the content, please consider subscribing to our youtube channel. We are publishing new content ~every day.


 

[Gazebo in 5 minutes] 003 – How to spawn a robot in gazebo

[Gazebo in 5 minutes] 003 – How to spawn a robot in gazebo

What you will learn

  • Learn how to spawn a robot from its package in any gazebo simulation you may have running

List of resources used in this post:

Preparing the environment

In order to spawn a gazebo model in a simulation using ROS, you need to have Gazebo and ROS installed. If you don’t want to install everything, we highly recommend using ROSDS (ROS Development Studio) which gives you access to an online environment with ROS already installed. Indeed, we are going to use that tool for easiness. You can follow the same steps on your computer as well if you don’t want to use ROSDS.

To use ROSDS, you can just create an account and start using it.

Once you have your account created, you have to create a ROSject by clicking on the New ROSject button:

Creating a new ROSject in ROSDS

Once you have the ROSject, you can open it by clicking Open:

Spawning a two-wheeled robot in a gazebo simulation

When you open a ROSject, you are able to open web shell, code editor, etc.

Let’s start opening a web shell by clicking Tools -> Shell in ROSDS. Once you have the shell, let’s clone the repository that contains the robot:

cd ~/simulation_ws/src/

git clone https://bitbucket.org/theconstructcore/two-wheeled-robot-simulation

If you see, the repository we just cloned, you will find the file m2wr_description/launch/spawn.launch which contains the code used to spawn the robot. The code is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<launch>
    <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find m2wr_description)/urdf/m2wr.xacro'" />
    
    <arg name="x" default="0"/>
    <arg name="y" default="0"/>
    <arg name="z" default="0.5"/>
    
    <node name="mybot_spawn" pkg="gazebo_ros" type="spawn_model" output="screen"
          args="-urdf -param robot_description -model m2wr -x $(arg x) -y $(arg y) -z $(arg z)" />
          
</launch>

A quick look into this file shows that the file loaded in gazebo will be the m2wr_description/urdf/m2wr.xacro, in the positions xyz = 0, 0, 0.5.

Now, to actually spawn the robot, you can first load an empty world by clicking Simulations -> Empty World -> Start Simulation.

Starting an empty simulation in ROSDS

Starting an empty simulation in ROSDS

With the empty simulation running, we can now spawn our robot into the current simulation. For that, let’s first compile the workspace to make sure the package we cloned is ok:

cd ~/simulation_ws/
catkin_make
source devel/setup.bash
rospack profile

Now let’s spawn our robot:

roslaunch m2wr_description spawn.launch

If everything went as expected, you should have the two-wheeled robot in the simulation:

A two-whelled robot running in ROSDS

A two-whelled robot running in ROSDS

Congratulations!!! You just learned how to spawn a robot in a gazebo simulation.

Youtube video

If you didn’t understand well all the steps explained here or need more understanding of the files we created, remember that we have the live version of this post on YouTube. Also, if you liked the content, please consider subscribing to our youtube channel. We are publishing new content ~every day.

Keep pushing your ROS Learning.


Links & Resources mentioned in the video:

 

[Gazebo in 5 minutes] 002 – How to add gazebo models to a simulation

[Gazebo in 5 minutes] 002 – How to add gazebo models to a simulation

What you will learn

  • Learn how to add a gazebo model to a running gazebo simulation

List of resources used in this post:

  • Robot Ignite Academy, the place to learn to program robots using only a web browser
  • ROS Development Studio (the environment used in the video), another powerful online tool for pushing your ROS learning in a practical way
  • Gazebo models repository where you can find different models to be spawned

Including our model in the .world file

In this post, we are assuming you already have created a ROS package called my_simulations  and the following files: ~/simulation_ws/src/my_simulations/launch/my_world.launch and ~/simulation_ws/src/my_simulations/world/empty_world.world.

If you don’t have these files, please remember to first follow the previous post: https://www.theconstruct.ai/gazebo-5-mins-launch-first-gazebo-world-using-ros/

If you check the my_world.world file, from the previous post we have the following content:

<?xml version="1.0" ?>

<sdf version="1.5">
	<world name="default">
		<!-- A global light source -->
		<include>
			<uri>model://sun</uri>
		</include>

		<!-- A ground plane -->
		<include>
			<uri>model://ground_plane</uri>
		</include>
	</world>
</sdf>

Let’s add a postbox model. Remember that you can find many Gazebo moels on the Gazebo models repository.

The final content of ~/simulation_ws/src/my_simulations/world/empty_world.world after adding the postbox would be:

<?xml version="1.0" ?>

<sdf version="1.5">
	<world name="default">
		<!-- A global light source -->
		<include>
			<uri>model://sun</uri>
		</include>

		<!-- A ground plane -->
		<include>
			<uri>model://ground_plane</uri>
		</include>

                <!-- A post box plane -->
		<include>
			<uri>model://postbox</uri>
		</include>        

	</world>
</sdf>

This adds a model called postbox in the initial position (x=0, y=0, z=0). If you want it in a different position, you can add a <pose> like in the example below:

<include>
  <uri>model://postbox</uri>
  <pose>2 1 0 0 0 0</pose>
</include>

 

Adding the gazebo model to the simulation

Now that we have our empty_world.world file set, we can start our simulation in two ways:

Option one: Click Simulation -> Choose File, then select my_world.launch. This should automatically load the web version of gazebo, called gzweb.

Postbox gazebo simulation loaded in ROSDS

Postbox gazebo simulation loaded in ROSDS

 

Option two: If you are running the tests on your computer, or you want to manually run the simulation, you can just:

source ~/simulation_ws/devel/setup.bash
roslaunch my_simulations my_world.launch --screen

If you are in ROSDS and chose to run the simulation manually, then you have to manually open the Gazebo Web (gzweb) by clicking on Tools -> Gazebo.

 

Congratulations. You have successfully loaded a custom model in a Gazebo World using ROS.

Youtube video

If you didn’t understand well all the steps explained here or needs more understanding of the files we created, remember that we have the live version of this post on YouTube. Also, if you liked the content, please consider subscribing to our youtube channel. We are publishing new content ~every day.

Keep pushing your ROS Learning.


 

[Gazebo in 5 mins] – How To Launch Your First Gazebo World Using ROS

[Gazebo in 5 mins] – How To Launch Your First Gazebo World Using ROS

What you will learn

  • Learn how to launch an empty world in the gazebo simulator using ROS commands.

List of resources used in this post:

  • Robot Ignite Academy, the place to learn to program robots using only a web browser
  • ROS Development Studio (the environment used in the video), another powerful online tool for pushing your ROS learning in a practical way

Preparing the environment

In order to load gazebo using ROS, you need to have Gazebo and ROS installed. If you don’t want to install everything, we highly recommend using ROSDS (ROS Development Studio) which gives you access to an online environment with ROS already installed. Indeed, we are going to use that tool for easiness. You can follow the same steps on your computer as well if you don’t want to use ROSDS.

To use ROSDS, you can just create an account and start using it.

Once you have your account created, you have to create a ROSject by clicking on the New ROSject button:

Creating a new ROSject in ROSDS

Creating a new ROSject in ROSDS

Once you have the ROSject, you can open it by clicking Open:

Opening a ROSject in ROSDS

Creating the ROS Package

In order to run anything using ROS, we need a ROS package, so, let’s create one. For that, you are going to need a terminal/shell. In ROSDS, you can have a terminal by clicking Tools -> Shell.

Let’s first create the workspace. In this case, let’s call it ~/simulation_ws

mkdir ~/simulation_ws/src -p

Now let’s then compile our empty workspace

source /opt/ros/kinetic/setup.bash 
source /usr/share/gazebo/setup.sh

cd ~/simulation_ws/

catkin_make

Now let’s create our ROS package. Let’s call it my_simulations:

source ~/simulation_ws/devel/setup.bash

cd ~/simulation_ws/src

catkin_create_pkg my_simulations

Now, let’s create a launch and a world folder inside the my_simulations package.

cd my_simulations

mkdir launch world

Now, inside the launch folder, let’s create a file named my_world.launch:

touch launch/my_world.launch

In that file, let’s put the following content:

<?xml version="1.0" encoding="UTF-8" ?>
<launch>
        <!-- overwriting these args -->
        <arg name="debug" default="false" />
        <arg name="gui" default="true" />
        <arg name="pause" default="false" />
        <arg name="world" default="$(find my_simulations)/world/empty_world.world" />

        <!-- include gazebo_ros launcher -->
        <include file="$(find gazebo_ros)/launch/empty_world.launch">
                <arg name="world_name" value="$(arg world)" />
                <arg name="debug" value="$(arg debug)" />
                <arg name="gui" value="$(arg gui)" />
                <arg name="paused" value="$(arg pause)" />
                <arg name="use_sim_time" value="true" />
        </include>
</launch>

In order to put the content on that file, you can do it using the code editor. For that, click on Tools -> IDE

Tools -> IDE. Opening the Code Editor on ROSDS

Tools -> IDE. Opening the Code Editor on ROSDS

Now, let’s create a file named empty_world.world in the world folder:

touch world/empty_world.world

In that file, let’s add the following content:

<?xml version="1.0" ?>

<sdf version="1.5">
	<world name="default">
		<!-- A global light source -->
		<include>
			<uri>model://sun</uri>
		</include>

		<!-- A ground plane -->
		<include>
			<uri>model://ground_plane</uri>
		</include>
	</world>
</sdf>

 

If you followed the instructions correctly, you should have the following structure:

user:~/simulation_ws/src$ tree .
.
|-- CMakeLists.txt -> /opt/ros/kinetic/share/catkin/cmake/toplevel.cmake
`-- my_simulations
    |-- CMakeLists.txt
    |-- launch
    |   `-- my_world.launch
    |-- package.xml
    `-- world
        `-- empty_world.world

3 directories, 5 files

Loading the Gazebo world using ROS

Now that we have our ROS package set, we can run our packages in two ways:

Option one: Click Simulation -> Choose File, then select my_world.launch. This should automatically load the web version of gazebo, called gzweb.

Opening a ROSject in ROSDS

Option two: If you are running the tests on your computer, or you want to manually run the simulation, you can just:

source ~/simulation_ws/devel/setup.bash
roslaunch my_simulations my_world.launch --screen

The output should be something like:

user:~/simulation_ws/src$ roslaunch my_simulations my_world.launch --screen
... logging to /home/user/.ros/log/1b7241b4-782c-11ea-a2f3-161ed25550cd/roslaunch-rosdscomputer-7087.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://rosdscomputer:40747/

SUMMARY
========

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14
 * /use_sim_time: True

NODES
  /
    gazebo (gazebo_ros/gzserver)
    gazebo_gui (gazebo_ros/gzclient)

auto-starting new master
process[master]: started with pid [7108]
ROS_MASTER_URI=http://master:11311

setting /run_id to 1b7241b4-782c-11ea-a2f3-161ed25550cd
process[rosout-1]: started with pid [7126]
started core service [/rosout]
process[gazebo-2]: started with pid [7140]
process[gazebo_gui-3]: started with pid [7158]
[ INFO] [1586194149.892774702]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1586194149.894694146]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
GZCLIENT disabled by The Construct
[ INFO] [1586194150.663164508, 0.021000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1586194150.694158392, 0.050000000]: Physics dynamic reconfigure ready.

If you are in ROSDS and chose to run the simulation manually, then you have to manually open the Gazebo Web (gzweb) by clicking on Tools -> Gazebo.

Congratulations. You have successfully launched your first Gazebo World using ROS.

Youtube video

If you didn’t understand all the steps explained here or needs more understanding of the files we created, remember that we have the live version of this post on YouTube. Also, if you liked the content, please consider subscribing to our youtube channel. We are publishing new content ~every day.

Keep pushing your ROS Learning.

 

 

[ROS in 5 mins] 028 – What is Gazebo simulation?

[ROS in 5 mins] 028 – What is Gazebo simulation?

Gazebo is a leader in robot simulation. It is a tool relied upon by hundreds of thousands of users and developers around the world.

Perhaps you have heard “Gazebo simulation” many times, but you don’t know exactly what it is or how it works. In this post, you will learn what a Gazebo simulation is by practicing, as it pertains to ROS development.

You don’t need a ROS installation for this, as we will use the ROS Development Studio (ROSDS), an online platform that provides access to ROS1 & ROS2 computers and other powerful ROS tools within a browser!

Let’s go!

Step 1: Create a Project (ROSject) on ROSDS

Action first before the theory! Grab a copy of the project used for this post using the link below. If you don’t have an account on the ROSDS, you will be guided to create one.

Project link: http://www.rosject.io/l/c40d140/.

Once you have cloned the project, open it up and give it a moment to finish loading.

If you want to know how to install Gazebo in an existing ROS environment on your local computer, then please follow this tutorial:

[irp posts=”8194″ name=”All about Gazebo ROS (Gazebo 9)”]

Step 2: Bring up a Gazebo simulation

From the ROSDS Tools menu, pick the Shell and Gazebo tools. Yeah, we have a tool so named:). Place the tools side-by-side for best effect.

Open Gazebo tools

Type the following commands on the Shell to bring up a Gazebo simulation.

user:~$ roslaunch gazebo_ros mud_world.launch

You should now see something similar to this:

Gazebo Sim Launched

Step 3: What is Gazebo simulation in theory?

Well, I just showed you a Gazebo simulation in the step above, in practice. Now we are going to look what it’s in theory.

  • A Gazebo simulation is a robot simulation made with Gazebo, a 3D simulator with the ability to accurately and efficiently simulate populations of robots in complex indoor and outdoor environments.
  • It’s similar to game engines, but produces better simulations and offers a suite of sensors and interfaces for both users and programs.
  • It has the following main components:
    • World files – contain all the elements in a simulation, including robots, lights, sensors, and static objects. In the image above, the world is shown in the Gazebo app.
    • Models – represent individual elements. The three robots and the object in front of them are models.
    • gzserver – the “work horse” Gazebo program – it reads the world file to generate and populate a world.
    • gzclient – connects to gzserver and visualizes the elements. In the shell output, under “NODES”, we have both gzserver and gzclient listed.
    • gzweb – web version of gzclient, using WebGL.

Step 4: Wrapping up

And that’s it! You know what a Gazebo simulation is in both practice and theory. This knowledge is the foundation for using and creating Gazebo simulations.

Extra: Video

Prefer to watch a video demonstrating the steps above? We have one for you below!

Related Resources and Further Learning

If you are a ROS beginner and want to learn ROS basics fast, we recommend you take any of the following courses on Robot Ignite Academy:

To learn more about Gazebo simulation, visit the full Gazebo Tutorials below:

Feedback

Did you like this post? Do you have questions about what is explained? Whatever the case, please leave a comment on the comments section below, so we can interact and learn from each other.

If you want to learn about other ROS topics, please let us know in the comments area and we will do a video or post about it ?

 

Edited by Bayode Aderinola & Yuhong Lin

[ROS Q&A] 191 – How to Launch the Parrot Drone Simulation Locally

[ROS Q&A] 191 – How to Launch the Parrot Drone Simulation Locally

Welcome to the ROS Q&A series again. In this post, we are going to answer and solve a question from a user on Gazebo Answers which asks how to launch a Parrot Drone simulation locally. The question can be found here.

What will you learn in this post

  • How to spawn a drone simulation in your local computer

List of resources referenced in this post

Downloading the required materials

Before downloading the repositories, let’s first create a catkin workspace for the parrot drone, which we will call parrot_ws. Let’s do that with the commands below:

mkdir -p ~/parrot_ws/src
cd ~/parrot_ws/

Now we have the parrot_ws (parrot workspace). Let’s then download the required git repositories which contain the simulation:

cd ~/parrot_ws/src
git clone --branch kinetic-gazebo7 https://bitbucket.org/theconstructcore/parrot_ardrone.git
git clone https://bitbucket.org/theconstructcore/spawn_robot_tools.git

You should now have the folders parrot_ardrone and spawn_robot_tools on the ~/parrot_ws/src folder.

Installing ignition-math, used by sjtu_drone

Before compiling the packages we downloaded in the previous step, we will need to install the Ignition Math library, which is used by the sjtu_drone drone found on the parrot_ardrone repository we cloned previously.

We can install the Ignition Math library with the following commands:

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install libignition-math4-dev -y

Now that we have the Ignition Math library installed, we can proceed to compile the packages in our workspace.

Compiling the drone package

Now that we have everything in place, we can compile our packages we downloaded previously.

IMPORTANT: it may happen that when compiling the package, catkin_make can’t find the ignition library, so we need to export the CXXFLAGS accordingly. In my local computer, the ignition library is found at /usr/include/ignition/math4, so to compile we use the following commands:

cd ~/parrot_ws

export CXXFLAGS=-isystem\ /usr/include/ignition/math4

source /opt/ros/kinetic/setup.bash

catkin_make

If everything worked as expected, great. If not, try removing the devel and build first with cd ~/parrot_ws/; rm -rf build/ devel/  and compile it again with the commands exemplified above.

If everything went ok, you should have something like:

root@79e5b2505ede:~/parrot_ws# export CXXFLAGS=-isystem\ /usr/include/ignition/math4 
root@79e5b2505ede:~/parrot_ws# source /opt/ros/kinetic/setup.bash; catkin_make
Base path: /root/parrot_ws
Source space: /root/parrot_ws/src
Build space: /root/parrot_ws/build
Devel space: /root/parrot_ws/devel
Install space: /root/parrot_ws/install
####
#### Running command: "cmake /root/parrot_ws/src -DCATKIN_DEVEL_PREFIX=/root/parrot_ws/devel -DCMAKE_INSTALL_PREFIX=/root/parrot_ws/install -G Unix Makefiles" in "/root/parrot_ws/build"
####
...
-- catkin 0.7.14
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 6 packages in topological order:
-- ~~  - custom_teleop
-- ~~  - drone_demo
-- ~~  - ardrone_as
-- ~~  - sjtu_drone
-- ~~  - spawn_robot_tools_pkg
-- ~~  - drone_construct
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'custom_teleop'
-- ==> add_subdirectory(parrot_ardrone/custom_teleop)
-- +++ processing catkin package: 'drone_demo'
-- ==> add_subdirectory(parrot_ardrone/drone_demo)
-- +++ processing catkin package: 'ardrone_as'
-- ==> add_subdirectory(parrot_ardrone/ardrone_as)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Generating .msg files for action ardrone_as/Ardrone /root/parrot_ws/src/parrot_ardrone/ardrone_as/action/Ardrone.action
Generating for action Ardrone
-- ardrone_as: 7 messages, 0 services
-- +++ processing catkin package: 'sjtu_drone'
-- ==> add_subdirectory(parrot_ardrone/sjtu_drone)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   thread
--   signals
--   system
--   filesystem
--   program_options
--   regex
--   iostreams
--   date_time
--   chrono
--   atomic
-- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so  
...
-- Generating done
-- Build files have been written to: /root/parrot_ws/build
####
#### Running command: "make -j4 -l4" in "/root/parrot_ws/build"
####
Scanning dependencies of target _ardrone_as_generate_messages_check_deps_ArdroneActionFeedback
Scanning dependencies of target _ardrone_as_generate_messages_check_deps_ArdroneGoal
Scanning dependencies of target _ardrone_as_generate_messages_check_deps_ArdroneActionGoal
Scanning dependencies of target _ardrone_as_generate_messages_check_deps_ArdroneResult
[  0%] Built target _ardrone_as_generate_messages_check_deps_ArdroneResult
...
Scanning dependencies of target plugin_drone
[  1%] Building CXX object parrot_ardrone/sjtu_drone/CMakeFiles/plugin_ros_cam.dir/src/plugin_ros_cam.cpp.o
[  3%] Building CXX object parrot_ardrone/sjtu_drone/CMakeFiles/plugin_ros_imu.dir/src/plugin_ros_imu_native.cpp.o
[  5%] Building CXX object parrot_ardrone/sjtu_drone/CMakeFiles/plugin_drone.dir/src/plugin_drone.cpp.o
[  7%] Building CXX object parrot_ardrone/sjtu_drone/CMakeFiles/plugin_ros_sonar.dir/src/plugin_ros_sonar.cpp.o
...
[  9%] Linking CXX shared library /root/parrot_ws/src/parrot_ardrone/sjtu_drone/plugins/libplugin_ros_imu.so
[ 11%] Linking CXX shared library /root/parrot_ws/src/parrot_ardrone/sjtu_drone/plugins/libplugin_ros_sonar.so
[ 11%] Built target plugin_ros_sonar
[ 13%] Building CXX object parrot_ardrone/sjtu_drone/CMakeFiles/plugin_ros_cam.dir/src/util_ros_cam.cpp.o
[ 13%] Built target plugin_ros_imu
Scanning dependencies of target plugin_ros_init
[ 15%] Building CXX object parrot_ardrone/sjtu_drone/CMakeFiles/plugin_ros_init.dir/src/plugin_ros_init.cpp.o
[ 17%] Building CXX object parrot_ardrone/sjtu_drone/CMakeFiles/plugin_drone.dir/src/pid_controller.cpp.o
[ 19%] Linking CXX shared library /root/parrot_ws/src/parrot_ardrone/sjtu_drone/plugins/libplugin_drone.so
[ 19%] Built target plugin_drone
Scanning dependencies of target spawn_drone
[ 21%] Building CXX object parrot_ardrone/sjtu_drone/CMakeFiles/spawn_drone.dir/src/spawn_drone.cpp.o
...
[ 23%] Linking CXX executable /root/parrot_ws/src/parrot_ardrone/sjtu_drone/bin/spawn_drone
[ 23%] Built target spawn_drone
Scanning dependencies of target spawn_robot_tools_pkg_xacro_generated_to_devel_space_
[ 23%] Built target spawn_robot_tools_pkg_xacro_generated_to_devel_space_
Scanning dependencies of target ardrone_as_generate_messages_cpp
[ 25%] Generating C++ code from ardrone_as/ArdroneFeedback.msg
[ 27%] Generating C++ code from ardrone_as/ArdroneActionResult.msg
[ 29%] Generating C++ code from ardrone_as/ArdroneAction.msg
[ 31%] Generating C++ code from ardrone_as/ArdroneResult.msg
[ 33%] Generating C++ code from ardrone_as/ArdroneActionGoal.msg
[ 35%] Generating C++ code from ardrone_as/ArdroneGoal.msg
[ 37%] Generating C++ code from ardrone_as/ArdroneActionFeedback.msg
Scanning dependencies of target ardrone_as_generate_messages_py
[ 37%] Built target ardrone_as_generate_messages_cpp
[ 39%] Generating Python from MSG ardrone_as/ArdroneFeedback
Scanning dependencies of target ardrone_as_generate_messages_nodejs
[ 41%] Generating Javascript code from ardrone_as/ArdroneFeedback.msg
[ 43%] Generating Javascript code from ardrone_as/ArdroneActionResult.msg
[ 47%] Generating Javascript code from ardrone_as/ArdroneAction.msg
[ 47%] Generating Python from MSG ardrone_as/ArdroneActionResult
[ 49%] Generating Javascript code from ardrone_as/ArdroneResult.msg
[ 50%] Generating Javascript code from ardrone_as/ArdroneActionGoal.msg
[ 52%] Generating Python from MSG ardrone_as/ArdroneAction
[ 54%] Generating Javascript code from ardrone_as/ArdroneGoal.msg
[ 56%] Generating Javascript code from ardrone_as/ArdroneActionFeedback.msg
[ 58%] Generating Python from MSG ardrone_as/ArdroneResult
[ 58%] Built target ardrone_as_generate_messages_nodejs
Scanning dependencies of target ardrone_as_generate_messages_eus
[ 60%] Generating EusLisp code from ardrone_as/ArdroneFeedback.msg
[ 62%] Generating EusLisp code from ardrone_as/ArdroneActionResult.msg
[ 64%] Generating Python from MSG ardrone_as/ArdroneActionGoal
[ 66%] Generating EusLisp code from ardrone_as/ArdroneAction.msg
[ 68%] Generating Python from MSG ardrone_as/ArdroneGoal
[ 70%] Generating EusLisp code from ardrone_as/ArdroneResult.msg
[ 72%] Generating EusLisp code from ardrone_as/ArdroneActionGoal.msg
[ 74%] Generating Python from MSG ardrone_as/ArdroneActionFeedback
[ 76%] Generating EusLisp code from ardrone_as/ArdroneGoal.msg
[ 78%] Generating EusLisp code from ardrone_as/ArdroneActionFeedback.msg
[ 80%] Generating Python msg __init__.py for ardrone_as
[ 82%] Generating EusLisp manifest code for ardrone_as
[ 82%] Built target ardrone_as_generate_messages_py
Scanning dependencies of target ardrone_as_generate_messages_lisp
[ 84%] Generating Lisp code from ardrone_as/ArdroneFeedback.msg
[ 86%] Generating Lisp code from ardrone_as/ArdroneActionResult.msg
[ 88%] Generating Lisp code from ardrone_as/ArdroneAction.msg
[ 90%] Generating Lisp code from ardrone_as/ArdroneResult.msg
[ 92%] Generating Lisp code from ardrone_as/ArdroneActionGoal.msg
[ 94%] Generating Lisp code from ardrone_as/ArdroneGoal.msg
[ 96%] Generating Lisp code from ardrone_as/ArdroneActionFeedback.msg
[ 96%] Built target ardrone_as_generate_messages_lisp
[ 96%] Built target ardrone_as_generate_messages_eus
Scanning dependencies of target ardrone_as_generate_messages
[ 96%] Built target ardrone_as_generate_messages
...
[ 98%] Linking CXX shared library /root/parrot_ws/src/parrot_ardrone/sjtu_drone/plugins/libplugin_ros_cam.so
[ 98%] Built target plugin_ros_cam
[100%] Linking CXX shared library /root/parrot_ws/src/parrot_ardrone/sjtu_drone/plugins/libplugin_ros_init.so
[100%] Built target plugin_ros_init

Once the package is compiled, in every shell you need to source the parrot_ws so that ROS can find the compiled packages. In each shell you can run the commands below:

cd ~/parrot_ws/
source devel/setup.bash
rospack profile

Launching the simulation

Now that you have everything in place, you should be able to launch the simulation with the command below:

source ~/parrot_ws/devel/setup.bash

rosrun drone_construct start_simulation_localy.sh

That is it. You should now have something like the image below:

drone_construct simulation in ROSDS

drone_construct simulation in ROSDS

 

Moving the drone around

With the simulation running, you should now be able to make the robot take off, be able to move it and then make it land using the commands below:

rostopic pub /drone/takeoff std_msgs/Empty "{}"
rostopic pub /drone/land std_msgs/Empty "{}"

rostopic pub /drone/takeoff std_msgs/Empty "{}"
rosrun teleop_twist_keyboard teleop_twist_keyboard.py

After running rosrun teleop_twist_keyboard teleop_twist_keyboard.py you can easily move the robot using the keyboard.

So that is the post for today. You can also find a live version of this post on our YouTube channel in the link below. Also, please consider subscribing to our channel if you liked the content and press the bell for a new video every day.

 

Related course:

 

 

#drone #parrot #Simulation #Gazebo #Robot #rostutorials #Ubuntu

Post Edited by Miguel, Yuhong and Ruben.

Pin It on Pinterest