Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.
6 changes: 3 additions & 3 deletions en/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
* [Simulation](simulation/README.md)
* [jMAVSim Simulation](simulation/jmavsim.md)
* [Gazebo Simulation](simulation/gazebo.md)
* [HITL Simulation](simulation/hitl.md)
* [Interfacing to ROS](simulation/ros_interface.md)
* [AirSim Simulation](simulation/airsim.md)
* [Multi-Vehicle Simulation](simulation/multi-vehicle-simulation.md)
* [HITL Simulation](simulation/hitl.md)
* [Interfacing to ROS](simulation/ros_interface.md)
Copy link
Collaborator Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, done in 108d2ce

* [Hardware](hardware/README.md)
* [Autopilot Hardware](flight_controller/README.md)
* [Porting Guide](debug/porting-guide.md)
Expand Down Expand Up @@ -68,9 +68,9 @@
* [Robotics](robotics/README.md)
* [Offboard Control from Linux](ros/offboard_control.md)
* [ROS](ros/README.md)
* [ROS Installation on RPi](ros/raspberrypi_installation.md)
* [MAVROS \(MAVLink on ROS\)](ros/mavros_installation.md)
* [MAVROS offboard example](ros/mavros_offboard.md)
* [ROS Installation on RPi](ros/raspberrypi_installation.md)
* [External Position Estimation](ros/external_position_estimation.md)
* [Gazebo Octomap](simulation/gazebo_octomap.md)
* [DroneKit](robotics/dronekit.md)
Expand Down
4 changes: 3 additions & 1 deletion en/ros/README.md
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.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI This is just because I think a section should properly introduce its content :-).

@TSC21 is MAVROS required to communicate with PX4 in ROS1 ? Can you use some other comms node?
ie My understanding is that it is needed, whether you are going over wifi or via a uart. Also that ROS2 will support both MAVROS and an approach based on RTPS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other bridges, but the current "official" supported bridge between ROS and the MAVLink protocol is MAVROS. We are extending the support for fast-RTPS (using CDR serialization and deserialization) for the ROS1 implementation. There's currently an open project on the MAVROS repo for supporting ROS2 also - even though ROS2 supports RTPS by default, you need some kind of translation from the uORB msg to the common ROS world, and that's what we are working on on MAVROS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I have captured this by adding a note to MAVROS doc about future support for RTPS, and removing the unnecessary clarification here that the communication is "via MAVLink". You can see the fix here: 6fa0b6f


This section contains topics about using ROS for offboard control with PX4.
2 changes: 1 addition & 1 deletion en/ros/mavros_installation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# MAVROS

The [mavros](http://wiki.ros.org/mavros#mavros.2BAC8-Plugins.sys_status) ros package enables MAVLink extendable communication between computers running ROS, MAVLink enabled autopilots, and MAVLink enabled GCS. While MAVRos can be used to communicate with any MAVLink enabled autopilot this documentation will be in the context of enabling communication between the PX4 flight stack and a ROS enabled companion computer.
The [mavros](http://wiki.ros.org/mavros#mavros.2BAC8-Plugins.sys_status) ROS package enables MAVLink extendable communication between computers running ROS, MAVLink enabled autopilots, and MAVLink enabled GCS. While MAVROS can be used to communicate with any MAVLink enabled autopilot this documentation will be in the context of enabling communication between the PX4 flight stack and a ROS enabled companion computer.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion en/setup/dev_env_linux_ubuntu.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Copy link
Collaborator Author

@hamishwillee hamishwillee Dec 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixing a typo - missing closing bracket


```sh
# ROS Kinetic/Gazebo
Expand Down
40 changes: 22 additions & 18 deletions en/simulation/gazebo.md
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.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, just a better introduction and also cross linking back to the parent doc for "general simulator info".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a collection of tools for automating vehicle control.

not just that, but I guess it fits the purpose.


**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 %}

Expand All @@ -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)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

The 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

Expand Down Expand Up @@ -98,7 +102,7 @@ make posix gazebo_rover
make posix_sitl_default gazebo_hippocampus
```

![](../../assets/gazebo/hippocampus.png)
![Submarine/UUV](../../assets/gazebo/hippocampus.png)



Expand All @@ -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:

Expand Down Expand Up @@ -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

Expand All @@ -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.

Expand Down
55 changes: 30 additions & 25 deletions en/simulation/ros_interface.md
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:
![PX4 SITL overview](../../assets/simulation/px4_sitl_overview.png)

<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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated instructions to point to our build scripts, which include everything you need with PX4 in one easy script. Also link to the kinetic instructions for people who want to do in manually.

@TSC21 FYI, this will need an update once I know what happens with macOS standard installer. If the standard installer does not include ROS are there manual instructions that we know will work on macOS?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, can't tell since I never tried to install ROS on a Mac.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, so the simple answer is "we don't support it"


<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
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • Does this work with PX4 currently?
  • If so, how does the information get to ROS? - we currently have no "path" in our comms directly between ROS and gazebo - they both just talk to PX4.
  • If so, where/when is this useful?

Copy link
Member

@TSC21 TSC21 Dec 18, 2017

Choose a reason for hiding this comment

The 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?
But we also should consider to implement some type of interface with MAVROS (rotors_simulator has a specific plugin to parse all the Gazebo sim data to ROS topics, but we don't do that - we use gazebo msgs only). Currently, all the data that's sent to an autopilot (being it SITL or other) is parsed first or gazebo_mavlink_interface or on other plugins and published as gazebo msgs. handled by gazebo_ros, and that can be received on the PX4 ROS implementation.
About an iteration on the MAVROS support (that pretends to also support HIL) - PX4/PX4-SITL_gazebo-classic#131.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bkueng maybe you can clarify that?

Sorry, since I don't use ROS I don't know the internals on that.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

The 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).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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>
Expand All @@ -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
Expand Down