-
Notifications
You must be signed in to change notification settings - Fork 480
Improve ROS and Gazebo documentation #393
Changes from 5 commits
80951e4
20a0b16
2459ffd
7d418f7
dbbf96d
108d2ce
8fb12b3
6fa0b6f
cd84278
8b5c8a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| # Robotics using ROS | ||
|
|
||
| This section contains topics about using ROS (and offboard control) with PX4. | ||
| [ROS](http://www.ros.org/) (Robot Operating System) is a general purpose robotics library that can be used with PX4 for offboard control. It uses the [MAVROS](../ros/mavros_installation.md) node to communicate with PX4 via MAVLink. | ||
|
||
|
|
||
| This section contains topics about using ROS for offboard control with PX4. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,7 +157,7 @@ sudo apt-get install clang-3.5 lldb-3.5 -y | |
|
|
||
| ### ROS/Gazebo | ||
|
|
||
| Install the dependencies for [ROS/Gazebo](../ros/README.md)) ("Kinetic"). These include Gazebo7 (at time of writing, the default version that comes with ROS). The instructions come from the ROS Wiki [Ubuntu page](http://wiki.ros.org/kinetic/Installation/Ubuntu). | ||
| Install the dependencies for [ROS/Gazebo](../ros/README.md) ("Kinetic"). These include Gazebo7 (at time of writing, the default version that comes with ROS). The instructions come from the ROS Wiki [Ubuntu page](http://wiki.ros.org/kinetic/Installation/Ubuntu). | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just fixing a typo - missing closing bracket |
||
|
|
||
| ```sh | ||
| # ROS Kinetic/Gazebo | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| # Gazebo Simulation | ||
|
|
||
| [Gazebo](http://gazebosim.org) is a 3D simulation environment for autonomous robots. It supports standalone use (without ROS) or SITL + ROS. | ||
| [Gazebo](http://gazebosim.org) is a powerful 3D simulation environment for autonomous robots that is particularly suitable for testing object-avoidance and computer vision. It can also be used for [multi-vehicle simulation](../simulation/multi-vehicle-simulation.md) and is commonly used with [ROS](../simulation/ros_interface.md), a collection of tools for automating vehicle control. | ||
|
||
|
|
||
| **Supported Vehicles:** Quad ([Iris](../airframes/airframe_reference.md#copter_quadrotor_wide_3dr_iris_quadrotor) and [Solo](../airframes/airframe_reference.md#copter_quadrotor_x_3dr_solo), Hex (Typhoon H480), [Generic quad delta VTOL](../airframes/airframe_reference.md#vtol_standard_vtol_generic_quad_delta_vtol), Tailsitter, Plane, Rover, Submarine (coming soon!) | ||
|
|
||
| > **Tip** See [Simulation](/simulation/README.md) for general information about simulators, the simulation environment and available simulation configuration (e.g. supported vehicles). | ||
|
|
||
| {% youtube %}https://www.youtube.com/watch?v=qfFF9-0k4KA&vq=hd720{% endyoutube %} | ||
|
|
||
|
|
@@ -12,31 +16,31 @@ graph LR; | |
| MAVLink-->SITL; | ||
| {% endmermaid %} | ||
|
|
||
| ## Installation | ||
|
|
||
| The installation requires to install Gazebo and our simulation plugin. | ||
|
|
||
| > **Note** Gazebo version 7 is recommended (the minimum version is Gazebo 6). If you run Linux and installed a ROS version earlier than Jade, be sure to uninstall the bundled Gazebo (sudo apt-get remove ros-indigo-gazebo) version as it is too old. | ||
| ## Installation | ||
|
|
||
| Check the [Linux](../setup/dev_env_linux.md) and [Mac](../setup/dev_env_mac.md) pages for install infos. | ||
| > **Tip** If you plan to use PX4 with ROS you should instead [follow the instructions here](../simulation/ros_interface.md) to install Gazebo as part of ROS! Note that we install Gazebo7 with ROS, as this is the default compatible version. | ||
|
|
||
| #### ROS Users | ||
| Gazebo 8 setup in included in our standard build instructions: | ||
| - **macOS:** [Development Environment on Mac](http://localhost:4000/en/setup/dev_env_mac.html) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TSC21 Does macOS installer also include ROS Kinetic? If so, does it install Gazebo 7 (the default) or Gazebo 8 (preferred).
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note also that I've dropped the mention of gazebo 6. We prefer gazebo 8 as standalone and for ROS we use whatever it default to.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't actually confirm that since I don't have a Mac... |
||
| - **Linux:** [Development Environment on Linux > jMAVSim/Gazebo Simulation](../setup/dev_env_linux.md#jmavsimgazebo-simulation) | ||
| - **Windows:** Not supported. | ||
|
|
||
| The PX4 SITL uses the Gazebo simulator, but does not depend on ROS. The simulation can be [interfaced to ROS](../simulation/ros_interface.md) the same way as normal flight code is. | ||
| Additional installation instructions can be found on [gazebosim.org](http://gazebosim.org/tutorials?cat=guided_b&tut=guided_b1). | ||
|
|
||
| If you plan to use PX4 with ROS, make sure to follow the [Gazebo version guide for version 7](http://gazebosim.org/tutorials?tut=ros_wrapper_versions#Gazebo7.xseries) for ROS. | ||
|
|
||
| #### Normal Installation | ||
| ## Running the Simulation | ||
|
|
||
| Follow the [Linux installation instructions](http://gazebosim.org/tutorials?tut=install_ubuntu&ver=7.0&cat=install) for Gazebo 7. | ||
| You can run a simulation by starting PX4 SITL and gazebo with the airframe configuration to load (multicopters, planes, VTOL, optical flow and multi-vehicle simulations are supported). | ||
|
|
||
| Make sure to have both installed: `gazebo7` and `libgazebo7-dev`. | ||
| The easiest way to do this is to open a terminal in the root directory of the PX4 *Firmware* repository and call `make` for the targets as shown in the following sections. | ||
|
|
||
| ## Running the Simulation | ||
| > **Tip** You can use the [instructions below](#start_px4_sim_separately) to keep Gazebo running and only re-launch PX4. This is quicker than restarting both. | ||
|
|
||
| From within the source directory of the PX4 Firmware run the PX4 SITL with one of the airframes (Quads, planes and VTOL are supported, including optical flow): | ||
| <span></span> | ||
| > **Tip** For the full list of build targets run `make posix list_vmd_make_targets` (and filter on those that start with `gazebo_`). | ||
|
|
||
| > **Note** You can use the instructions below to keep Gazebo running and only re-launch PX4. | ||
|
|
||
| ### Quadrotor | ||
|
|
||
|
|
@@ -98,7 +102,7 @@ make posix gazebo_rover | |
| make posix_sitl_default gazebo_hippocampus | ||
| ``` | ||
|
|
||
|  | ||
|  | ||
|
|
||
|
|
||
|
|
||
|
|
@@ -108,7 +112,7 @@ The current default world is the iris.world located in the directory [worlds](ht | |
|
|
||
| ## Taking it to the Sky | ||
|
|
||
| > **Note** Please refer to the [Installing Files and Code](../setup/dev_env_mac.md) guide in case you run into any errors. | ||
| > **Note** Please refer to the [Installing Files and Code](../setup/dev_env.md) guide if you run into any errors. | ||
|
|
||
| This will bring up the PX4 shell: | ||
|
|
||
|
|
@@ -139,7 +143,7 @@ The system will print the home position once it finished intializing (`telem> ho | |
| pxh> commander takeoff | ||
| ``` | ||
|
|
||
| > **Note** Joystick or thumb-joystick support is available through QGroundControl (QGC). To use manual input, put the system in a manual flight mode (e.g. POSCTL, position control). Enable the thumb joystick from the QGC preferences menu. | ||
| > **Note** Joystick or thumb-joystick support [is available](../simulation/README.md#joystickgamepad-integration). | ||
|
|
||
| ## Set custom takeoff location | ||
|
|
||
|
|
@@ -155,7 +159,7 @@ export PX4_HOME_ALT=28.5 | |
| make posix gazebo | ||
| ``` | ||
|
|
||
| ## Starting Gazebo and PX4 separately | ||
| ## Starting Gazebo and PX4 separately {#start_px4_sim_separately} | ||
|
|
||
| For extended development sessions it might be more convenient to start Gazebo and PX4 separately or even from within an IDE. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,53 @@ | ||
| # Interfacing the Simulation to ROS | ||
|
|
||
| The simulated autopilot starts a second MAVLink interface on port 14557. Connecting MAVROS to this port allows to receive all data the vehicle would expose if in real flight. | ||
| [ROS](../ros/README.md) (Robot Operating System) is a general purpose robotics library that can be used with the PX4 flight stack and also (optionally) with the Gazebo simulator. It uses the [MAVROS](../ros/mavros_installation.md) MAVLink node to communicate with PX4. | ||
|
|
||
| ## Launching MAVROS | ||
| The diagram below shows the *standard* [PX4 simulation environment](../simulation/README.md#sitl-simulation-environment). PX4 communicates with the simulator (e.g. Gazebo) to receive sensor data from the simulated world and send motor and actuator values. It communicates with the GCS and Offboard API to send telemetry from the simulated environment and receive commands. | ||
|
|
||
| If an interface to ROS is wanted, the already running secondary MAVLink instance can be connected to ROS via [mavros](../ros/mavros_offboard.md). To connect to a specific IP (`fcu_url` is the IP / port of SITL), use a URL in this form: | ||
|  | ||
|
|
||
| <div class="host-code"></div> | ||
| The ROS/Gazebo integration with PX4 follows the pattern above. The only *slight* difference being that ROS initiates the connection on port 14557, while it is more typical for an offboard API to listen for connections on UDP port 14540. | ||
|
|
||
| ```sh | ||
| roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557" | ||
| ``` | ||
|
|
||
| To connect to localhost, use this URL: | ||
| ## Installing Gazebo for ROS | ||
|
||
|
|
||
| <div class="host-code"></div> | ||
| The easiest way to setup PX4 simulation with ROS on Ubuntu Linux is to use the standard installation script that can be found at [Development Environment on Linux > Gazebo with ROS](../setup/dev_env_linux.md#gazebo-with-ros). The script installs everything you need: PX4, ROS "Kinetic", the Gazebo 7 simulator, and [MAVROS](../ros/mavros_installation.md). | ||
|
|
||
| ```sh | ||
| roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557" | ||
| ``` | ||
| > **Note** The script follows the [standard ROS "Kinetic" installation instructions](http://wiki.ros.org/kinetic/Installation/Ubuntu), which include Gazebo 7. Installation of ROS Kinetic for other platforms is covered in the [ROS Wiki here](http://wiki.ros.org/kinetic/Installation). | ||
|
|
||
|
|
||
| ## Installing Gazebo for ROS | ||
| ## Launching ROS/Simulation | ||
|
|
||
| The Gazebo ROS SITL simulation is known to work with both Gazebo 6 and Gazebo 7, which can be installed via: | ||
| The command below can be used to launch the simulation and connect ROS to it via [MAVROS](../ros/mavros_installation.md), where `fcu_url` is the IP / port of the computer running the simulation: | ||
|
|
||
| ```sh | ||
| sudo apt-get install ros-$(ROS_DISTRO)-gazebo7-ros-pkgs //Recommended | ||
| roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557" | ||
| ``` | ||
| or | ||
|
|
||
| To connect to localhost, use this URL: | ||
|
|
||
| ```sh | ||
| sudo apt-get install ros-$(ROS_DISTRO)-gazebo6-ros-pkgs | ||
| roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557" | ||
| ``` | ||
|
|
||
| ## Launching Gazebo with ROS wrappers | ||
| > **Tip** It can be useful to call *roslaunch* with the `-w` (warn) and/or `-v` (verbose) in order to get warnings about missing dependencies in your setup. For example: | ||
| ```sh | ||
| roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557" | ||
| ``` | ||
|
|
||
|
|
||
| In case you would like to modify the Gazebo simulation to integrate sensors publishing directly to ROS topics e.g. the Gazebo ROS laser plugin, Gazebo must be launched with the appropriate ROS wrappers. | ||
| ## Launching Gazebo with ROS Wrappers | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TSC21 So how I interpret this is that rather than having ROS get rangefinder information from PX4 it can get it from gazebo.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The PX4 ROS implementation (which is an active part of SITL) has everything built in to receive and publish data in the ROS framework - but I actually don't know what is happening there cause there seems to be some data handled as ROS msgs, other as Gazebo msgs, while there is data also being handled as Mavlink msgs. @bkueng maybe you can clarify that?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, since I don't use ROS I don't know the internals on that.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok but then whoever wrote the PX4 ROS implementation can give a hand here?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This all sounds very inconsistent. It would be useful to understand, but I doubt we'll get a timely answer on this point. OK if I create a separate issue that this section needs update and merge the rest?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does require a clarification is how the PX4 ROS implementation is done, what it accepts and how it can be applied generally (if it can be pulled out of the SITL sim environment for example).
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I have posted a question #399 for that. |
||
|
|
||
| The Gazebo simulation can be modified to integrate sensors publishing directly to ROS topics e.g. the Gazebo ROS laser plugin. To support this feature, Gazebo must be launched with the appropriate ROS wrappers. | ||
|
|
||
| There are ROS launch scripts available to run the simulation wrapped in ROS: | ||
|
|
||
| * [posix_sitl.launch](https://github.com/PX4/Firmware/blob/master/launch/posix_sitl.launch): plain SITL launch | ||
| * [mavros_posix_sitl.launch](https://github.com/PX4/Firmware/blob/master/launch/mavros_posix_sitl.launch): SITL and MAVROS | ||
| * [posix_sitl.launch](https://github.com/PX4/Firmware/blob/master/launch/posix_sitl.launch): plain SITL launch | ||
| * [mavros_posix_sitl.launch](https://github.com/PX4/Firmware/blob/master/launch/mavros_posix_sitl.launch): SITL and MAVROS | ||
|
|
||
| To run SITL wrapped in ROS the ROS environment needs to be updated, then launch as usual: | ||
|
|
||
| (optional): only source the catkin workspace if you compiled MAVROS or other ROS packages from source | ||
| (optional): only source the catkin workspace if you compiled MAVROS or other ROS packages from source: | ||
|
|
||
| ```sh | ||
| cd <Firmware_clone> | ||
|
|
@@ -58,15 +61,17 @@ roslaunch px4 posix_sitl.launch | |
|
|
||
| Include one of the above mentioned launch files in your own launch file to run your ROS application in the simulation. | ||
|
|
||
| ### What's happening behind the scenes | ||
| ### What's Happening Behind the Scenes | ||
|
|
||
| This section shows how the *roslaunch* instructions provided previously actually work (you can follow them to manually launch the simulation and ROS). | ||
|
|
||
| (or how to run it manually) | ||
| First start the simulator using the command below: | ||
|
|
||
| ```sh | ||
| no_sim=1 make posix_sitl_default gazebo | ||
| ``` | ||
|
|
||
| This should start the simulator and the console will look like this | ||
| The console will look like this: | ||
|
|
||
|
|
||
| ```sh | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TSC21 I would like to move this OUT of simulation and into the ROS section. My reasoning is that even though ROS can be used with a simulator, it can also be used stand alone. The topic name would also change to something like "ROS with Gazebo Simulation". Note that I have updated the Gazebo doc to better link to this ROS doc too.
Does this make sense to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, done in 108d2ce