当前位置: 首页>>代码示例>>C++>>正文


C++ AP_AHRS_NavEKF::get_gyro方法代码示例

本文整理汇总了C++中AP_AHRS_NavEKF::get_gyro方法的典型用法代码示例。如果您正苦于以下问题:C++ AP_AHRS_NavEKF::get_gyro方法的具体用法?C++ AP_AHRS_NavEKF::get_gyro怎么用?C++ AP_AHRS_NavEKF::get_gyro使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AP_AHRS_NavEKF的用法示例。


在下文中一共展示了AP_AHRS_NavEKF::get_gyro方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: call_hook_AHRS_update

/*
  call any AHRS_update hooks
*/
void AP_Module::call_hook_AHRS_update(const AP_AHRS_NavEKF &ahrs)
{
#if AP_MODULE_SUPPORTED
    if (hooks[HOOK_AHRS_UPDATE] == nullptr) {
        // avoid filling in AHRS_state
        return;
    }

    /*
      construct AHRS_state structure
     */
    struct AHRS_state state {};
    state.structure_version = AHRS_state_version;
    state.time_us = AP_HAL::micros64();

    if (!ahrs.initialised()) {
        state.status = AHRS_STATUS_INITIALISING;
    } else if (ahrs.healthy()) {
        state.status = AHRS_STATUS_HEALTHY;
    } else {
        state.status = AHRS_STATUS_UNHEALTHY;
    }

    Quaternion q;
    q.from_rotation_matrix(ahrs.get_rotation_body_to_ned());
    state.quat[0] = q[0];
    state.quat[1] = q[1];
    state.quat[2] = q[2];
    state.quat[3] = q[3];

    state.eulers[0] = ahrs.roll;
    state.eulers[1] = ahrs.pitch;
    state.eulers[2] = ahrs.yaw;

    Location loc;
    if (ahrs.get_origin(loc)) {
        state.origin.initialised = true;
        state.origin.latitude = loc.lat;
        state.origin.longitude = loc.lng;
        state.origin.altitude = loc.alt*0.01f;
    }

    if (ahrs.get_position(loc)) {
        state.position.available = true;
        state.position.latitude = loc.lat;
        state.position.longitude = loc.lng;
        state.position.altitude = loc.alt*0.01f;
    }
    
    Vector3f pos;
    if (ahrs.get_relative_position_NED(pos)) {
        state.relative_position[0] = pos[0];
        state.relative_position[1] = pos[1];
        state.relative_position[2] = pos[2];
    }

    const Vector3f &gyro = ahrs.get_gyro();
    state.gyro_rate[0] = gyro[0];
    state.gyro_rate[1] = gyro[1];
    state.gyro_rate[2] = gyro[2];

    const Vector3f &accel_ef = ahrs.get_accel_ef();
    state.accel_ef[0] = accel_ef[0];
    state.accel_ef[1] = accel_ef[0];
    state.accel_ef[2] = accel_ef[0];
    
    for (const struct hook_list *h=hooks[HOOK_AHRS_UPDATE]; h; h=h->next) {
        ap_hook_AHRS_update_fn_t fn = reinterpret_cast<ap_hook_AHRS_update_fn_t>(h->symbol);
        fn(&state);
    }
#endif
}
开发者ID:2013-8-15,项目名称:ardupilot,代码行数:75,代码来源:AP_Module.cpp


注:本文中的AP_AHRS_NavEKF::get_gyro方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。