Body reference system and navigation reference system

Hi,
I’m implementing a new flight mode for vision-based autonomous landing of a quadrotor.
The autonomous landing flight mode is based on a camera. The camera is able to detect a predefined marker and estimate the x,y,z position of the quadrotor with respect to the center of the marker.

The (x,y,z) coordinates provided by the camera are expressed in the following reference frame:

  • x front
  • y left
    -z down

I’m trying to use those information to move the quadrotor and making it hovering above the marker autonomously.

You can see the implementation of the new flight mode at https://github.com/alessandro-benini/ardupilot/blob/master/ArduCopter/control_vision_land.cpp

Before using the vision data, I convert them to the NED frame using the yaw measurement provided by the internal ahrs (rows 95 and 96).

Then I call a modified version of the update_xy_controller in order to calculate the roll and pitch targets.

The modified version of update_xy_controller (called __update_xy_controller) can be seen at https://github.com/alessandro-benini/ardupilot/blob/master/libraries/AC_AttitudeControl/AC_PosControl.cpp (row 763)

After that, I call the input_euler_angle_roll_pitch_euler_rate_yaw_smooth controller to apply the roll and pitch target.

For some reason if I switch to the new flight mode when the quadrotor is hovering above the marker, the new flight mode, instead of correcting the error and move the quad above the center of the marker, push the quad away.

It seems a problem with the signs, but I double checked and everything is fine.

Now the questions:
What is the body reference frame of the pixhawk?
What is the navigation frame used by the class AC_PosControl?