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

[Pending] Add custom magnetometer orienation documentation #2135

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion en/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* [Basic Configuration](config/README.md)
* [Firmware](config/firmware.md)
* [Airframe](config/airframe.md)
* [Sensor Orientation](config/flight_controller_orientation.md)
* [Orientation](config/flight_controller_orientation.md)
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
* [Compass](config/compass.md)
* [Gyroscope](config/gyroscope.md)
* [Accelerometer](config/accelerometer.md)
Expand Down
22 changes: 17 additions & 5 deletions en/assembly/mount_gps_compass.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,25 @@ The diagram below shows the heading marker on the Pixhawk 4 and compass.

## Compass Orientation

The compass can also be mounted in any other _supported_ orientation, where the supported orientations can be seen in [CAL_MAGn_ROT](../advanced_config/parameter_reference.md#CAL_MAG1_ROT), and have the same meaning as used for [orienting the flight controller](../config/flight_controller_orientation.md#calculating-orientation).
The compass can also be mounted in any _supported_ orientation, where the supported orientations can be seen in [CAL_MAGn_ROT](../advanced_config/parameter_reference.md#CAL_MAG1_ROT), and uses the same convention for [orienting the flight controller](../config/flight_controller_orientation.md#orientation-definition).
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved

If you're using the normal [Compass Calibration](../config/compass.md) process the parameter [CAL_MAG_ROT_AUTO](../advanced_config/parameter_reference.md#CAL_MAG_ROT_AUTO) is enabled, and the orientation should be detected automatically.

:::warning
You must mount the compass in a supported orientation!
If your compass can't be oriented in any of the supported orientations, you can utilize `Custom rotation`, which is documented below.
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved

If you mount the compass at an orientation that isn't supported, for example `Yaw 30`, PX4 will detect the closest supported value.
This will result in errors/warnings, even if the calibration appeared to succeed.
:::warning
If you mount the compass at an orientation that isn't supported, for example `Yaw 30`, PX4 will detect the closest supported value. This will result in errors/warnings, even if the calibration appeared to succeed.
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
:::

### Custom magnetometer orientation

By selecting the `Custom Euler Angle` in the orientation setting for your magnetometer, you can specify any rotation using [CAL_MAGn_ROLL](../advanced_config/parameter_reference.md#CAL_MAG1_ROLL), [CAL_MAGn_PITCH](../advanced_config/parameter_reference.md#CAL_MAG1_PITCH) and [CAL_MAGn_YAW](../advanced_config/parameter_reference.md#CAL_MAG1_YAW) parameters.

The roll/pitch/yaw are defined as documented [here](../config/flight_controller_orientation.md#orientation-definition).

To configure the custom orientation correctly, do the following:
1. Set the [CAL_MAGn_ROT](../advanced_config/parameter_reference.md#CAL_MAG1_ROT) parameter to `Custom Euler Angle`
2. Set the magnetometer's custom roll/pitch/yaw appropriately
3. Follow the [compass calibration procedure](../config/compass.md#performing-the-calibration)

After this, you should have a calibrated magnetometer with a custom specified rotation.
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved
27 changes: 15 additions & 12 deletions en/config/flight_controller_orientation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
By default the flight controller (and external compass(es), if present) should be placed on the frame top-side up, oriented so that the arrow points towards the front of the vehicle.
If the board or an external compass are mounted in any other orientation then you will need configure this in the firmware.

## Calculating Orientation
## Orientation definition
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved

ROLL, PITCH and/or YAW offsets of the flight controller are calculated relative to the vehicle around the forward (x), right (y), down (z) axes.
ROLL, PITCH and/or YAW for flight controller and sensors are calculated relative to the vehicle's forward (x), right (y), down (z) axes.
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved

![Frame Heading](../../assets/concepts/frame_heading.png)
You can use this tool for visualizing the Euler angles : https://compsci290-s2016.github.io/CoursePage/Materials/EulerAnglesViz/

The axes to rotate around stay the same from one rotation step to the next one.
So the frame to perform the rotation in stays fixed.
This is also known as *extrinsic rotation*.
![Frame Heading](../../assets/concepts/frame_heading.png)

<img src="../../assets/qgc/setup/sensor/fc_orientation_1.png" style="width: 600px;"/>
The axes to rotate around stay the same from one rotation step to the next one. So the frame to perform the rotation in stays fixed. This is also known as "**extrinsic rotation**(roll-pitch-yaw sequence)". Read more about it in [this article](https://en.wikipedia.org/wiki/Euler_angles#Conventions_by_extrinsic_rotations).
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved

For example, the vehicles shown below have rotations around the z-axis (i.e. yaw only) corresponding to: `ROTATION_NONE`, `ROTATION_YAW_90`,`ROTATION_YAW_180`,`ROTATION_YAW_270`.

Expand All @@ -26,16 +24,21 @@ The axis are normally relative to the orientation of the vehicle during steady f
For more information see [Basic Concepts](../getting_started/px4_basic_concepts.md#heading-and-directions).
:::

### Supported rotations

PX4 supports the rotations defined by the MAVLink's [MAV_SENSOR_ORIENTATION](https://mavlink.io/en/messages/common.html#MAV_SENSOR_ORIENTATION) enumerator.
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved

Note that a custom rotation is also available for a magnetometer if it is not mounted in one of the supported rotation configurations. For this, please refer to [Setting a custom rotation](../assembly/mount_gps_compass.md#custom-magnetometer-orientation) chapter of the Magnetometer mounting documentation.
hamishwillee marked this conversation as resolved.
Show resolved Hide resolved

## Setting the Orientation

To set the orientations:
To set the orientations for the flight controller/magnetometer:

1. Start *QGroundControl* and connect the vehicle.
1. Select the **Gear** icon (Vehicle Setup) in the top toolbar and then **Sensors** in the sidebar.
1. Select the **Set Orientations** button.
<img src="../../assets/qgc/setup/sensor/sensor_orientation_set_orientations.jpg" style="width: 600px;"/>
1. Select the **AutoPilot Orientation** (as [calculated above](#calculating-orientation)).

1. Select the **Orientations** button.
<img src="../../assets/qgc/setup/sensor/sensor_orientation_set_orientations.png" style="width: 600px;"/>
1. Select the **AutoPilot Orientation** (as [calculated above](#orientation-definition)).
<img src="../../assets/qgc/setup/sensor/sensor_orientation_selector_values.jpg" style="width: 200px;"/>
1. Select the **External Compass Orientation** in the same way (this option will only be displayed if your vehicle has an external compass).
1. Press **OK**.
Expand Down
2 changes: 1 addition & 1 deletion en/gps_compass/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ When using GPS for yaw fusion you will need to configure the following parameter

Parameter | Setting
--- | ---
[GPS_YAW_OFFSET](../advanced_config/parameter_reference.md#GPS_YAW_OFFSET) | The angle made by the *baseline* (the line between the two GPS antennas) relative to the vehicle x-axis (front/back axis, as shown [here](../config/flight_controller_orientation.md#calculating-orientation)).
[GPS_YAW_OFFSET](../advanced_config/parameter_reference.md#GPS_YAW_OFFSET) | The angle made by the *baseline* (the line between the two GPS antennas) relative to the vehicle x-axis (front/back axis, as shown [here](../config/flight_controller_orientation.md#orientation-definition)).
[EKF2_GPS_CTRL](../advanced_config/parameter_reference.md#EKF2_GPS_CTRL) | Set bit position 3 "Dual antenna heading" to `1` (i.e. add 8 to the parameter value).


Expand Down
2 changes: 1 addition & 1 deletion en/gps_compass/rtk_gps_trimble_mb_two.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ For heading estimation the two antennas need to be on the same level and at leas
The direction that they are facing does not matter as it can be configured with the [GPS_YAW_OFFSET](../advanced_config/parameter_reference.md#GPS_YAW_OFFSET) parameter.

:::note
The `GPS_YAW_OFFSET` is the angle made by the *baseline* (the line between the two GPS antennas) relative to the vehicle x-axis (front/back axis, as shown [here](../config/flight_controller_orientation.md#calculating-orientation)).
The `GPS_YAW_OFFSET` is the angle made by the *baseline* (the line between the two GPS antennas) relative to the vehicle x-axis (front/back axis, as shown [here](../config/flight_controller_orientation.md#orientation-definition)).
:::

[Configure the serial port](../peripherals/serial_configuration.md) on which the Trimple will run using [GPS_1_CONFIG](../advanced_config/parameter_reference.md#GPS_1_CONFIG), and set the baud rate to 115200 using [SER_GPS1_BAUD](../advanced_config/parameter_reference.md#SER_GPS1_BAUD).
Expand Down