Browse Source

Attitude estimator Q: Move to convenience publication call

sbg
Lorenz Meier 9 years ago
parent
commit
eb4a562948
  1. 26
      src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp

26
src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp

@ -552,7 +552,7 @@ void AttitudeEstimatorQ::task_main()
_vel_prev_t = 0; _vel_prev_t = 0;
} }
// Time from previous iteration /* time from previous iteration */
hrt_abstime now = hrt_absolute_time(); hrt_abstime now = hrt_absolute_time();
float dt = (last_time > 0) ? ((now - last_time) / 1000000.0f) : 0.00001f; float dt = (last_time > 0) ? ((now - last_time) / 1000000.0f) : 0.00001f;
last_time = now; last_time = now;
@ -595,18 +595,15 @@ void AttitudeEstimatorQ::task_main()
att.accel_vibration = _voter_accel.get_vibration_factor(hrt_absolute_time()); att.accel_vibration = _voter_accel.get_vibration_factor(hrt_absolute_time());
att.mag_vibration = _voter_mag.get_vibration_factor(hrt_absolute_time()); att.mag_vibration = _voter_mag.get_vibration_factor(hrt_absolute_time());
if (_att_pub == nullptr) { /* the instance count is not used here */
_att_pub = orb_advertise(ORB_ID(vehicle_attitude), &att); int att_inst;
orb_publish_auto(ORB_ID(vehicle_attitude), &_att_pub, &att, &att_inst, ORB_PRIO_HIGH);
} else {
orb_publish(ORB_ID(vehicle_attitude), _att_pub, &att);
}
struct control_state_s ctrl_state = {}; struct control_state_s ctrl_state = {};
ctrl_state.timestamp = sensors.timestamp; ctrl_state.timestamp = sensors.timestamp;
/* Attitude quaternions for control state */ /* attitude quaternions for control state */
ctrl_state.q[0] = _q(0); ctrl_state.q[0] = _q(0);
ctrl_state.q[1] = _q(1); ctrl_state.q[1] = _q(1);
@ -615,7 +612,7 @@ void AttitudeEstimatorQ::task_main()
ctrl_state.q[3] = _q(3); ctrl_state.q[3] = _q(3);
/* Attitude rates for control state */ /* attitude rates for control state */
ctrl_state.roll_rate = _lp_roll_rate.apply(_rates(0)); ctrl_state.roll_rate = _lp_roll_rate.apply(_rates(0));
ctrl_state.pitch_rate = _lp_pitch_rate.apply(_rates(1)); ctrl_state.pitch_rate = _lp_pitch_rate.apply(_rates(1));
@ -632,13 +629,10 @@ void AttitudeEstimatorQ::task_main()
ctrl_state.airspeed_valid = false; ctrl_state.airspeed_valid = false;
} }
/* Publish to control state topic */ /* the instance count is not used here */
if (_ctrl_state_pub == nullptr) { int ctrl_inst;
_ctrl_state_pub = orb_advertise(ORB_ID(control_state), &ctrl_state); /* publish to control state topic */
orb_publish_auto(ORB_ID(control_state), &_ctrl_state_pub, &ctrl_state, &ctrl_inst, ORB_PRIO_HIGH);
} else {
orb_publish(ORB_ID(control_state), _ctrl_state_pub, &ctrl_state);
}
} }
} }

Loading…
Cancel
Save