I’m operating the drone using the SET_ATTITUDE_TARGET command, wherein I input the Attitude quaternion. However, I’ve observed that when the yaw changes and I extract yaw values from the Attitude at 40Hz to incorporate them into the quaternion, there’s a notable increase in oscillations over time.
Currently, I’m attempting to control pitch and roll through quaternions while managing yaw with the body_yaw_rate. Despite this approach, it appears that the drone is not responding to the body rate adjustments and instead drifts towards a yaw angle of zero. MAV_FRAME_LOCAL_NED
time_boot_ms
uint32_t
ms
Timestamp (time since system boot).
target_system
uint8_t
System ID
target_component
uint8_t
Component ID
type_mask
uint8_t
ATTITUDE_TARGET_TYPEMASK
Bitmap to indicate which dimensions should be ignored by the vehicle.
q
float[4]
Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0) from MAV_FRAME_LOCAL_NED to MAV_FRAME_BODY_FRD
body_roll_rate
float
rad/s
Body roll rate
body_pitch_rate
float
rad/s
Body pitch rate
body_yaw_rate
float
rad/s
Body yaw rate
thrust
float
Collective thrust, normalized to 0 … 1 (-1 … 1 for vehicles capable of reverse trust)
thrust_body **
float[3]
3D thrust setpoint in the body NED frame, normalized to -1 … 1
I have tryed setting up the bitmask 0b00000011, which is 3 accoridng the list below, but there is no effect. I am currently working with GUIDED mode, expecing to support GUIDED_noGPS
Please clarify if my understanding is accurate. Can I directly control movement using body rate? Alternatively, does it involve setting a yaw target angle in quaternion and controlling the yaw rate to determine the speed at which I reach that yaw target angle?
// Sets guided's angular target submode: Using a rotation quaternion, angular velocity, and climbrate or thrust (depends on user option)
// attitude_quat: IF zero: ang_vel (angular velocity) must be provided even if all zeroes
// IF non-zero: attitude_control is performed using both the attitude quaternion and angular velocity
// ang_vel: angular velocity (rad/s)
// climb_rate_cms_or_thrust: represents either the climb_rate (cm/s) or thrust scaled from [0, 1], unitless
// use_thrust: IF true: climb_rate_cms_or_thrust represents thrust
// IF false: climb_rate_cms_or_thrust represents climb_rate (cm/s)
void set_angle(const Quaternion &attitude_quat, const Vector3f &ang_vel, float climb_rate_cms_or_thrust, bool use_thrust);
All I know is that you can control attitude accurately and quickly by requesting a specific yaw/roll/pitch. I am not using quaternions or rates alas. When I do set a particular pitch or whatever, the drone is very quick to respond.
Also, you must always set the throttle otherwise the command will do nothing. Don’t ask me why!
I am of course using quaternions because you have to, but I am first converting Euler angles to quaternions using a clone of the Arducopter ToQuaternion() function. I have these fields also set in the message: