mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 23:23:33 +08:00
Merged master
This commit is contained in:
@@ -130,7 +130,7 @@ float ECL_Controller::get_desired_bodyrate()
|
||||
|
||||
float ECL_Controller::constrain_airspeed(float airspeed, float minspeed, float maxspeed) {
|
||||
float airspeed_result = airspeed;
|
||||
if (!isfinite(airspeed)) {
|
||||
if (!PX4_ISFINITE(airspeed)) {
|
||||
/* airspeed is NaN, +- INF or not available, pick center of band */
|
||||
airspeed_result = 0.5f * (minspeed + maxspeed);
|
||||
} else if (airspeed < minspeed) {
|
||||
|
||||
@@ -60,62 +60,24 @@ ECL_PitchController::~ECL_PitchController()
|
||||
|
||||
float ECL_PitchController::control_attitude(const struct ECL_ControlData &ctl_data)
|
||||
{
|
||||
float roll = ctl_data.roll;
|
||||
|
||||
/* Do not calculate control signal with bad inputs */
|
||||
if (!(isfinite(ctl_data.pitch_setpoint) &&
|
||||
isfinite(roll) &&
|
||||
isfinite(ctl_data.pitch) &&
|
||||
isfinite(ctl_data.airspeed))) {
|
||||
if (!(PX4_ISFINITE(ctl_data.pitch_setpoint) &&
|
||||
PX4_ISFINITE(ctl_data.roll) &&
|
||||
PX4_ISFINITE(ctl_data.pitch) &&
|
||||
PX4_ISFINITE(ctl_data.airspeed))) {
|
||||
perf_count(_nonfinite_input_perf);
|
||||
warnx("not controlling pitch");
|
||||
return _rate_setpoint;
|
||||
}
|
||||
|
||||
/* flying inverted (wings upside down) ? */
|
||||
bool inverted = false;
|
||||
|
||||
/* roll is used as feedforward term and inverted flight needs to be considered */
|
||||
if (fabsf(roll) < math::radians(90.0f)) {
|
||||
/* not inverted, but numerically still potentially close to infinity */
|
||||
roll = math::constrain(roll, math::radians(-80.0f), math::radians(80.0f));
|
||||
|
||||
} else {
|
||||
/* inverted flight, constrain on the two extremes of -pi..+pi to avoid infinity */
|
||||
|
||||
/* note: the ranges are extended by 10 deg here to avoid numeric resolution effects */
|
||||
if (roll > 0.0f) {
|
||||
/* right hemisphere */
|
||||
roll = math::constrain(roll, math::radians(100.0f), math::radians(180.0f));
|
||||
|
||||
} else {
|
||||
/* left hemisphere */
|
||||
roll = math::constrain(roll, math::radians(-100.0f), math::radians(-180.0f));
|
||||
}
|
||||
}
|
||||
|
||||
/* input conditioning */
|
||||
float airspeed = constrain_airspeed(ctl_data.airspeed, ctl_data.airspeed_min, ctl_data.airspeed_max);
|
||||
/* calculate the offset in the rate resulting from rolling */
|
||||
//xxx needs explanation and conversion to body angular rates or should be removed
|
||||
float turn_offset = fabsf((CONSTANTS_ONE_G / airspeed) *
|
||||
tanf(roll) * sinf(roll)) * _roll_ff;
|
||||
|
||||
if (inverted) {
|
||||
turn_offset = -turn_offset;
|
||||
}
|
||||
|
||||
/* Calculate the error */
|
||||
float pitch_error = ctl_data.pitch_setpoint - ctl_data.pitch;
|
||||
|
||||
/* Apply P controller: rate setpoint from current error and time constant */
|
||||
_rate_setpoint = pitch_error / _tc;
|
||||
|
||||
/* add turn offset */
|
||||
_rate_setpoint += turn_offset;
|
||||
|
||||
/* limit the rate */ //XXX: move to body angluar rates
|
||||
|
||||
/* limit the rate */
|
||||
if (_max_rate > 0.01f && _max_rate_neg > 0.01f) {
|
||||
if (_rate_setpoint > 0.0f) {
|
||||
_rate_setpoint = (_rate_setpoint > _max_rate) ? _max_rate : _rate_setpoint;
|
||||
@@ -132,14 +94,14 @@ float ECL_PitchController::control_attitude(const struct ECL_ControlData &ctl_da
|
||||
float ECL_PitchController::control_bodyrate(const struct ECL_ControlData &ctl_data)
|
||||
{
|
||||
/* Do not calculate control signal with bad inputs */
|
||||
if (!(isfinite(ctl_data.roll) &&
|
||||
isfinite(ctl_data.pitch) &&
|
||||
isfinite(ctl_data.pitch_rate) &&
|
||||
isfinite(ctl_data.yaw_rate) &&
|
||||
isfinite(ctl_data.yaw_rate_setpoint) &&
|
||||
isfinite(ctl_data.airspeed_min) &&
|
||||
isfinite(ctl_data.airspeed_max) &&
|
||||
isfinite(ctl_data.scaler))) {
|
||||
if (!(PX4_ISFINITE(ctl_data.roll) &&
|
||||
PX4_ISFINITE(ctl_data.pitch) &&
|
||||
PX4_ISFINITE(ctl_data.pitch_rate) &&
|
||||
PX4_ISFINITE(ctl_data.yaw_rate) &&
|
||||
PX4_ISFINITE(ctl_data.yaw_rate_setpoint) &&
|
||||
PX4_ISFINITE(ctl_data.airspeed_min) &&
|
||||
PX4_ISFINITE(ctl_data.airspeed_max) &&
|
||||
PX4_ISFINITE(ctl_data.scaler))) {
|
||||
perf_count(_nonfinite_input_perf);
|
||||
return math::constrain(_last_output, -1.0f, 1.0f);
|
||||
}
|
||||
@@ -160,11 +122,48 @@ float ECL_PitchController::control_bodyrate(const struct ECL_ControlData &ctl_da
|
||||
_bodyrate_setpoint = cosf(ctl_data.roll) * _rate_setpoint +
|
||||
cosf(ctl_data.pitch) * sinf(ctl_data.roll) * ctl_data.yaw_rate_setpoint;
|
||||
|
||||
/* Transform estimation to body angular rates (jacobian) */
|
||||
float pitch_bodyrate = cosf(ctl_data.roll) * ctl_data.pitch_rate +
|
||||
cosf(ctl_data.pitch) * sinf(ctl_data.roll) * ctl_data.yaw_rate;
|
||||
/* apply turning offset to desired bodyrate setpoint*/
|
||||
/* flying inverted (wings upside down)*/
|
||||
bool inverted = false;
|
||||
float constrained_roll;
|
||||
/* roll is used as feedforward term and inverted flight needs to be considered */
|
||||
if (fabsf(ctl_data.roll) < math::radians(90.0f)) {
|
||||
/* not inverted, but numerically still potentially close to infinity */
|
||||
constrained_roll = math::constrain(ctl_data.roll, math::radians(-80.0f), math::radians(80.0f));
|
||||
|
||||
_rate_error = _bodyrate_setpoint - pitch_bodyrate;
|
||||
} else {
|
||||
/* inverted flight, constrain on the two extremes of -pi..+pi to avoid infinity */
|
||||
inverted = true;
|
||||
/* note: the ranges are extended by 10 deg here to avoid numeric resolution effects */
|
||||
if (ctl_data.roll > 0.0f) {
|
||||
/* right hemisphere */
|
||||
constrained_roll = math::constrain(ctl_data.roll, math::radians(100.0f), math::radians(180.0f));
|
||||
|
||||
} else {
|
||||
/* left hemisphere */
|
||||
constrained_roll = math::constrain(ctl_data.roll, math::radians(-100.0f), math::radians(-180.0f));
|
||||
}
|
||||
}
|
||||
|
||||
/* input conditioning */
|
||||
float airspeed = constrain_airspeed(ctl_data.airspeed, ctl_data.airspeed_min, ctl_data.airspeed_max);
|
||||
|
||||
/* Calculate desired body fixed y-axis angular rate needed to compensate for roll angle.
|
||||
For reference see Automatic Control of Aircraft and Missiles by John H. Blakelock, pg. 175
|
||||
Availible on google books 8/11/2015:
|
||||
https://books.google.com/books?id=ubcczZUDCsMC&pg=PA175#v=onepage&q&f=false*/
|
||||
float body_fixed_turn_offset = (fabsf((CONSTANTS_ONE_G / airspeed) *
|
||||
tanf(constrained_roll) * sinf(constrained_roll)));
|
||||
|
||||
if (inverted) {
|
||||
body_fixed_turn_offset = -body_fixed_turn_offset;
|
||||
}
|
||||
|
||||
/* Finally add the turn offset to your bodyrate setpoint*/
|
||||
_bodyrate_setpoint += body_fixed_turn_offset;
|
||||
|
||||
|
||||
_rate_error = _bodyrate_setpoint - ctl_data.pitch_rate;
|
||||
|
||||
if (!lock_integrator && _k_i > 0.0f) {
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ ECL_RollController::~ECL_RollController()
|
||||
float ECL_RollController::control_attitude(const struct ECL_ControlData &ctl_data)
|
||||
{
|
||||
/* Do not calculate control signal with bad inputs */
|
||||
if (!(isfinite(ctl_data.roll_setpoint) && isfinite(ctl_data.roll))) {
|
||||
if (!(PX4_ISFINITE(ctl_data.roll_setpoint) && PX4_ISFINITE(ctl_data.roll))) {
|
||||
perf_count(_nonfinite_input_perf);
|
||||
return _rate_setpoint;
|
||||
}
|
||||
@@ -83,13 +83,13 @@ float ECL_RollController::control_attitude(const struct ECL_ControlData &ctl_dat
|
||||
float ECL_RollController::control_bodyrate(const struct ECL_ControlData &ctl_data)
|
||||
{
|
||||
/* Do not calculate control signal with bad inputs */
|
||||
if (!(isfinite(ctl_data.pitch) &&
|
||||
isfinite(ctl_data.roll_rate) &&
|
||||
isfinite(ctl_data.yaw_rate) &&
|
||||
isfinite(ctl_data.yaw_rate_setpoint) &&
|
||||
isfinite(ctl_data.airspeed_min) &&
|
||||
isfinite(ctl_data.airspeed_max) &&
|
||||
isfinite(ctl_data.scaler))) {
|
||||
if (!(PX4_ISFINITE(ctl_data.pitch) &&
|
||||
PX4_ISFINITE(ctl_data.roll_rate) &&
|
||||
PX4_ISFINITE(ctl_data.yaw_rate) &&
|
||||
PX4_ISFINITE(ctl_data.yaw_rate_setpoint) &&
|
||||
PX4_ISFINITE(ctl_data.airspeed_min) &&
|
||||
PX4_ISFINITE(ctl_data.airspeed_max) &&
|
||||
PX4_ISFINITE(ctl_data.scaler))) {
|
||||
perf_count(_nonfinite_input_perf);
|
||||
return math::constrain(_last_output, -1.0f, 1.0f);
|
||||
}
|
||||
@@ -109,11 +109,8 @@ float ECL_RollController::control_bodyrate(const struct ECL_ControlData &ctl_dat
|
||||
/* Transform setpoint to body angular rates (jacobian) */
|
||||
_bodyrate_setpoint = _rate_setpoint - sinf(ctl_data.pitch) * ctl_data.yaw_rate_setpoint;
|
||||
|
||||
/* Transform estimation to body angular rates (jacobian) */
|
||||
float roll_bodyrate = ctl_data.roll_rate - sinf(ctl_data.pitch) * ctl_data.yaw_rate;
|
||||
|
||||
/* Calculate body angular rate error */
|
||||
_rate_error = _bodyrate_setpoint - roll_bodyrate; //body angular rate error
|
||||
_rate_error = _bodyrate_setpoint - ctl_data.roll_rate; //body angular rate error
|
||||
|
||||
if (!lock_integrator && _k_i > 0.0f) {
|
||||
|
||||
|
||||
@@ -101,13 +101,13 @@ float ECL_YawController::control_bodyrate(const struct ECL_ControlData &ctl_data
|
||||
float ECL_YawController::control_attitude_impl_openloop(const struct ECL_ControlData &ctl_data)
|
||||
{
|
||||
/* Do not calculate control signal with bad inputs */
|
||||
if (!(isfinite(ctl_data.roll) &&
|
||||
isfinite(ctl_data.pitch) &&
|
||||
isfinite(ctl_data.speed_body_u) &&
|
||||
isfinite(ctl_data.speed_body_v) &&
|
||||
isfinite(ctl_data.speed_body_w) &&
|
||||
isfinite(ctl_data.roll_rate_setpoint) &&
|
||||
isfinite(ctl_data.pitch_rate_setpoint))) {
|
||||
if (!(PX4_ISFINITE(ctl_data.roll) &&
|
||||
PX4_ISFINITE(ctl_data.pitch) &&
|
||||
PX4_ISFINITE(ctl_data.speed_body_u) &&
|
||||
PX4_ISFINITE(ctl_data.speed_body_v) &&
|
||||
PX4_ISFINITE(ctl_data.speed_body_w) &&
|
||||
PX4_ISFINITE(ctl_data.roll_rate_setpoint) &&
|
||||
PX4_ISFINITE(ctl_data.pitch_rate_setpoint))) {
|
||||
perf_count(_nonfinite_input_perf);
|
||||
return _rate_setpoint;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ float ECL_YawController::control_attitude_impl_openloop(const struct ECL_Control
|
||||
|
||||
// counter++;
|
||||
|
||||
if (!isfinite(_rate_setpoint)) {
|
||||
if (!PX4_ISFINITE(_rate_setpoint)) {
|
||||
warnx("yaw rate sepoint not finite");
|
||||
_rate_setpoint = 0.0f;
|
||||
}
|
||||
@@ -156,10 +156,10 @@ float ECL_YawController::control_attitude_impl_openloop(const struct ECL_Control
|
||||
float ECL_YawController::control_bodyrate_impl(const struct ECL_ControlData &ctl_data)
|
||||
{
|
||||
/* Do not calculate control signal with bad inputs */
|
||||
if (!(isfinite(ctl_data.roll) && isfinite(ctl_data.pitch) && isfinite(ctl_data.pitch_rate) &&
|
||||
isfinite(ctl_data.yaw_rate) && isfinite(ctl_data.pitch_rate_setpoint) &&
|
||||
isfinite(ctl_data.airspeed_min) && isfinite(ctl_data.airspeed_max) &&
|
||||
isfinite(ctl_data.scaler))) {
|
||||
if (!(PX4_ISFINITE(ctl_data.roll) && PX4_ISFINITE(ctl_data.pitch) && PX4_ISFINITE(ctl_data.pitch_rate) &&
|
||||
PX4_ISFINITE(ctl_data.yaw_rate) && PX4_ISFINITE(ctl_data.pitch_rate_setpoint) &&
|
||||
PX4_ISFINITE(ctl_data.airspeed_min) && PX4_ISFINITE(ctl_data.airspeed_max) &&
|
||||
PX4_ISFINITE(ctl_data.scaler))) {
|
||||
perf_count(_nonfinite_input_perf);
|
||||
return math::constrain(_last_output, -1.0f, 1.0f);
|
||||
}
|
||||
@@ -179,7 +179,7 @@ float ECL_YawController::control_bodyrate_impl(const struct ECL_ControlData &ctl
|
||||
/* input conditioning */
|
||||
float airspeed = ctl_data.airspeed;
|
||||
|
||||
if (!isfinite(airspeed)) {
|
||||
if (!PX4_ISFINITE(airspeed)) {
|
||||
/* airspeed is NaN, +- INF or not available, pick center of band */
|
||||
airspeed = 0.5f * (ctl_data.airspeed_min + ctl_data.airspeed_max);
|
||||
|
||||
@@ -198,12 +198,8 @@ float ECL_YawController::control_bodyrate_impl(const struct ECL_ControlData &ctl
|
||||
_bodyrate_setpoint -= (ctl_data.acc_body_y / (airspeed * cosf(ctl_data.pitch)));
|
||||
}
|
||||
|
||||
/* Transform estimation to body angular rates (jacobian) */
|
||||
float yaw_bodyrate = -sinf(ctl_data.roll) * ctl_data.pitch_rate +
|
||||
cosf(ctl_data.roll) * cosf(ctl_data.pitch) * ctl_data.yaw_rate;
|
||||
|
||||
/* Calculate body angular rate error */
|
||||
_rate_error = _bodyrate_setpoint - yaw_bodyrate; //body angular rate error
|
||||
_rate_error = _bodyrate_setpoint - ctl_data.yaw_rate; //body angular rate error
|
||||
|
||||
if (!lock_integrator && _k_i > 0.0f && airspeed > 0.5f * ctl_data.airspeed_min) {
|
||||
|
||||
|
||||
+1
-1
Submodule src/lib/eigen updated: e7850ed81f...240599e148
@@ -62,6 +62,10 @@ void TECS::update_state(float baro_altitude, float airspeed, const math::Matrix<
|
||||
_integ3_state = baro_altitude;
|
||||
_integ2_state = 0.0f;
|
||||
_integ1_state = 0.0f;
|
||||
|
||||
// Reset the filter state as we just switched from non-altitude control
|
||||
// to altitude control mode
|
||||
_states_initalized = false;
|
||||
}
|
||||
|
||||
_update_50hz_last_usec = now;
|
||||
@@ -94,7 +98,7 @@ void TECS::update_state(float baro_altitude, float airspeed, const math::Matrix<
|
||||
// Only required if airspeed is being measured and controlled
|
||||
float temp = 0;
|
||||
|
||||
if (isfinite(airspeed) && airspeed_sensor_enabled()) {
|
||||
if (PX4_ISFINITE(airspeed) && airspeed_sensor_enabled()) {
|
||||
// Get DCM
|
||||
// Calculate speed rate of change
|
||||
// XXX check
|
||||
@@ -138,7 +142,7 @@ void TECS::_update_speed(float airspeed_demand, float indicated_airspeed,
|
||||
|
||||
// Get airspeed or default to halfway between min and max if
|
||||
// airspeed is not being used and set speed rate to zero
|
||||
if (!isfinite(indicated_airspeed) || !airspeed_sensor_enabled()) {
|
||||
if (!PX4_ISFINITE(indicated_airspeed) || !airspeed_sensor_enabled()) {
|
||||
// If no airspeed available use average of min and max
|
||||
_EAS = 0.5f * (indicated_airspeed_min + indicated_airspeed_max);
|
||||
|
||||
@@ -224,12 +228,12 @@ void TECS::_update_speed_demand(void)
|
||||
void TECS::_update_height_demand(float demand, float state)
|
||||
{
|
||||
// Handle initialization
|
||||
if (isfinite(demand) && fabsf(_hgt_dem_in_old) < 0.1f) {
|
||||
if (PX4_ISFINITE(demand) && fabsf(_hgt_dem_in_old) < 0.1f) {
|
||||
_hgt_dem_in_old = demand;
|
||||
}
|
||||
// Apply 2 point moving average to demanded height
|
||||
// This is required because height demand is updated in steps
|
||||
if (isfinite(demand)) {
|
||||
if (PX4_ISFINITE(demand)) {
|
||||
_hgt_dem = 0.5f * (demand + _hgt_dem_in_old);
|
||||
} else {
|
||||
_hgt_dem = _hgt_dem_in_old;
|
||||
@@ -309,12 +313,12 @@ void TECS::_update_throttle(float throttle_cruise, const math::Matrix<3,3> &rotM
|
||||
// Calculate total energy values
|
||||
_STE_error = _SPE_dem - _SPE_est + _SKE_dem - _SKE_est;
|
||||
float STEdot_dem = constrain((_SPEdot_dem + _SKEdot_dem), _STEdot_min, _STEdot_max);
|
||||
float STEdot_error = STEdot_dem - _SPEdot - _SKEdot;
|
||||
_STEdot_error = STEdot_dem - _SPEdot - _SKEdot;
|
||||
|
||||
// Apply 0.5 second first order filter to STEdot_error
|
||||
// This is required to remove accelerometer noise from the measurement
|
||||
STEdot_error = 0.2f * STEdot_error + 0.8f * _STEdotErrLast;
|
||||
_STEdotErrLast = STEdot_error;
|
||||
_STEdot_error = 0.2f * _STEdot_error + 0.8f * _STEdotErrLast;
|
||||
_STEdotErrLast = _STEdot_error;
|
||||
|
||||
// Calculate throttle demand
|
||||
// If underspeed condition is set, then demand full throttle
|
||||
@@ -342,7 +346,7 @@ void TECS::_update_throttle(float throttle_cruise, const math::Matrix<3,3> &rotM
|
||||
}
|
||||
|
||||
// Calculate PD + FF throttle and constrain to avoid blow-up of the integrator later
|
||||
_throttle_dem = (_STE_error + STEdot_error * _thrDamp) * K_STE2Thr + ff_throttle;
|
||||
_throttle_dem = (_STE_error + _STEdot_error * _thrDamp) * K_STE2Thr + ff_throttle;
|
||||
_throttle_dem = constrain(_throttle_dem, _THRminf, _THRmaxf);
|
||||
|
||||
// Rate limit PD + FF throttle
|
||||
@@ -438,11 +442,11 @@ void TECS::_update_pitch(void)
|
||||
// Calculate Specific Energy Balance demand, and error
|
||||
float SEB_dem = _SPE_dem * SPE_weighting - _SKE_dem * SKE_weighting;
|
||||
float SEBdot_dem = _SPEdot_dem * SPE_weighting - _SKEdot_dem * SKE_weighting;
|
||||
float SEB_error = SEB_dem - (_SPE_est * SPE_weighting - _SKE_est * SKE_weighting);
|
||||
float SEBdot_error = SEBdot_dem - (_SPEdot * SPE_weighting - _SKEdot * SKE_weighting);
|
||||
_SEB_error = SEB_dem - (_SPE_est * SPE_weighting - _SKE_est * SKE_weighting);
|
||||
_SEBdot_error = SEBdot_dem - (_SPEdot * SPE_weighting - _SKEdot * SKE_weighting);
|
||||
|
||||
// Calculate integrator state, constraining input if pitch limits are exceeded
|
||||
float integ7_input = SEB_error * _integGain;
|
||||
float integ7_input = _SEB_error * _integGain;
|
||||
|
||||
if (_pitch_dem_unc > _PITCHmaxf) {
|
||||
integ7_input = min(integ7_input, _PITCHmaxf - _pitch_dem_unc);
|
||||
@@ -460,7 +464,7 @@ void TECS::_update_pitch(void)
|
||||
// demand equal to the minimum value (which is )set by the mission plan during this mode). Otherwise the
|
||||
// integrator has to catch up before the nose can be raised to reduce speed during climbout.
|
||||
float gainInv = (_integ5_state * _timeConst * CONSTANTS_ONE_G);
|
||||
float temp = SEB_error + SEBdot_error * _ptchDamp + SEBdot_dem * _timeConst;
|
||||
float temp = _SEB_error + _SEBdot_error * _ptchDamp + SEBdot_dem * _timeConst;
|
||||
if (_climbOutDem)
|
||||
{
|
||||
temp += _PITCHminf * gainInv;
|
||||
@@ -598,18 +602,26 @@ void TECS::update_pitch_throttle(const math::Matrix<3,3> &rotMat, float pitch, f
|
||||
_tecs_state.mode = ECL_TECS_MODE_NORMAL;
|
||||
}
|
||||
|
||||
_tecs_state.hgt_dem = _hgt_dem_adj;
|
||||
_tecs_state.hgt = _integ3_state;
|
||||
_tecs_state.dhgt_dem = _hgt_rate_dem;
|
||||
_tecs_state.dhgt = _integ2_state;
|
||||
_tecs_state.spd_dem = _TAS_dem_adj;
|
||||
_tecs_state.spd = _integ5_state;
|
||||
_tecs_state.dspd = _vel_dot;
|
||||
_tecs_state.ithr = _integ6_state;
|
||||
_tecs_state.iptch = _integ7_state;
|
||||
_tecs_state.thr = _throttle_dem;
|
||||
_tecs_state.ptch = _pitch_dem;
|
||||
_tecs_state.dspd_dem = _TAS_rate_dem;
|
||||
_tecs_state.altitude_sp = _hgt_dem_adj;
|
||||
_tecs_state.altitude_filtered = _integ3_state;
|
||||
_tecs_state.altitude_rate_sp = _hgt_rate_dem;
|
||||
_tecs_state.altitude_rate = _integ2_state;
|
||||
|
||||
_tecs_state.airspeed_sp = _TAS_dem_adj;
|
||||
_tecs_state.airspeed_rate_sp = _TAS_rate_dem;
|
||||
_tecs_state.airspeed_filtered = _integ5_state;
|
||||
_tecs_state.airspeed_rate = _vel_dot;
|
||||
|
||||
_tecs_state.total_energy_error = _STE_error;
|
||||
_tecs_state.energy_distribution_error = _SEB_error;
|
||||
_tecs_state.total_energy_rate_error = _STEdot_error;
|
||||
_tecs_state.energy_distribution_error = _SEBdot_error;
|
||||
|
||||
_tecs_state.energy_error_integ = _integ6_state;
|
||||
_tecs_state.energy_distribution_error_integ = _integ7_state;
|
||||
|
||||
_tecs_state.throttle_integ = _integ6_state;
|
||||
_tecs_state.pitch_integ = _integ7_state;
|
||||
|
||||
_update_pitch_throttle_last_usec = now;
|
||||
|
||||
|
||||
@@ -79,6 +79,10 @@ public:
|
||||
_SKE_est(0.0f),
|
||||
_SPEdot(0.0f),
|
||||
_SKEdot(0.0f),
|
||||
_STE_error(0.0f),
|
||||
_STEdot_error(0.0f),
|
||||
_SEB_error(0.0f),
|
||||
_SEBdot_error(0.0f),
|
||||
_airspeed_enabled(false),
|
||||
_states_initalized(false),
|
||||
_in_air(false),
|
||||
@@ -137,18 +141,22 @@ public:
|
||||
|
||||
struct tecs_state {
|
||||
uint64_t timestamp;
|
||||
float hgt;
|
||||
float dhgt;
|
||||
float hgt_dem;
|
||||
float dhgt_dem;
|
||||
float spd_dem;
|
||||
float spd;
|
||||
float dspd;
|
||||
float ithr;
|
||||
float iptch;
|
||||
float thr;
|
||||
float ptch;
|
||||
float dspd_dem;
|
||||
float altitude_filtered;
|
||||
float altitude_sp;
|
||||
float altitude_rate;
|
||||
float altitude_rate_sp;
|
||||
float airspeed_filtered;
|
||||
float airspeed_sp;
|
||||
float airspeed_rate;
|
||||
float airspeed_rate_sp;
|
||||
float energy_error_integ;
|
||||
float energy_distribution_error_integ;
|
||||
float total_energy_error;
|
||||
float total_energy_rate_error;
|
||||
float energy_distribution_error;
|
||||
float energy_distribution_rate_error;
|
||||
float throttle_integ;
|
||||
float pitch_integ;
|
||||
enum ECL_TECS_MODE mode;
|
||||
};
|
||||
|
||||
@@ -376,6 +384,15 @@ private:
|
||||
// Specific energy error quantities
|
||||
float _STE_error;
|
||||
|
||||
// Energy error rate
|
||||
float _STEdot_error;
|
||||
|
||||
// Specific energy balance error
|
||||
float _SEB_error;
|
||||
|
||||
// Specific energy balance error rate
|
||||
float _SEBdot_error;
|
||||
|
||||
// Time since last update of main TECS loop (seconds)
|
||||
float _DT;
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ public:
|
||||
|
||||
for (unsigned int i = 0; i < M; i++)
|
||||
for (unsigned int j = 0; j < N; j++)
|
||||
res[i][j] = data[i][j] / num;
|
||||
res.data[i][j] = data[i][j] / num;
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ public:
|
||||
printf("[ ");
|
||||
|
||||
for (unsigned int j = 0; j < N; j++)
|
||||
printf("%.3f\t", data[i][j]);
|
||||
printf("%.3f\t", (double)data[i][j]);
|
||||
|
||||
printf(" ]\n");
|
||||
}
|
||||
|
||||
@@ -46,8 +46,6 @@
|
||||
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
#define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC 1
|
||||
|
||||
#define EIGEN_MAX_STATIC_ALIGN_BYTES 16
|
||||
|
||||
#include <eigen/Eigen/Core>
|
||||
#include <eigen/Eigen/Geometry>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
+1
-1
Submodule src/lib/uavcan updated: 988e404586...3ae5400aa5
Reference in New Issue
Block a user