建议开发者将姿态控制命令以50Hz的频率发送,用户可根据自己的开发环境通过如usleep(20000)
、ros::Duration(1/50)
等方式实现。
typedef struct
{
signed short yaw_angle;
signed short roll_angle;
signed short pitch_angle;
struct
{
unsigned char base : 1;
unsigned char yaw_cmd_ignore : 1;
unsigned char roll_cmd_ignore : 1;
unsigned char pitch_cmd_ignore : 1;
unsigned char reserve : 4;
}ctrl_byte;
unsigned char duration;
}gimbal_custom_control_angle_t;
解释这里使用了bit field方法,为C++11内容,如下:
Declares a class data member with explicit size, in bits. Adjacent bit field members may be packed to share and straddle the individual bytes.
A bit field declaration is a class data member declaration which uses the following declarator:
identifier(optional) attr(optional) : size (1)
The type of the bit field is introduced by the decl-specifier-seq of the declaration syntax.
- attr(C++11) - optional sequence of any number of attributes
- identifier - the name of the bit field that is being declared. The
name is optional: nameless bit fields introduce the specified number
of bits of padding - size - an integral constant expression with a
value greater or equal to zero. When greater than zero, this is the
number of bits that this bit field will occupy. The value zero is
only allowed for nameless bitfields and has special meaning: it
specifies that the next bit field in the class definition will begin
at an allocation unit’s boundary.
typedef struct
{
signed short yaw_angle_rate;
signed short roll_angle_rate;
signed short pitch_angle_rate;
struct
{
unsigned char reserve : 7;
unsigned char ctrl_switch : 1;//decide increment mode or absolute mode
}ctrl_byte;
}gimbal_custom_speed_t;
/*
*struct of api contrl
*/
typedef struct
{
fp32 q0;
fp32 q1;
fp32 q2;
fp32 q3;
}api_quaternion_data_t;//四元数
typedef struct
{
fp32 x;
fp32 y;
fp32 z;
}api_common_data_t;//三维坐标
/*
*struct of vellocity data
*/
typedef struct
{
fp32 x;
fp32 y;
fp32 z;
unsigned char health_flag :1;
unsigned char feedback_sensor_id :4;
unsigned char reserve :