aboutsummaryrefslogtreecommitdiff
path: root/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-10-16 21:43:11 +0200
committerLorenz Meier <lm@inf.ethz.ch>2013-10-16 21:43:11 +0200
commit71ac33596836519a341001bb48a8835b8af75cd3 (patch)
treec16c020b2e232e6c658525684a940fe1544572da /src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp
parent4532eca4ef6f6170765062ccd2ca7f29814e0b3a (diff)
downloadpx4-firmware-71ac33596836519a341001bb48a8835b8af75cd3.tar.gz
px4-firmware-71ac33596836519a341001bb48a8835b8af75cd3.tar.bz2
px4-firmware-71ac33596836519a341001bb48a8835b8af75cd3.zip
Small improvements to autoland, ensure that throttle can be shut down close to touch down. Depends on accurate land WP altitude
Diffstat (limited to 'src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp')
-rw-r--r--src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp
index cd4a0d58e..3697af225 100644
--- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp
+++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp
@@ -196,6 +196,8 @@ private:
float throttle_max;
float throttle_cruise;
+ float throttle_land_max;
+
float loiter_hold_radius;
} _parameters; /**< local copies of interesting parameters */
@@ -227,6 +229,8 @@ private:
param_t throttle_max;
param_t throttle_cruise;
+ param_t throttle_land_max;
+
param_t loiter_hold_radius;
} _parameter_handles; /**< handles for interesting parameters */
@@ -342,6 +346,7 @@ FixedwingPositionControl::FixedwingPositionControl() :
_parameter_handles.throttle_min = param_find("FW_THR_MIN");
_parameter_handles.throttle_max = param_find("FW_THR_MAX");
_parameter_handles.throttle_cruise = param_find("FW_THR_CRUISE");
+ _parameter_handles.throttle_land_max = param_find("FW_THR_LND_MAX");
_parameter_handles.time_const = param_find("FW_T_TIME_CONST");
_parameter_handles.min_sink_rate = param_find("FW_T_SINK_MIN");
@@ -404,6 +409,8 @@ FixedwingPositionControl::parameters_update()
param_get(_parameter_handles.throttle_max, &(_parameters.throttle_max));
param_get(_parameter_handles.throttle_cruise, &(_parameters.throttle_cruise));
+ param_get(_parameter_handles.throttle_land_max, &(_parameters.throttle_land_max));
+
param_get(_parameter_handles.time_const, &(_parameters.time_const));
param_get(_parameter_handles.min_sink_rate, &(_parameters.min_sink_rate));
param_get(_parameter_handles.max_sink_rate, &(_parameters.max_sink_rate));
@@ -625,6 +632,9 @@ FixedwingPositionControl::control_position(const math::Vector2f &current_positio
_tecs.update_50hz(baro_altitude, _airspeed.indicated_airspeed_m_s, _R_nb, accel_body, accel_earth);
float altitude_error = _global_triplet.current.altitude - _global_pos.alt;
+ /* no throttle limit as default */
+ float throttle_max = 1.0f;
+
/* AUTONOMOUS FLIGHT */
// XXX this should only execute if auto AND safety off (actuators active),
@@ -634,11 +644,12 @@ FixedwingPositionControl::control_position(const math::Vector2f &current_positio
/* get circle mode */
bool was_circle_mode = _l1_control.circle_mode();
+ /* restore speed weight, in case changed intermittently (e.g. in landing handling) */
+ _tecs.set_speed_weight(_parameters.speed_weight);
+
/* execute navigation once we have a setpoint */
if (_setpoint_valid) {
- float altitude_error = _global_triplet.current.altitude - _global_pos.alt;
-
/* current waypoint (the one currently heading for) */
math::Vector2f next_wp(global_triplet.current.lat / 1e7f, global_triplet.current.lon / 1e7f);
@@ -712,16 +723,23 @@ FixedwingPositionControl::control_position(const math::Vector2f &current_positio
/* apply minimum pitch (flare) and limit roll if close to touch down, altitude error is negative (going down) */
// XXX this could make a great param
- if (altitude_error > -20.0f) {
- float flare_angle_rad = math::radians(15.0f);//math::radians(global_triplet.current.param1)
+ if (altitude_error > -10.0f) {
+
+ float flare_angle_rad = math::radians(10.0f);//math::radians(global_triplet.current.param1)
+
+ /* set the speed weight to 0.0 to push the system to control altitude with pitch */
+ _tecs.set_speed_weight(0.0f);
_tecs.update_pitch_throttle(_R_nb, _att.pitch, _global_pos.alt, _global_triplet.current.altitude, calculate_target_airspeed(_parameters.airspeed_min),
_airspeed.indicated_airspeed_m_s, eas2tas,
- true, flare_angle_rad,
+ false, flare_angle_rad,
_parameters.throttle_min, _parameters.throttle_max, _parameters.throttle_cruise,
math::radians(_parameters.pitch_limit_min), math::radians(_parameters.pitch_limit_max));
+ /* kill the throttle if param requests it */
+ throttle_max = math::min(throttle_max, _parameters.throttle_land_max);
+
/* limit roll motion to prevent wings from touching the ground first */
_att_sp.roll_body = math::constrain(_att_sp.roll_body, math::radians(-20.0f), math::radians(20.0f));
@@ -785,7 +803,7 @@ FixedwingPositionControl::control_position(const math::Vector2f &current_positio
_loiter_hold = true;
}
- float altitude_error = _loiter_hold_alt - _global_pos.alt;
+ altitude_error = _loiter_hold_alt - _global_pos.alt;
math::Vector2f loiter_hold_pos(_loiter_hold_lat, _loiter_hold_lon);
@@ -862,7 +880,7 @@ FixedwingPositionControl::control_position(const math::Vector2f &current_positio
}
_att_sp.pitch_body = _tecs.get_pitch_demand();
- _att_sp.thrust = _tecs.get_throttle_demand();
+ _att_sp.thrust = math::min(_tecs.get_throttle_demand(), throttle_max);
return setpoint;
}