本文整理汇总了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
}