Browse Source

change altctl throttle deadband to 2 point curve

sbg
Mark Whitehorn 9 years ago committed by tumbili
parent
commit
101ac63737
  1. 13
      src/modules/mc_pos_control/mc_pos_control_main.cpp

13
src/modules/mc_pos_control/mc_pos_control_main.cpp

@ -122,6 +122,7 @@ public: @@ -122,6 +122,7 @@ public:
private:
const float alt_ctl_dz = 0.1f;
const float alt_ctl_dy = 0.05f;
bool _task_should_exit; /**< if true, task should exit */
int _control_task; /**< task handle for task */
@ -268,7 +269,7 @@ private: @@ -268,7 +269,7 @@ private:
*/
void poll_subscriptions();
static float scale_control(float ctl, float end, float dz);
static float scale_control(float ctl, float end, float dz, float dy);
/**
* Update reference for local position projection
@ -635,16 +636,16 @@ MulticopterPositionControl::poll_subscriptions() @@ -635,16 +636,16 @@ MulticopterPositionControl::poll_subscriptions()
}
float
MulticopterPositionControl::scale_control(float ctl, float end, float dz)
MulticopterPositionControl::scale_control(float ctl, float end, float dz, float dy)
{
if (ctl > dz) {
return (ctl - dz) / (end - dz);
return dy + (ctl - dz) * (1.0f - dy) / (end - dz);
} else if (ctl < -dz) {
return (ctl + dz) / (end - dz);
return -dy + (ctl + dz) * (1.0f - dy) / (end - dz);
} else {
return 0.0f;
return ctl * (dy / dz);
}
}
@ -737,7 +738,7 @@ MulticopterPositionControl::control_manual(float dt) @@ -737,7 +738,7 @@ MulticopterPositionControl::control_manual(float dt)
if (_control_mode.flag_control_altitude_enabled) {
/* set vertical velocity setpoint with throttle stick */
req_vel_sp(2) = -scale_control(_manual.z - 0.5f, 0.5f, alt_ctl_dz); // D
req_vel_sp(2) = -scale_control(_manual.z - 0.5f, 0.5f, alt_ctl_dz, alt_ctl_dy); // D
}
if (_control_mode.flag_control_position_enabled) {

Loading…
Cancel
Save