Skip to content

Mounting a Compass (or GNSS/Compass)

Compass and GNSS/Compass modules should be mounted on the frame as far away from motor/ESC power lines and other sources of electromagnetic interference as possible, and oriented upright with the direction marker pointing towards the front of the vehicle. You should also configure PX4 to set the position of the receiver relative to the centre-of-gravity (CoG).

On multicopters it is common to mount the compass on a pedestal, while for fixed-wing and VTOL vehicles the compass is usually mounted on a wing.

Compass Orientation

The compass should ideally be oriented so that it is upright and the direction marker is pointing towards the front of the vehicle (the default orientation), but if needed can be oriented at multiples of 45° from this attitude (in any axis) as defined in the standard MAVLink orientations (these follow the same frame convention as when orienting the flight controller).

The diagram below shows the heading marker on the Pixhawk 4 flight controller and compass.

Connect compass/GPS to Pixhawk 4

PX4 will automatically detect the orientation for any of these standard orientations during compass calibration (by default).

The compass can also be mounted at any other "custom euler angles", but in this case you will need to manually configure the orientations. For more information see Setting the Compass Orientation in Flight Controller/Sensor Orientation.


In order to compensate for the relative motion between the receiver and the CoG, you should configure the following parameters to set the offsets: EKF2_GPS_POS_X, EKF2_GPS_POS_Y and EKF2_GPS_POS_Z.

This is important because the body frame estimated by the EKF will converge on the location of the GNSS module and assume it to be at the CoG. If the GNSS module is significantly offset from the CoG, then rotation around the COG will be interpreted as an altitude change, which in some flight modes (such as position mode) will result in unnecessary corrections.

It is particularly important if using RTK GNSS which has centimeter-level accuracy, because if the offsets are not set then GNSS measurements will often be rejected as inconsistent with the current EFK estimate.


For example, if the GNSS module is 10cm above the CoG, and the IMU is located at the GoG, a pitch motion of 1 rad/s will create a GNSS velocity measurement of 10cm/s even though the CoG isn't moving. If the speed accuracy of the GNSS receiver is 1cm/s, the EKF might stop trusting the measurements because they appear inconsistent (wrong by 10x the accuracy). If the offsets are defined, the EKF will correct the measurements using the gyro data.