Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added x500_lidar model #3296

Merged
merged 6 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/simulation/gazebo/vehicles/advanced_plane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/simulation/gazebo/vehicles/rc_cessna.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/simulation/gazebo/vehicles/standard_vtol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/simulation/gazebo/vehicles/x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/simulation/gazebo/vehicles/x500_depth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/simulation/gazebo/vehicles/x500_lidar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 18 additions & 19 deletions en/computer_vision/collision_prevention.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ Configure collision prevention by [setting the following parameters](../advanced
| <a id="CP_GO_NO_DATA"></a>[CP_GO_NO_DATA](../advanced_config/parameter_reference.md#CP_GO_NO_DATA) | Set to 1 to allow the vehicle to move in directions where there is no sensor coverage (default is 0/`False`). |
| <a id="MPC_POS_MODE"></a>[MPC_POS_MODE](../advanced_config/parameter_reference.md#MPC_POS_MODE) | Set to 0 or 3 to enable Collision Prevention in Position Mode (default is 4). |

<a id="algorithm"></a>

## Algorithm Description

The data from all sensors are fused into an internal representation of 36 sectors around the vehicle, each containing either the sensor data and information about when it was last observed, or an indication that no data for the sector was available.
Expand All @@ -71,8 +69,6 @@ This should be [tuned](#delay_tuning) to the specific vehicle.
If the sectors adjacent to the commanded sectors are 'better' by a significant margin, the direction of the requested input can be modified by up to the angle specified in [CP_GUIDE_ANG](#CP_GUIDE_ANG).
This helps to fine-tune user input to 'guide' the vehicle around obstacles rather than getting stuck against them.

<a id="data_loss"></a>

### Range Data Loss

If the autopilot does not receive range data from any sensor for longer than 0.5s, it will output a warning _No range data received, no movement allowed_.
Expand All @@ -88,9 +84,7 @@ Be careful when enabling [CP_GO_NO_DATA=1](#CP_GO_NO_DATA), which allows the veh
If you lose connection to one of multiple sensors, the area covered by the faulty sensor is also treated as uncovered and you will be able to move there without constraint.
:::

<a id="delay_tuning"></a>

### CP_DELAY Delay Tuning
### CP_DELAY Delay Tuning {#delay_tuning}

There are two main sources of delay which should be accounted for: _sensor delay_, and vehicle _velocity setpoint tracking delay_.
Both sources of delay are tuned using the [CP_DELAY](#CP_DELAY) parameter.
Expand All @@ -106,9 +100,7 @@ The tracking delay is typically between 0.1 and 0.5 seconds, depending on vehicl
If vehicle speed oscillates as it approaches the obstacle (i.e. it slows down, speeds up, slows down) the delay is set too high.
:::

<a id="angle_change_tuning"></a>

### CP_GUIDE_ANG Guidance Tuning
### CP_GUIDE_ANG Guidance Tuning {#angle_change_tuning}

Depending on the vehicle, type of environment and pilot skill different amounts of guidance may be desired.
Setting the [CP_GUIDE_ANG](#CP_GUIDE_ANG) parameter to 0 will disable the guidance, resulting in the vehicle only moving exactly in the directions commanded.
Expand All @@ -123,9 +115,7 @@ The guidance feature will never direct the vehicle in a direction without sensor
If the vehicle feels 'stuck' with only a single distance sensor pointing forwards, this is probably because the guidance cannot safely adapt the direction due to lack of information.
:::

<a id="rangefinder"></a>

## PX4 Distance Sensor
## PX4 Distance Sensor {#rangefinder}

### Lanbao PSK-CM8JL65-CC5

Expand Down Expand Up @@ -176,9 +166,7 @@ You can see the required modifications from the [feature PR](https://github.com/
Please contribute back your changes!
:::

<a id="companion"></a>

## Companion Setup
## Companion Setup {#companion}

If using a companion computer or external sensor, it needs to supply a stream of [OBSTACLE_DISTANCE](https://mavlink.io/en/messages/common.html#OBSTACLE_DISTANCE) messages, which should reflect when and where obstacle were detected.

Expand All @@ -197,10 +185,21 @@ For more information on hardware and software setup see: [PX4/PX4-Avoidance > Ru
The hardware and software should be set up as described in the [PX4/PX4-Avoidance](https://github.com/PX4/PX4-Avoidance) repo.
In order to emit `OBSTACLE_DISTANCE` messages you must use the _rqt_reconfigure_ tool and set the parameter `send_obstacles_fcu` to true.

## Gazebo Setup
## Gazebo Simulation

_Collision Prevention_ can be tested using [Gazebo](../sim_gazebo_gz/index.md) with the [x500_lidar](../sim_gazebo_gz/vehicles.md#x500-quadrotor-with-2d-lidar) model.
To do this, start a simulation with the x500 lidar model by running the following command:

```sh
make px4_sitl gz_x500_lidar
```

Next, adjust the relevant parameters to the appropriate values and add arbitrary obstacles to your simulation world to test the collision prevention functionality.

The diagram below shows how the simulation looks when viewed in RViz.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually its Gazebo and not RViz 😅

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks @Claudio-Chies, I'll fix - didn't know you could get the sensor view like that. BTW, do you know much about prearm conditions on collision prevention - got a bug PX4/PX4-Autopilot#22994 and from my comment to that you can see a linked (current) discussion board post.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

puh, for Collision Prevention, i think you just have to have a obstacle_distance message present. but in the issue he's talking about avoidance, and there its handeled differently from what i know. as it has to wait for the onbaord computer to be ready

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, we should probably document that :-). So to be clear, the implication is that you need a component that is sending a HEARTBEAT and has type https://mavlink.io/en/messages/common.html#MAV_TYPE_ONBOARD_CONTROLLER right?

Copy link
Collaborator

@hamishwillee hamishwillee Aug 8, 2024

Choose a reason for hiding this comment

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

Ignore that, I can see the code

			case MAV_COMP_ID_OBSTACLE_AVOIDANCE:
				_heartbeat_component_obstacle_avoidance = now;
				_mavlink->telemetry_status().avoidance_system_healthy = (hb.system_status == MAV_STATE_ACTIVE);
				break;

Incorrect in that it relies on the companion computer component ID rather than mavlink type

Anyway, added a docs fix in #3340 to make it easier for people to search on the arm failure and find this information.,


_Collision Prevention_ can also be tested using Gazebo.
See [PX4/PX4-Avoidance](https://github.com/PX4/PX4-Avoidance) for setup instructions.
![RViz image of collision detection using the x500_lidar model in Gazebo](../../assets/simulation/gazebo/vehicles/x500_lidar_viz.png)

<!-- PR companion collision prevention (initial): https://github.com/PX4/PX4-Autopilot/pull/10785 -->
<!-- PR for FC sensor collision prevention: https://github.com/PX4/PX4-Autopilot/pull/12179 -->
<!-- using rangefinder? -->
Claudio-Chies marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 3 additions & 1 deletion en/releases/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ Please continue reading for [upgrade instructions](#upgrade-guide).

### Simulation

- The SIH on SITL [custom takeoff location](../sim_sih/index.md#set-custom-takeoff-location) in now set using the normal unscaled GPS position values, where previously the value needed to be multiplied by 1E7.
- [SIH]: The SIH on SITL [custom takeoff location](../sim_sih/index.md#set-custom-takeoff-location) in now set using the normal unscaled GPS position values, where previously the value needed to be multiplied by 1E7.
([PX4-Autopilot#23363](https://github.com/PX4/PX4-Autopilot/pull/23363)).
- [Gazebo]: New vehicle model `x500_lidar` — [x500 Quadrotor with 2D Lidar](../sim_gazebo_gz/vehicles.md#x500-quadrotor-with-2d-lidar).
([PX4-Autopilot#22418](https://github.com/PX4/PX4-Autopilot/pull/22418), [PX4-gazebo-models#41](https://github.com/PX4/PX4-gazebo-models/pull/41)).

### Ethernet

Expand Down
14 changes: 10 additions & 4 deletions en/sensor/rangefinders.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Distance sensors provide distance measurement that can be used for [terrain following](../flying/terrain_following_holding.md#terrain_following), [terrain holding](../flying/terrain_following_holding.md#terrain_hold) (i.e. precision hovering for photography), improved landing behaviour ([conditional range aid](../advanced_config/tuning_the_ecl_ekf.md#conditional-range-aiding)), warning of regulatory height limits, collision prevention, etc.

This section lists the distance sensors supported by PX4 (linked to more detailed documentation), the [generic configuration](#configuration) required for all rangefinders, [testing](#testing), and [Gazebo-Classic simulation](#gazebo-classic-simulation) information.
This section lists the distance sensors supported by PX4 (linked to more detailed documentation), and provides information about the [generic configuration](#configuration) required for all rangefinders, [testing](#testing), and simulation with [Gazebo](#gazebo-simulation) or [Gazebo-Classic](#gazebo-classic-simulation).
More detailed setup and configuration information is provided in the topics linked below (and sidebar).

<img src="../../assets/hardware/sensors/lidar_lite/lidar_lite_v3.jpg" alt="Lidar Lite V3" width="200px" /><img src="../../assets/hardware/sensors/lidar_lightware/sf11c_120_m.jpg" alt="LightWare SF11/C Lidar" width="200px" /><img src="../../assets/hardware/sensors/optical_flow/ark_flow_distance_sensor.jpg" alt="ARK Flow" width="200px">
Expand Down Expand Up @@ -99,9 +99,7 @@ Features:
- Input voltage sensor
- CAN connectors: 2 [UCANPHY Micro (JST-GH 4)](https://raccoonlabdev.github.io/docs/guide/wires/).

<a id="configuration"></a>

## Configuration/Setup
## Configuration/Setup {#configuration}

Rangefinders are usually connected to either a serial (PWM) or I2C port (depending on the device driver), and are enabled on the port by setting a particular parameter.

Expand Down Expand Up @@ -161,6 +159,14 @@ On the Simulator you can run the commands directly in the terminal.

For more information see: [Development > Debugging/Logging > Sensor/Topic Debugging using the Listener Command](../debug/sensor_uorb_topic_debugging.md).

## Gazebo Simulation

Rangefinders use cases such as terrain following cannot be used for testing in the [Gazebo](../sim_gazebo_gz/index.md) simulator (at time of writing), because none of the [vehicle models](../sim_gazebo_gz/vehicles.md) include sensors that write to the [DistanceSensor](../msg_docs/DistanceSensor.md) UORB topic.

::: info
The [x500 lidar model](../sim_gazebo_gz/vehicles.md#x500-quadrotor-with-2d-lidar) includes a 2D Lidar rangefinder that can be used for testing [Collision Prevention](../computer_vision/collision_prevention.md#gazebo-simulation)
:::

## Gazebo-Classic Simulation

Lidar and sonar rangefinders can be used in the [Gazebo Classic](../sim_gazebo_classic/index.md) simulator.
Expand Down
1 change: 1 addition & 0 deletions en/sim_gazebo_gz/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Note that all gazebo make targets have the prefix `gz_`.
| [Quadrotor(x500)](../sim_gazebo_gz/vehicles.md#x500-quadrotor) | `make px4_sitl gz_x500` | 4001 |
| [Quadrotor(x500) with Depth Camera](../sim_gazebo_gz/vehicles.md#x500-quadrotor-with-depth-camera) | `make px4_sitl gz_x500_depth` | 4002 |
| [Quadrotor(x500) with Vision Odometry](../sim_gazebo_gz/vehicles.md#x500-quadrotor-with-visual-odometry) | `make px4_sitl gz_x500_vision` | 4005 |
| [Quadrotor(x500) with 2D LIDAR](../sim_gazebo_gz/vehicles.md#x500-quadrotor-with-2d-lidar) | `make px4_sitl gz_x500_lidar` | 4013 |
| [VTOL](../sim_gazebo_gz/vehicles.md#standard-vtol) | `make px4_sitl gz_standard_vtol` | 4004 |
| [Plane](../sim_gazebo_gz/vehicles.md#standard-plane) | `make px4_sitl gz_rc_cessna` | 4003 |
| [Advanced Plane](../sim_gazebo_gz/vehicles.md#advanced-plane) | `make px4_sitl gz_advanced_plane` | 4008 |
Expand Down
18 changes: 17 additions & 1 deletion en/sim_gazebo_gz/vehicles.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ make px4_sitl gz_x500_depth

### X500 Quadrotor with Monocular Camera

This models has a simple monocular camera sensor attached (there is no physical camera visualization on the model itself).
This model has a simple monocular camera sensor attached (there is no physical camera visualization on the model itself).

```sh
make px4_sitl gz_x500_mono_cam
Expand All @@ -52,6 +52,22 @@ The camera cannot yet be used to stream video or for image capture in QGroundCon
[PX4-Autopilot#22563](https://github.com/PX4/PX4-Autopilot/issues/22563) can be used to track the additional work needed to fully enable these use cases.
:::

### X500 Quadrotor with 2D LIDAR

This model have a 2D LIDAR attached, modelled on the Hokuyo UTM-30LX.
It has a range between 0.1 and 30m, and scans in a 270° arc.
The model can be used for testing [Collision Prevention](../computer_vision/collision_prevention.md#gazebo-simulation).

```sh
make px4_sitl gz_x500_lidar
```

![x500 with 2D LIDAR in Gazebo](../../assets/simulation/gazebo/vehicles/x500_lidar.png)

::: info
The model cannot be used for testing normal [rangefinder](../sensor/rangefinders.md#gazebo-simulation) use cases, such as terrain following, as the information is not written to the [DistanceSensor](../msg_docs/DistanceSensor.md) topic (it is written to the [ObstacleDistance](../msg_docs/ObstacleDistance.md) UORB message used by collision prevention).
:::

## Plane/Fixed-wing

### Standard Plane
Expand Down
Loading