2 ******************************************************************************
3 * @addtogroup OpenPilotModules OpenPilot Modules
5 * @addtogroup PathFollower PID Control implementation
6 * @brief PID Controller for down direction
9 * @file PIDControlDown.h
10 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015.
11 * @brief Executes control loop for down direction
13 * @see The GNU Public License (GPL) Version 3
15 *****************************************************************************/
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #ifndef PIDCONTROLDOWN_H
32 #define PIDCONTROLDOWN_H
35 #include <stabilizationdesired.h>
37 #include "pidcontroldowncallback.h"
39 class PIDControlDown
{
43 void Initialize(PIDControlDownCallback
*callback
);
44 void SetThrustLimits(float min_thrust
, float max_thrust
);
51 void UpdateParameters(float kp
, float ki
, float kd
, float beta
, float dT
, float velocityMax
);
52 void UpdateNeutralThrust(float neutral
);
53 void UpdateVelocitySetpoint(float setpoint
);
54 void RateLimit(float *spDesired
, float *spCurrent
, float rateLimit
);
55 void UpdateVelocityState(float pv
);
56 float GetVelocityDesired(void);
57 float GetDownCommand(void);
58 void UpdatePositionalParameters(float kp
);
59 void UpdatePositionState(float pvDown
);
60 void UpdatePositionSetpoint(float setpointDown
);
61 void ControlPosition();
62 void ControlPositionWithPath(struct path_status
*progress
);
63 void UpdateBrakeVelocity(float startingVelocity
, float dT
, float brakeRate
, float currentVelocity
, float *updatedVelocity
);
64 void UpdateVelocityStateWithBrake(float pvDown
, float path_time
, float brakeRate
);
65 void DisableNeutralThrustCalc()
67 mAllowNeutralThrustCalc
= false;
69 void EnableNeutralThrustCalc()
71 mAllowNeutralThrustCalc
= true;
75 void setup_neutralThrustCalc();
76 void run_neutralThrustCalc();
80 float mVelocitySetpointTarget
;
81 float mVelocitySetpointCurrent
;
84 PIDControlDownCallback
*mCallback
;
88 float mPositionSetpointTarget
;
93 struct NeutralThrustEstimation
{
101 bool have_correction
;
103 struct NeutralThrustEstimation neutralThrustEst
;
105 bool mAllowNeutralThrustCalc
;
108 #endif // PIDCONTROLDOWN_H