offboard里的期望姿态

消息体头文件:mavros_msgs/AttitudeTarget.h
里面的内容:

# Message for SET_ATTITUDE_TARGET
#
# Some complex system requires all feautures that mavlink
# message provide. See issue #402, #418.

std_msgs/Header header

uint8 type_mask
uint8 IGNORE_ROLL_RATE = 1 # body_rate.x
uint8 IGNORE_PITCH_RATE = 2 # body_rate.y
uint8 IGNORE_YAW_RATE = 4 # body_rate.z
uint8 IGNORE_THRUST = 64
uint8 IGNORE_ATTITUDE = 128 # orientation field

geometry_msgs/Quaternion orientation
geometry_msgs/Vector3 body_rate
float32 thrust

所以我们发布期望姿态时,一般要去初始化里面的orientation这个对象。这个对象的内容为:

float64 x
float64 y
float64 z
float64 w

说明:四元数里的q0,q1,q2,q3对应里面的w,x,y,z,这里要十分注意。然后根据欧拉角转四元数公式根据目标姿态求出所需要的四元数。然后赋值给x,y,z,w.

比如:

    targetattitude.orientation.x = 0;
    targetattitude.orientation.y = 0;
    targetattitude.orientation.z = 0.7071;
    targetattitude.orientation.w = 0.7071;
    targetattitude.thrust = 0.6;//推力占比

你可能感兴趣的:(offboard)