Skip to content

Commit ec790ca

Browse files
authored
use external autopilot-tools python package for autopilot configuration (#37)
1 parent b70625e commit ec790ca

11 files changed

Lines changed: 178 additions & 1485 deletions

README.md

Lines changed: 56 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,28 @@
1-
# VTOL HITL Dynamics Simulator
1+
# UAV HITL Dynamics Simulator
22

3-
VTOL HITL Dynamics Simulator is a set of ROS packages proposed full simulation for UAV based on PX4/Ardupilot autopilot.
3+
UAV HITL Dynamics Simulator is a set of ROS packages proposed full simulation for UAV based on PX4/Ardupilot autopilot.
44

55
![dynamics](docs/img/dynamics.png?raw=true "dynamics")
66

77
The key feature of this simulation is to run it in such a way that the hardware knows nothing about the simulation. This can be done with Cyphal/DroneCAN. It covers more PX4 modules than standard SITL and HITL.
88

99
## 1. Design
1010

11-
VTOL HITL Dynamics Simulator is designed to be flexible.
12-
13-
It supports multiple dynamics:
14-
- [inno_vtol](https://github.com/RaccoonlabDev/inno_vtol_dynamics),
15-
- [flightgoggles_multicopter](https://github.com/mit-aera/FlightGoggles)
16-
17-
and protocols:
18-
- `MAVLink SITL`,
19-
- `DroneCAN HITL`,
20-
- `Cyphal HITL`.
21-
22-
It is expected to use either PX4 or ArduPilot autopilots.
23-
24-
The simulator is divided into the following main components:
11+
VTOL HITL Dynamics Simulator is designed to be modular. It is divided into the following main components:
2512

2613
1. `UAV dynamics` is the main node that handles actuator commands from the communicator, performs dynamics simulation, and publishes vehicle and sensors states.
2714
2. `Communicator` is the set of nodes that communicate with the `PX4 flight stack` in HITL (via Cyphal/DroneCAN) and SITL (via MAVLink) modes.
28-
3. `inno_sim_interface` is a bridge for interaction with `Inno Simulator` through ROS.
15+
3. `inno_sim_interface` is a bridge for interaction with `3D-Simulator` through ROS.
2916

3017
The design of the simulator is shown below.
3118

3219
![scheme](docs/img/scheme.png?raw=true "scheme")
3320

34-
## 2. Supported modes
35-
36-
The primaries modes are:
37-
38-
|| Autopilot | Communicator | dynamics | Airframe |
39-
| - | -------- | --------- | ------------ | -------- |
40-
| 1 | PX4 v1.12/v1.13 | DroneCAN HITL | inno_vtol | inno_standard_vtol [(13070)](https://github.com/PonomarevDA/Firmware/blob/px4_v1.12.1_inno_vtol_dynamics/ROMFS/px4fmu_common/init.d/airframes/13070_innopolis_vtol)
41-
| 2 | PX4 v1.13 | Cyphal HITL | inno_vtol | Generic Quadcopter [(4001)](https://dev.px4.io/master/en/airframes/airframe_reference.html#quadrotor-x)
42-
43-
The following modes are supported as well, but they are not well-tested:
44-
45-
|| Autopilot | Communicator | dynamics | Airframe |
46-
| - | -------- | --------- | ------------ | -------- |
47-
| 1 | PX4 v1.12| DroneCAN HITL | quadcopter | iris [(10016)](https://github.com/PonomarevDA/Firmware/blob/px4_v1.12.1_inno_vtol_dynamics/ROMFS/px4fmu_common/init.d-posix/airframes/10016_iris) |
48-
| 2 | PX4 v1.12 | MAVLink SITL | inno_vtol | innopolis_vtol [(1050)](https://github.com/PonomarevDA/Firmware/blob/px4_v1.12.1_inno_vtol_dynamics/ROMFS/px4fmu_common/init.d-posix/airframes/1050_innopolis_vtol) |
49-
| 3 | PX4 v1.12 | MAVLink SITL | quadcopter | iris [(10016)](https://github.com/PonomarevDA/Firmware/blob/px4_v1.12.1_inno_vtol_dynamics/ROMFS/px4fmu_common/init.d-posix/airframes/10016_iris) |
50-
| 4 | ArduPilot v4.3/v4.4 | DroneCAN HITL | inno_vtol | copter |
51-
| 5 | ArduPilot v4.3/v4.4 | Cyphal HITL | inno_vtol | copter |
52-
53-
New modes will be extended step by step.
54-
55-
## 3. Usage
21+
## 2. Usage
5622

57-
The instruction below discribes the most common use case: PX4 v1.13 in DroneCAN VTOL and Cyphal Quadcopter modes. If you want to use ArduPilot, another dynamic, airframe or SITL mode, you can still use this instruction, but it is recommended to read additional instructions.
58-
59-
The simulator is distributed as a Docker image. If you want to contribute or try it without Docker, you can find more details in [the developer docs](docs/dev_docs.md).
23+
The simulator is distributed as a Docker image. It is recommended to use the `./scripts/docker.sh` script. It configures all the necessary Docker flags, performs automatic firmware upload,
24+
configuration, creates a CAN interface, and generally provides a simple interface to interact with
25+
the simulator.
6026

6127
**Step 1. Clone repository with submodules**
6228

@@ -72,129 +38,103 @@ git submodule update --init --recursive
7238

7339
**Step 2. Build/pull the docker image**
7440

75-
It is recommended to use the `./scripts/docker.sh` script. It configures all the necessary Docker flags, SLCAN and provides a simple interface to interact with the simulator.
76-
77-
To get help, just type:
78-
79-
```bash
80-
./scripts/docker.sh --help
81-
```
82-
8341
To build docker image, type:
8442

8543
```bash
8644
./scripts/docker.sh build
8745
```
8846

89-
To pull docker image, type:
90-
91-
```bash
92-
./scripts/docker.sh pull
93-
```
47+
> An image on dockerhub usually is not up to date, so it's better to build manually
9448
95-
**Step 3. Connect everything together**
49+
**Step 3. Connect everything together for HITL**
9650

97-
> This step is not necessary if you want to run PX4 MAVLink SITL mode. Please follow [docs/px4/mavlink](docs/px4/mavlink.md) instead.
51+
> You should skip this step if you want to run PX4 MAVLink SITL mode. Please follow [docs/px4/mavlink](docs/px4/mavlink.md) for details.
9852
9953
Typically we use [CUAV v5+](https://docs.px4.io/master/en/flight_controller/cuav_v5_plus.html) and [RL-programmer-sniffer](https://docs.raccoonlab.co/guide/programmer_sniffer/), but it might be anything else.
10054

10155
An example of a connection is shown in the picture below.
10256

10357
<img src="docs/img/sniffer_connection.png" alt="drawing" width="640"/>
10458

105-
If you have a choice, it is sometimes preferable to use CAN1 on the autopilot side.
59+
All default parameters expect that you use CAN1 on the autopilot side.
10660

107-
**Step 4. Upload firmware**
61+
**Step 4. Run the container in force mode**
10862

109-
HITL simulator may require some additional features that the official PX4 and ArduPilot doesn't have.
63+
In `--force` mode the script automatically upload the required firmware and parameters corresponded
64+
to the specified mode, create SLCAN and run the container with required docker flags.
11065

111-
The appropriated and ready to use binaries are uploaded here: [PX4](https://github.com/ZilantRobotics/PX4-Autopilot/releases) and [ArduPilot](https://github.com/ZilantRobotics/ardupilot/releases). Alternativelly, you can build the firmware manually.
66+
To run force mode you need to install [autopilot-tools](https://pypi.org/project/autopilot-tools/) python package: `pip install autopilot-tools`.
11267

113-
For PX4 DroneCAN you can upload the firmware by typing the following 2 lines:
114-
115-
```bash
116-
wget https://github.com/ZilantRobotics/PX4-Autopilot/releases/download/v1.13.0_hitl/px4_fmu-v5_default.px4
117-
./scripts/px4/upload.sh px4_fmu-v5_default.px4
118-
```
119-
120-
For PX4 Cyphal you can upload the firmware by typing:
121-
122-
```bash
123-
wget https://github.com/ZilantRobotics/PX4-Autopilot/releases/download/v1.13.0_hitl/px4_fmu-v5_cyphal.px4
124-
./scripts/px4/upload.sh px4_fmu-v5_cyphal.px4
125-
```
126-
127-
**Step 5. Configure autopilot**
128-
129-
You need to run the [scripts/parameters_configurator.py](scripts/parameters_configurator.py). It will automatically will reset your parameters to default, and then configure exactly the parameters your autopilot needs for the HITL simulation. It will automatically restart the autopilot a few times.
130-
131-
```bash
132-
pip install mavlink_tools
133-
./scripts/parameters_configurator.py <desired_mode>
134-
```
135-
136-
If your desired mode is not supported, refer to the corresponded section for the details:
137-
- [PX4 Autopilot](docs/px4/README.md)
138-
- [Ardupilot](docs/ardupilot/README.md)
139-
140-
**Step 6. Run the container**
141-
142-
You can run the simulator with the same `./scripts/docker.sh` script.
143-
144-
To get help, type:
68+
To get the list of all supported modes, just type:
14569

14670
```bash
14771
./scripts/docker.sh --help
14872
```
14973

150-
To run Cyphal VTOL, type:
74+
To run PX4 Cyphal quadcopter, type:
15175

15276
```bash
153-
./scripts/docker.sh cv
77+
./scripts/docker.sh cq # cq = cyphal_quadrotor
15478
```
15579

156-
To run Dronecan VTOL, type:
80+
To run PX4 Dronecan VTOL, type:
15781

15882
```bash
159-
./scripts/docker.sh dv
83+
./scripts/docker.sh dv # cq = dronecan_vtol
16084
```
16185

162-
Here the commands are similar for both PX4 and ArduPilot.
86+
Troubleshooting:
87+
- If your sniffer connection is not found or something else is missing, it will exit in a few seconds.
16388

164-
The scripts will automatically attach SLCAN. If your sniffer connection is not found, it will exit in a few seconds.
89+
If something doesn't work, please open an issue.
16590

166-
**Step 7. Run QGC**
91+
**Step 5. Run ground control station**
16792

168-
Run QGroundControl or any other MAVLink based ground station you need to start the flight.
93+
Here 2 options are suggested.
94+
1. You can run QGroundControl or MissionPlanner to have manual flight
95+
2. (soon) You can run a script to run one of the test scenario in automatic mode.
16996

170-
**Step 8. (optional) InnoSimulator**
97+
**Step 6. (optional) 3D Simulator**
17198

172-
InnoSimulator is a photorealistic simulator.
99+
> A new 3D simulator will appear here soon.
173100
174-
At that moment we use it for visualization purposes only.
101+
## 3. Supported modes
175102

176-
To use it you need to download it from [inno-robolab/InnoSimulator](https://github.com/inno-robolab/InnoSimulator) repository.
103+
You can obrain the actual list of the suported modes by typing `./scripts/docker.sh --help`.
177104

178-
An example of running might be:
105+
Well, here is the output of the command:
179106

180107
```bash
181-
~/software/InnoSimulator-Linux64-2021.1.3/InnoSimulator.x86_64
108+
Primary well-supported modes (with aliases):
109+
cyphal_quadrotor,cq Cyphal PX4 v1.14-beta Quadrotor x (4001)
110+
dronecan_quadrotor,dq DroneCAN PX4 v1.14-beta Quadrotor (4001)
111+
dronecan_vtol,dv DroneCAN PX4 v1.12 inno_vtol
112+
113+
Other modes:
114+
cyphal_standard_vtol,csv Cyphal PX4 v1.14-beta Standard VTOL (13000)
115+
cyphal_octorotor,co Cyphal PX4 v1.14-beta Octorotor Coaxial (12001)
116+
sitl_inno_vtol MAVLink PX4 v1.12 inno_vtol
117+
sitl_flight_goggles MAVLink PX4 v1.12 Quadrotor (4001)
118+
cyphal_and_dronecan 2 CAN AP v4.4.0 Copter
182119
```
183120

184-
Then choose a drone and press the Launch button.
185-
121+
New modes will be extended step by step.
186122

187123
## 4. Example
188124

189125
Check the video below.
190126

191127
[![Cyphal/DroneCAN HITL VTOL dynamics simulator](https://img.youtube.com/vi/e9MREW6tCmE/0.jpg)](https://youtu.be/e9MREW6tCmE)
192128

193-
## 5. Repos used as references
129+
## 5. Auxilliary documentation
130+
131+
Docs:
132+
133+
- [Developer docs](docs/dev_docs.md)
134+
- [PX4 MAVLink SITL manual configuration instructions](docs/px4/mavlink.md)
135+
136+
Outdated manual instructions:
194137

195-
1. [flightgoggles_uav_dynamics (multicopter)](https://github.com/mit-fast/FlightGoggles/blob/master/flightgoggles_uav_dynamics/) - read their [paper](https://arxiv.org/pdf/1905.11377.pdf)
196-
2. [PX4 mavlink communicator](https://github.com/ThunderFly-aerospace/PX4-FlightGear-Bridge)
197-
3. [sitl_gazebo](https://github.com/PX4/sitl_gazebo)
198-
4. [innopolis_vtol_indi](https://github.com/RaccoonlabDev/innopolis_vtol_indi) - dynamics written in Octave
199-
5. [InnoSimulator](https://github.com/inno-robolab/InnoSimulator) - photorealistic simulator
200-
6. [inno_sim_interface](https://github.com/RaccoonlabDev/inno_sim_interface) - the bridge between dynamics and photorealistic simulator
138+
- [PX4 Cyphal manual configuration instructions](docs/px4/cyphal.md)
139+
- [PX4 DroneCAN manual configuration instructions](docs/px4/dronecan.md)
140+
- [ArduPilot manual configuration instructions](docs/ardupilot/README.md)

scripts/ardupilot_configurator.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

scripts/autopilot_configurator.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

scripts/calibrate_ardupilot_mag.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)