Flight Review: angles estimated are wrong for tailsitter in FW mode?

Problem is for Roll, Pitch, Yaw angles estimated in FW mode (after the transition).

  1. They don’t match the setpoints. PX is not trying to catch the setpoints according to logs, that means that the angles inside PX are calculated differently.
  2. They are not what we observed in reality. When the flight is horizontal and pitch is -45° that just can’t be true. Roll and Yaw are less obvious, but they don’t match also.

Here are our logs that show the inconsistence:
https://logs.px4.io/plot_app?log=a5aac0ad-2acc-447f-922f-a20f36eae74a
https://logs.px4.io/plot_app?log=e04721a9-d9f8-4fb6-9494-74f060d2b8b7
https://logs.px4.io/plot_app?log=ece418ed-ae74-4525-ad3e-95f992696b2e

Also I found a log for other tailsitter here on this forum that shows the same problem:
https://logs.px4.io/plot_app?log=5b0a9781-4648-41d9-bd04-e246819571ea

We have calculated a transformation to get real angles (python):

import numpy as np
from helper import get_log, plotting, at_times
from scipy.spatial.transform import Rotation as R

def tailsitter_adapt(R: np.ndarray):
    r = np.zeros_like(R)
    r[:, :, 0] = -R[:, :, 2]
    r[:, :, 2] = R[:, :, 0]
    r[:, :, 1] = R[:, :, 1]
    return r

def rpy_to_fw(roll, pitch, yaw):
    angles = np.array([roll, pitch, yaw]).T
    mat = R.from_euler("xyz", angles).as_matrix()
    mat_fw = tailsitter_adapt(mat)
    rpy_fw = R.from_matrix(mat_fw).as_euler("xyz")
    r = rpy_fw[:, 0]
    p = rpy_fw[:, 1]
    y = rpy_fw[:, 2]
    return r, p, y

log = get_log("https://logs.px4.io/plot_app?log=ece418ed-ae74-4525-ad3e-95f992696b2e")
v_att = log.topic("vehicle_attitude").data
roll_fw, pitch_fw, yaw_fw = rpy_to_fw(v_att["roll"], v_att["pitch"], v_att["yaw"])

Can you please fix the angles in Flight Review for tailsitters?

Comarison for roll


Comarison for pitch


For further simplification, to calculate angles properly for FW mode we just need to process quaternions from log with the following formula:
Q0, Q1, Q2, Q3 = np.sqrt(0.5)*(q[0]-q[2]), np.sqrt(0.5)*(q[1]-q[3]), np.sqrt(0.5)*(q[0]+q[2]), np.sqrt(0.5)*(q[3]+q[1])
where q* are vehicle_attitude/q.* from original log file
and then use Q* for plot like we used our q*.

Hi, did you consider already making a PR against flight review to address it there directly? GitHub - PX4/flight_review: web application for flight log analysis & review

1 Like