当前位置: 首页 > news >正文

免费推广网站在线观看无锡百度公司王东

免费推广网站在线观看,无锡百度公司王东,企业管理网站模板,家教网站建设ArduPilot开源飞控之AP_Baro_MSP 1. 源由2. back-end抽象类3. 方法实现3.1 AP_Baro_MSP3.2 update3.3 handle_msp3.4 MSP UART port 4. 参考资料 1. 源由 鉴于ArduPilot开源飞控之AP_Baro中涉及Sensor Driver有以下总线类型: I2CSerial UARTCANSITL //模拟传感器(…

ArduPilot开源飞控之AP_Baro_MSP

  • 1. 源由
  • 2. back-end抽象类
  • 3. 方法实现
    • 3.1 AP_Baro_MSP
    • 3.2 update
    • 3.3 handle_msp
    • 3.4 MSP UART port
  • 4. 参考资料

1. 源由

鉴于ArduPilot开源飞控之AP_Baro中涉及Sensor Driver有以下总线类型:

  1. I2C
  2. Serial UART
  3. CAN
  4. SITL //模拟传感器(暂时并列放在这里)

ArduPilot之开源代码Sensor Drivers设计的front-end / back-end分层设计思路,AP_Baro主要描述的是front-end。

为了更好的从整体理解气压计这个传感器的嵌入式应用,这里深入到back-end驱动层,针对基于MSP协议的气压计设备,进行一个研读和理解。

2. back-end抽象类

AP_Baro_Backend驱动层需实现方法:

  • void update()
  • static AP_Baro_Backend *probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::Device> dev)

注:通常来说使用ChibiOS的都有定时器,如果没有定时器,可以使用void accumulate(void)来实现传感器的数据定时获取。

class AP_Baro_Backend
{
public:AP_Baro_Backend(AP_Baro &baro);virtual ~AP_Baro_Backend(void) {};// each driver must provide an update method to copy accumulated// data to the frontendvirtual void update() = 0;// accumulate function. This is used for backends that don't use a// timer, and need to be called regularly by the main code to// trigger them to read the sensorvirtual void accumulate(void) {}void backend_update(uint8_t instance);//  Check that the baro valid by using a mean filter.// If the value further that filtrer_range from mean value, it is rejected.bool pressure_ok(float press);uint32_t get_error_count() const { return _error_count; }#if AP_BARO_MSP_ENABLEDvirtual void handle_msp(const MSP::msp_baro_data_message_t &pkt) {}
#endif#if AP_BARO_EXTERNALAHRS_ENABLEDvirtual void handle_external(const AP_ExternalAHRS::baro_data_message_t &pkt) {}
#endif/*device driver IDs. These are used to fill in the devtype fieldof the device ID, which shows up as BARO_DEVID* parameters tousers.*/enum DevTypes {DEVTYPE_BARO_SITL     = 0x01,DEVTYPE_BARO_BMP085   = 0x02,DEVTYPE_BARO_BMP280   = 0x03,DEVTYPE_BARO_BMP388   = 0x04,DEVTYPE_BARO_DPS280   = 0x05,DEVTYPE_BARO_DPS310   = 0x06,DEVTYPE_BARO_FBM320   = 0x07,DEVTYPE_BARO_ICM20789 = 0x08,DEVTYPE_BARO_KELLERLD = 0x09,DEVTYPE_BARO_LPS2XH   = 0x0A,DEVTYPE_BARO_MS5611   = 0x0B,DEVTYPE_BARO_SPL06    = 0x0C,DEVTYPE_BARO_UAVCAN   = 0x0D,DEVTYPE_BARO_MSP      = 0x0E,DEVTYPE_BARO_ICP101XX = 0x0F,DEVTYPE_BARO_ICP201XX = 0x10,DEVTYPE_BARO_MS5607   = 0x11,DEVTYPE_BARO_MS5837   = 0x12,DEVTYPE_BARO_MS5637   = 0x13,DEVTYPE_BARO_BMP390   = 0x14,};protected:// reference to frontend objectAP_Baro &_frontend;void _copy_to_frontend(uint8_t instance, float pressure, float temperature);// semaphore for access to shared frontend dataHAL_Semaphore _sem;virtual void update_healthy_flag(uint8_t instance);// mean pressure for range filterfloat _mean_pressure; // number of dropped samples. Not used for now, but can be usable to choose more reliable sensoruint32_t _error_count;// set bus ID of this instance, for BARO_DEVID parametersvoid set_bus_id(uint8_t instance, uint32_t id) {_frontend.sensors[instance].bus_id.set(int32_t(id));}
};

3. 方法实现

由于气压数据来自串口,因此,其逻辑相对简单,没有校准等复杂物理公式。

3.1 AP_Baro_MSP

实例初始化。

AP_Baro_MSP::AP_Baro_MSP├──> msp_instance = _msp_instance;├──> instance = _frontend.register_sensor();└──> set_bus_id(instance, AP_HAL::Device::make_bus_id(AP_HAL::Device::BUS_TYPE_MSP,0,msp_instance,0));

3.2 update

front-end / back-end数据更新。

AP_Baro_MSP::update└──> <count>├──> WITH_SEMAPHORE(_sem);├──> _copy_to_frontend(instance, sum_pressure/count, sum_temp/count);├──> sum_pressure = sum_temp = 0;└──> count = 0;

3.3 handle_msp

处理MSP协议中气压数据。

AP_Baro_MSP::handle_msp├──> <pkt.instance != msp_instance> // not for us│   └──> return;├──> WITH_SEMAPHORE(_sem);├──> sum_pressure += pkt.pressure_pa;├──> sum_temp += pkt.temp*0.01;└──> count++;typedef struct PACKED {uint8_t instance;uint32_t time_ms;float pressure_pa;int16_t temp; // centi-degrees C
} msp_baro_data_message_t;

3.4 MSP UART port

满足MSP协议格式,参考:BetaFlight模块设计之三十二:MSP协议模块分析

AP_Vehicle::setup└──> AP_MSP::init└──> AP_MSP::loop  //thread_create└──> AP_MSP_Telem_Backend::process_incoming_data└──> AP_MSP_Telem_Backend::msp_process_received_command└──> AP_MSP_Telem_Backend::msp_process_command└──> AP_MSP_Telem_Backend::msp_process_sensor_command└──> AP_MSP_Telem_Backend::msp_handle_baro└──> AP_Baro::handle_msp└──> AP_Baro_MSP::handle_msp

4. 参考资料

【1】ArduPilot开源飞控系统之简单介绍
【2】ArduPilot之开源代码Task介绍
【3】ArduPilot飞控启动&运行过程简介
【4】ArduPilot之开源代码Library&Sketches设计
【5】ArduPilot之开源代码Sensor Drivers设计

http://www.ds6.com.cn/news/2223.html

相关文章:

  • 论坛上怎么做网站优化浏览器大全网站
  • 网站开发 培训 周末班百度网页版链接地址
  • 医院营销策略的具体方法搜索引擎优化英文简称为
  • 网站推广关键词网络软营销
  • 网站建设成本分析周口搜索引擎优化
  • 贵金属网站模板昆明长尾词seo怎么优化
  • 网站建设举报一站式推广平台
  • 哪个网站做课件ppt比较好湖南长沙最新情况
  • 如东网站建设哪家好重庆百度小额贷款有限公司
  • 聊城网站百度推广如何免费建立一个网站
  • 长沙芙蓉区疫情最新情况最好的seo外包
  • 深圳宝安区住房和建设局网站官网百度关键词优化点击 教程
  • 两个男生如何做网站百度自然排名优化
  • 深圳网站建设 网站设计百度上广告怎么搞上去的
  • 做调查问卷权威网站需要推广的app在哪里找
  • 网站开发费用国家标准免费搭建自己的网站
  • 动态网站建设seo技术培训教程视频
  • 搜狗首页排名优化seo搜索引擎优化内容
  • 网站如何提高流量万物识别扫一扫
  • 潍坊网站建设最新报价外链网盘
  • 网站开发完成如何上线快点tv下载安装
  • 开发公司网站建设抖音关键词用户搜索排名靠前
  • 做品牌推广用什么网站什么平台可以发广告引流
  • 全球最热门网站攀枝花网站seo
  • 城乡建设部网官方网站广东省人大常委会
  • 电子表格做网站框架今日的新闻头条10条
  • 买了两台服务器可以做网站吗保温杯软文营销300字
  • 杭州建设银行网站线上seo关键词优化软件工具
  • 邢台疫情防控最新规定宁波seo推广如何收费
  • 杭州手机模板建站发帖推广平台