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 6 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 not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 26 additions & 8 deletions en/assembly/mount_gps_compass.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
# Mounting the GPS/Compass
# Mounting a GPS/Compass

GPS/Compasses should be mounted on the frame as far away from other electronics as possible, with the direction marker pointing towards the front of the vehicle.
If mounted in this way you can immediately proceed to [compass calibration](../config/compass.md#performing-the-calibration).

The GPS/Compass should be mounted on the frame as far away from other electronics as possible, with the direction marker pointing towards the front of the vehicle.
The diagram below shows the heading marker on the Pixhawk 4 and compass.

![Connect compass/GPS to Pixhawk 4](../../assets/flight_controller/pixhawk4/pixhawk4_compass_gps.jpg)

## 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 be mounted in any of the standard MAVLink orientations defined in [MAV_SENSOR_ORIENTATION](https://mavlink.io/en/messages/common.html#MAV_SENSOR_ORIENTATION).
The orientation follows the same frame convention as when [orienting the flight controller](../config/flight_controller_orientation.md#orientation-definition).

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.
If you're using the normal [Compass Calibration](../config/compass.md) process (with parameter [CAL_MAG_ROT_AUTO](../advanced_config/parameter_reference.md#CAL_MAG_ROT_AUTO) enabled), the orientation should be detected automatically.
Otherwise you can directly select the appropriate value in [CAL_MAGn_ROT](../advanced_config/parameter_reference.md#CAL_MAG1_ROT) for up to three compasses.

:::warning
You must mount the compass in a supported orientation!
If your compass can't be oriented in any of the standard orientations, you can use a [custom rotation](#custom_orientation) as 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
PX4 will automatically (by default) detect the closest _standard_ orientation if you perform a normal calibration.
If the orientation is not one of the standard values (for example `Yaw 30`) the calibration will be inaccurate even if it appears to succeed.
This can result in errors, warnings, and poor flight performance.
:::

### Custom Orientation

You can use a custom orientation by first selecting `Custom Euler Angle` in `CAL_MAGn_ROT` for your magnetometer.
You can then set any rotation using the [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 a custom orientation and calibrate the compass:

1. Set the [CAL_MAGn_ROT](../advanced_config/parameter_reference.md#CAL_MAG1_ROT) parameter to `Custom Euler Angle`
2. Set the magnetometer's correct custom roll/pitch/yaw
3. Follow the [compass calibration procedure](../config/compass.md#performing-the-calibration)
25 changes: 15 additions & 10 deletions en/config/flight_controller_orientation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
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

You can use this tool for visualizing the Euler angles : https://compsci290-s2016.github.io/CoursePage/Materials/EulerAnglesViz/

![Frame Heading](../../assets/concepts/frame_heading.png)

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

<img src="../../assets/qgc/setup/sensor/fc_orientation_1.png" style="width: 600px;"/>
This roll-pitch-yaw sequence is also known as [extrinsic rotation](https://en.wikipedia.org/wiki/Euler_angles#Conventions_by_extrinsic_rotations).

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 +26,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