ArduPilot开源代码之AP_OpticalFlow_CXOF

1. 源由

AP_OpticalFlow_CXOF是就是一个光流计,与前面传感模块:MATEKSYS Optical Flow & LIDAR 3901-L0X不一样。

MATEKSYS Optical Flow & LIDAR 3901-L0X不仅仅只有一个光流计,还有一个Lidar高度计。而本次研读的是基于CXOF串口协议的光流传感器。

2. Library设计

设备相关的重要函数:

  • init
  • update
  • detect
class AP_OpticalFlow_CXOF : public OpticalFlow_backend
{
   
   
public:
    /// 构造函数
    AP_OpticalFlow_CXOF(AP_OpticalFlow &_frontend, AP_HAL::UARTDriver *uart);

    // 初始化传感器
    void init() override;

    // 从传感器读取最新值并填充 x, y 和 totals
    void update(void) override;

    // 检测传感器是否可用
    static AP_OpticalFlow_CXOF *detect(AP_OpticalFlow &_frontend);

private:
    AP_HAL::UARTDriver *uart;           // 连接到光流传感器的 UART
    uint64_t last_frame_us;             // 上次从光流传感器接收到消息的系统时间
    uint8_t buf[10];                    // 从光流传感器接收到的字符缓冲区
    uint8_t buf_len;                    // 缓冲区中的字符数
    Vector2f gyro_sum;                  // 自上次从光流传感器接收到消息以来的陀螺仪传感器值的总和
    uint16_t gyro_sum_count;            // 陀螺仪传感器值总和中的数量
};

3. 重要例程

3.1 AP_OpticalFlow_CXOF::init

模块默认波特率19200 bps。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值