玩转四旋翼无人机(DJI SDK LIB)

建议开发者将姿态控制命令以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.

  1. attr(C++11) - optional sequence of any number of attributes
  2. 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
  3. 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             :
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值