Skip to content

Commit 1d80fc3

Browse files
committed
docs(sim): restructure hardware sim pages and add SIH docs
Co-authored-by: Hamish Willee <hamishwillee@gmail.com> Signed-off-by: Ramon Roche <mrpollo@gmail.com>
1 parent 01dd41b commit 1d80fc3

File tree

11 files changed

+563
-306
lines changed

11 files changed

+563
-306
lines changed
Lines changed: 30 additions & 0 deletions
Loading

docs/en/SUMMARY.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@
466466
- [Plugins](sim_gazebo_gz/plugins.md)
467467
- [Gazebo Models Repository](sim_gazebo_gz/gazebo_models.md)
468468
- [Multi-Vehicle Sim](sim_gazebo_gz/multi_vehicle_simulation.md)
469+
- [SIH Simulation](sim_sih/index.md)
469470
- [Gazebo Classic Simulation](sim_gazebo_classic/index.md)
470471
- [Vehicles](sim_gazebo_classic/vehicles.md)
471472
- [Worlds](sim_gazebo_classic/worlds.md)
@@ -849,8 +850,9 @@
849850
- [Multi-Vehicle Sim with JMAVSim](sim_jmavsim/multi_vehicle.md)
850851
- [JSBSim Simulation](sim_jsbsim/index.md)
851852
- [AirSim Simulation](sim_airsim/index.md)
852-
- [HITL Simulation](simulation/hitl.md)
853-
- [Simulation-In-Hardware](sim_sih/index.md)
853+
- [Hardware Simulation](simulation/hardware.md)
854+
- [HITL Simulation](simulation/hitl.md)
855+
- [SIH on Hardware](sim_sih/hardware.md)
854856
- [Multi-vehicle simulation](simulation/multi-vehicle-simulation.md)
855857
- [Platform Testing and CI](test_and_ci/index.md)
856858
- [Test Flights](test_and_ci/test_flights.md)

docs/en/dev_setup/building_px4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ make [VENDOR_][MODEL][_VARIANT] [VIEWER_MODEL_DEBUGGER_WORLD]
263263
- **VENDOR:** The manufacturer of the board: `px4`, `aerotenna`, `airmind`, `atlflight`, `auav`, `beaglebone`, `intel`, `nxp`, etc.
264264
The vendor name for Pixhawk series boards is `px4`.
265265
- **MODEL:** The _board model_ "model": `sitl`, `fmu-v2`, `fmu-v3`, `fmu-v4`, `fmu-v5`, `navio2`, etc.
266-
- **VARIANT:** Indicates particular configurations: e.g. `bootloader`, `cyphal`, which contain components that are not present in the `default` configuration.
266+
- **VARIANT:** Indicates particular configurations: e.g. `bootloader`, `cyphal`, `sih`, which add or remove components to/from the `default` configuration.
267267
Most commonly this is `default`, and may be omitted.
268268

269269
:::tip

docs/en/sim_jmavsim/index.md

Lines changed: 95 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,31 @@ jMAVSim can also be used for HITL Simulation ([as shown here](../simulation/hitl
2222

2323
## Installation
2424

25-
jMAVSim setup is included in our [standard build instructions](../dev_setup/dev_env.md) for Ubuntu Linux and Windows.
26-
Follow the instructions below to install jMAVSim on macOS.
25+
jMAVSim requires JDK 17 or later.
26+
On Ubuntu and Windows, the [standard development environment setup](../dev_setup/dev_env.md) scripts install all required dependencies including Java.
27+
On macOS, you need to install Java manually as shown below.
2728

2829
### macOS
2930

30-
To setup the environment for [jMAVSim](../sim_jmavsim/index.md) simulation:
31+
jMAVSim requires OpenJDK 17 or later.
32+
Install it via Homebrew:
3133

32-
1. Install a recent version of Java (e.g. Java 15).
33-
You can download [Java 15 (or later) from Oracle](https://www.oracle.com/java/technologies/downloads/?er=221886) or use [Eclipse Temurin](https://adoptium.net):
34-
35-
```sh
36-
brew install --cask temurin
37-
```
38-
39-
1. Install jMAVSim:
40-
41-
```sh
42-
brew install px4-sim-jmavsim
43-
```
34+
```sh
35+
brew install openjdk@17
36+
```
4437

45-
:::warning
46-
PX4 v1.11 and beyond require at least JDK 15 for jMAVSim simulation.
38+
Homebrew installs OpenJDK but does not link it into your `PATH`, so you need to set `JAVA_HOME` for jMAVSim to find it.
39+
Add this to your shell profile (e.g. `~/.zshrc`):
4740

48-
For earlier versions, macOS users might see the error `Exception in thread "main" java.lang.UnsupportedClassVersionError:`.
49-
You can find the fix in the [jMAVSim with SITL > Troubleshooting](../sim_jmavsim/index.md#troubleshooting)).
50-
:::
41+
```sh
42+
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
43+
```
5144

5245
## Simulation Environment
5346

54-
Software in the Loop Simulation runs the complete system on the host machine and simulates the autopilot. It connects via local network to the simulator. The setup looks like this:
47+
Software in the Loop Simulation runs the complete system on the host machine and simulates the autopilot.
48+
It connects via local network to the simulator.
49+
The setup looks like this:
5550

5651
[![Mermaid graph: SITL Simulator](https://mermaid.ink/img/eyJjb2RlIjoiZ3JhcGggTFI7XG4gIFNpbXVsYXRvci0tPk1BVkxpbms7XG4gIE1BVkxpbmstLT5TSVRMOyIsIm1lcm1haWQiOnsidGhlbWUiOiJkZWZhdWx0In0sInVwZGF0ZUVkaXRvciI6ZmFsc2V9)](https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ3JhcGggTFI7XG4gIFNpbXVsYXRvci0tPk1BVkxpbms7XG4gIE1BVkxpbmstLT5TSVRMOyIsIm1lcm1haWQiOnsidGhlbWUiOiJkZWZhdWx0In0sInVwZGF0ZUVkaXRvciI6ZmFsc2V9)
5752

@@ -94,7 +89,8 @@ It will also bring up a window showing a 3D view of the [jMAVSim](https://github
9489

9590
## Taking it to the Sky
9691

97-
The system will start printing status information. You will be able to start flying once you have a position lock (shortly after the console displays the message: _EKF commencing GPS fusion_).
92+
The system will start printing status information.
93+
You will be able to start flying once you have a position lock (shortly after the console displays the message: _EKF commencing GPS fusion_).
9894

9995
To takeoff enter the following into the console:
10096

@@ -196,8 +192,8 @@ Lockstep makes it possible to [change the simulation speed](#change-simulation-s
196192
The sequence of steps for lockstep are:
197193

198194
1. The simulation sends a sensor message [HIL_SENSOR](https://mavlink.io/en/messages/common.html#HIL_SENSOR) including a timestamp `time_usec` to update the sensor state and time of PX4.
199-
1. PX4 receives this and does one iteration of state estimation, controls, etc. and eventually sends an actuator message [HIL_ACTUATOR_CONTROLS](https://mavlink.io/en/messages/common.html#HIL_ACTUATOR_CONTROLS).
200-
1. The simulation waits until it receives the actuator/motor message, then simulates the physics and calculates the next sensor message to send to PX4 again.
195+
2. PX4 receives this and does one iteration of state estimation, controls, etc. and eventually sends an actuator message [HIL_ACTUATOR_CONTROLS](https://mavlink.io/en/messages/common.html#HIL_ACTUATOR_CONTROLS).
196+
3. The simulation waits until it receives the actuator/motor message, then simulates the physics and calculates the next sensor message to send to PX4 again.
201197

202198
The system starts with a "freewheeling" period where the simulation sends sensor messages including time and therefore runs PX4 until it has initialized and responds with an actuator message.
203199

@@ -217,11 +213,13 @@ To disable lockstep in:
217213

218214
## Extending and Customizing
219215

220-
To extend or customize the simulation interface, edit the files in the **Tools/jMAVSim** folder. The code can be accessed through the[jMAVSim repository](https://github.com/px4/jMAVSim) on Github.
216+
To extend or customize the simulation interface, edit the files in the **Tools/jMAVSim** folder.
217+
The code can be accessed through the[jMAVSim repository](https://github.com/px4/jMAVSim) on Github.
221218

222219
::: info
223220
The build system enforces the correct submodule to be checked out for all dependencies, including the simulator.
224-
It will not overwrite changes in files in the directory, however, when these changes are committed the submodule needs to be registered in the Firmware repo with the new commit hash. To do so, `git add Tools/jMAVSim` and commit the change.
221+
It will not overwrite changes in files in the directory, however, when these changes are committed the submodule needs to be registered in the Firmware repo with the new commit hash.
222+
To do so, `git add Tools/jMAVSim` and commit the change.
225223
This will update the GIT hash of the simulator.
226224
:::
227225

@@ -234,6 +232,75 @@ The simulation can be [interfaced to ROS](../simulation/ros_interface.md) the sa
234232
- The startup scripts are discussed in [System Startup](../concept/system_startup.md).
235233
- The simulated root file system ("`/`" directory) is created inside the build directory here: `build/px4_sitl_default/rootfs`.
236234

235+
## Display-Only Mode
236+
237+
jMAVSim can run as a display-only renderer for other simulators (like [SIH](../sim_sih/index.md)), with its internal physics disabled.
238+
In this mode, jMAVSim receives vehicle position via MAVLink and only renders the 3D view.
239+
240+
To use jMAVSim as a display for SIH running in SITL:
241+
242+
```sh
243+
# Start SIH first
244+
make px4_sitl_sih sihsim_quadx
245+
246+
# In another terminal, start jMAVSim in display-only mode
247+
./Tools/simulation/jmavsim/jmavsim_run.sh -p 19410 -u -q -o # 19410 is the default SIH display port
248+
```
249+
250+
For SIH running on flight controller hardware:
251+
252+
```sh
253+
./Tools/simulation/jmavsim/jmavsim_run.sh -q -d /dev/ttyACM0 -b 2000000 -o
254+
```
255+
256+
Use `-a` for airplane display or `-t` for tailsitter display.
257+
258+
## Command-Line Reference
259+
260+
The `jmavsim_run.sh` launch script accepts the following flags:
261+
262+
| Flag | Description |
263+
| ------------- | ------------------------------------------------ |
264+
| `-b <rate>` | Serial baud rate (default: 921600) |
265+
| `-d <device>` | Serial device path (e.g., `/dev/ttyACM0`) |
266+
| `-u` | Use UDP connection instead of serial |
267+
| `-i <id>` | Simulated MAVLink system ID |
268+
| `-p <port>` | UDP port (default: 14560) |
269+
| `-q` | No interactive console |
270+
| `-s <port>` | TCP serial port |
271+
| `-r <rate>` | Render rate in Hz |
272+
| `-l` | Enable lockstep |
273+
| `-o` | Display-only mode (disable physics, render only) |
274+
| `-a` | Use airplane model |
275+
| `-t` | Use tailsitter model |
276+
| `HEADLESS=1` | Environment variable: run without GUI window |
277+
278+
## How jMAVSim Works
279+
280+
jMAVSim is a Java-based lightweight simulator that communicates with PX4 via MAVLink HIL (Hardware-In-the-Loop) messages.
281+
282+
In normal mode:
283+
284+
1. PX4 sends actuator commands via [HIL_ACTUATOR_CONTROLS](https://mavlink.io/en/messages/common.html#HIL_ACTUATOR_CONTROLS).
285+
2. jMAVSim runs its physics engine to compute the vehicle state.
286+
3. jMAVSim sends sensor data back via [HIL_SENSOR](https://mavlink.io/en/messages/common.html#HIL_SENSOR) and [HIL_GPS](https://mavlink.io/en/messages/common.html#HIL_GPS).
287+
288+
In **display-only mode** (`-o` flag), jMAVSim disables its physics engine and only reads [HIL_STATE_QUATERNION](https://mavlink.io/en/messages/common.html#HIL_STATE_QUATERNION) messages to render the vehicle position.
289+
This allows it to visualize vehicles from other simulators like SIH.
290+
291+
jMAVSim supports [lockstep synchronization](#lockstep) with PX4 (enabled with `-l` flag), ensuring deterministic simulation results.
292+
293+
## Keyboard Shortcuts
294+
295+
Camera modes in the jMAVSim 3D view:
296+
297+
| Key | Camera Mode |
298+
| ------------- | ------------------------------------ |
299+
| **F** | First person (attached to vehicle) |
300+
| **S** | Stationary (fixed position) |
301+
| **G** | Gimbal (follows vehicle orientation) |
302+
| **(default)** | Third person follow |
303+
237304
## Troubleshooting
238305

239306
### java.long.NoClassDefFoundError
@@ -324,8 +391,8 @@ Exception in thread "main" java.lang.UnsupportedClassVersionError: me/drton/jmav
324391
This error is telling you, you need a more recent version of Java in your environment.
325392
Class file version 58 corresponds to jdk14, version 59 to jdk15, version 60 to jdk 16 etc.
326393
327-
To fix it under macOS, we recommend installing OpenJDK through homebrew
394+
To fix it under macOS, install a newer OpenJDK via Homebrew:
328395
329396
```sh
330-
brew install --cask adoptopenjdk16
397+
brew install openjdk@17
331398
```

0 commit comments

Comments
 (0)