mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-05 19:40:34 +08:00
publish control state from attitude_estimator_q
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
#include <uORB/uORB.h>
|
||||
#include <uORB/topics/sensor_combined.h>
|
||||
#include <uORB/topics/vehicle_attitude.h>
|
||||
#include <uORB/topics/control_state.h>
|
||||
#include <uORB/topics/vehicle_control_mode.h>
|
||||
#include <uORB/topics/vehicle_global_position.h>
|
||||
#include <uORB/topics/parameter_update.h>
|
||||
@@ -116,6 +117,7 @@ private:
|
||||
int _params_sub = -1;
|
||||
int _global_pos_sub = -1;
|
||||
orb_advert_t _att_pub = nullptr;
|
||||
orb_advert_t _ctrl_state_pub = nullptr;
|
||||
|
||||
struct {
|
||||
param_t w_acc;
|
||||
@@ -417,11 +419,8 @@ void AttitudeEstimatorQ::task_main()
|
||||
att.pitch = euler(1);
|
||||
att.yaw = euler(2);
|
||||
|
||||
/* the complimentary filter should reflect the true system
|
||||
* state, but we need smoother outputs for the control system
|
||||
*/
|
||||
att.rollspeed = _lp_roll_rate.apply(_rates(0));
|
||||
att.pitchspeed = _lp_pitch_rate.apply(_rates(1));
|
||||
att.rollspeed = _rates(0);
|
||||
att.pitchspeed = _rates(1);
|
||||
att.yawspeed = _rates(2);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -446,6 +445,29 @@ void AttitudeEstimatorQ::task_main()
|
||||
} else {
|
||||
orb_publish(ORB_ID(vehicle_attitude), _att_pub, &att);
|
||||
}
|
||||
|
||||
struct control_state_s ctrl_state = {};
|
||||
ctrl_state.timestamp = sensors.timestamp;
|
||||
|
||||
/* Attitude quaternions for control state */
|
||||
ctrl_state.q[0] = _q(0);
|
||||
ctrl_state.q[1] = _q(1);
|
||||
ctrl_state.q[2] = _q(2);
|
||||
ctrl_state.q[3] = _q(3);
|
||||
|
||||
/* Attitude rates for control state */
|
||||
ctrl_state.roll_rate = _lp_roll_rate.apply(_rates(0));
|
||||
ctrl_state.pitch_rate = _lp_pitch_rate.apply(_rates(1));
|
||||
ctrl_state.roll_rate = _rates(2);
|
||||
|
||||
/* Publish to control state topic */
|
||||
if (_ctrl_state_pub == nullptr)
|
||||
{
|
||||
_ctrl_state_pub = orb_advertise(ORB_ID(control_state), &ctrl_state);
|
||||
|
||||
} else {
|
||||
orb_publish(ORB_ID(control_state), _ctrl_state_pub, &ctrl_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,7 +593,6 @@ bool AttitudeEstimatorQ::update(float dt) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int attitude_estimator_q_main(int argc, char *argv[]) {
|
||||
if (argc < 1) {
|
||||
warnx("usage: attitude_estimator_q {start|stop|status}");
|
||||
|
||||
Reference in New Issue
Block a user