1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 16:25:26 +03:00

HIL now outputs rcCommand for multicopters and selects between rcCommand and axisPID for airplanes

This commit is contained in:
Konstantin Sharlaimov (DigitalEntity) 2015-12-12 00:00:44 +10:00
parent c15512b4da
commit 0121d81da9
6 changed files with 4 additions and 8 deletions

View file

@ -245,7 +245,6 @@ void resetNavConfig(navConfig_t * navConfig)
// General navigation parameters
navConfig->waypoint_radius = 300;
navConfig->dterm_cut_hz = 15;
navConfig->max_speed = 250;
navConfig->max_manual_speed = 500;
navConfig->max_manual_climb_rate = 200;

View file

@ -56,7 +56,7 @@ void hilUpdateControlState(void)
{
// FIXME: There must be a cleaner way to to this
// If HIL active, store PID outout into hilState and disable motor control
if (FLIGHT_MODE(PASSTHRU_MODE)) {
if (FLIGHT_MODE(PASSTHRU_MODE) || !STATE(FIXED_WING)) {
hilToSIM.pidCommand[ROLL] = rcCommand[ROLL];
hilToSIM.pidCommand[PITCH] = rcCommand[PITCH];
hilToSIM.pidCommand[YAW] = rcCommand[YAW];

View file

@ -1171,10 +1171,7 @@ float navPidApply2(float setpoint, float measurement, float dt, pidController_t
pid->last_input = measurement;
}
if (posControl.navConfig->dterm_cut_hz)
newDerivative = pid->param.kD * filterApplyPt1(newDerivative, &pid->dterm_filter_state, posControl.navConfig->dterm_cut_hz, dt);
else
newDerivative = pid->param.kD * newDerivative;
newDerivative = pid->param.kD * filterApplyPt1(newDerivative, &pid->dterm_filter_state, NAV_DTERM_CUT_HZ, dt);
/* Pre-calculate output and limit it if actuator is saturating */
float outVal = newProportional + pid->integrator + newDerivative;

View file

@ -104,7 +104,6 @@ typedef struct navConfig_s {
uint16_t emerg_descent_rate; // emergency landing descent rate
uint16_t rth_altitude; // altitude to maintain when RTH is active (depends on rth_alt_control_style) (cm)
uint16_t min_rth_distance; // 0 Disables. Minimal distance for RTL in cm, otherwise it will just autoland
uint8_t dterm_cut_hz; // Low pass filter cut frequency for D-term calculation (default 5Hz)
uint8_t pos_hold_deadband; // Adds ability to adjust the Hold-position when moving the sticks (assisted mode)
uint8_t alt_hold_deadband; // Defines the neutral zone of throttle stick during altitude hold

View file

@ -31,6 +31,8 @@
#define NAV_FW_VEL_CUTOFF_FREQENCY_HZ 2 // low-pass filter on Z-velocity for fixed wing
#define NAV_DTERM_CUT_HZ 10
#define NAV_ACCELERATION_XY_MAX 980.0f // cm/s/s // approx 45 deg lean angle
#define HZ2US(hz) (1000000 / (hz))

View file

@ -560,7 +560,6 @@ const clivalue_t valueTable[] = {
{ "nav_use_midrc_for_althold", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.navConfig.flags.use_midrc_for_althold, .config.lookup = { TABLE_OFF_ON }, 0 },
{ "nav_extra_arming_safety", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.navConfig.flags.extra_arming_safety, .config.lookup = { TABLE_OFF_ON }, 0 },
{ "nav_user_control_mode", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.navConfig.flags.user_control_mode, .config.lookup = { TABLE_NAV_USER_CTL_MODE }, 0 },
{ "nav_dterm_cut_hz", VAR_UINT8 | MASTER_VALUE, &masterConfig.navConfig.dterm_cut_hz, .config.minmax = { 0, 100 }, 0 },
{ "nav_wp_radius", VAR_UINT16 | MASTER_VALUE, &masterConfig.navConfig.waypoint_radius, .config.minmax = { 100, 2000 }, 0 },
{ "nav_max_speed", VAR_UINT16 | MASTER_VALUE, &masterConfig.navConfig.max_speed, .config.minmax = { 10, 2000 }, 0 },
{ "nav_manual_speed", VAR_UINT16 | MASTER_VALUE, &masterConfig.navConfig.max_manual_speed, .config.minmax = { 10, 2000 }, 0 },