Josua B
Josua B

Reputation: 71

Exact Return Values of "Attitude" and "Velocity" In Dronekit API

I have perused the Dronekit-Python API Reference thoroughly and before I continue with my Masters Engineering project I need some more information. I am using a Raspberry-Pi 2B as a companion computer with the Pixhawk Flight Controller to obtain certain information about the copter at a specific time instance. I need some more information on the return structure and returned values of certain calls in the Dronekit-Python API.

First and foremost I can only work with Euler angles, and if "class dronekit.Attitude" does not return Euler angles, I would like to know what is the easiest way to get the current attitude of the copter in Euler angles (in order of Yaw-Pitch-Roll) from the Pixhawk Flight Controller.

Secondly I would like to know in what axes/reference frame the velocity vector is returned in. Is it relatively to the fixed body axes of the copter or relative so some starting position in the North-East-Down coordinate system. I would also like to know how the velocity vector is obtained, is it solely based on GPS and pressure sensor measurements, or is it a fusion of all the on-board sensors including the IMU. This will greatly influence the accuracy of the Velocity vector which will incorporate a lot of uncertainty into my UKF.

Upvotes: 2

Views: 1309

Answers (1)

epinal
epinal

Reputation: 1465

Attitude is returned in radians. Here I'll show you a code I used to convert from radians to degrees. Just change the conversion constant to radians to euler conversion.

Let's assume you are inside a vehicle class.

# Attitude attribute listener. 
# This will call attitude_callback every time the attitude changes
self.add_attribute_listener('attitude', self.attitude_callback)

def attitude_callback(self, *args):
    attitude = args[2]
    if attitude is not None:
        # degrees = radians * 180 / pi
        # CHANGE TO CONVERT FROM RADIANS TO EULER HERE 
        const = 180 / pi
        pitch = attitude.pitch * const
        yaw = attitude.yaw * const
        roll = attitude.roll * const
        self.horizon = (int(pitch), int(roll), int(yaw))

Velocity gives you [velocity_x, velocity_y, velocity_z].

  • velocity_x, # X velocity in NED frame in m/s
  • velocity_y, # Y velocity in NED frame in m/s
  • velocity_z, # Z velocity in NED frame in m/s

To understand how it works you need to understand first how NED frame works. Take a look at send_ned_velocity() in:

http://python.dronekit.io/examples/guided-set-speed-yaw-demo.html#example-guided-mode-send-global-velocity

Upvotes: 2

Related Questions