LP-89 - Port OP_15.05.01 fixes. Release notes:
[librepilot.git] / flight / modules / PathFollower / inc / pidcontrolne.h
blobdba5d59bbc71223be116a9e611de76f94883e71d
1 /**
2 ******************************************************************************
3 * @addtogroup OpenPilotModules OpenPilot Modules
4 * @{
5 * @addtogroup PathFollower CONTROL interface class
6 * @brief PID Controler for NE Class definition
7 * @{
9 * @file pidcontrolne.h
10 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2015.
11 * @brief Executes pid control loop for NE
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
25 * for more details.
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 PIDCONTROLNE_H
32 #define PIDCONTROLNE_H
33 extern "C" {
34 #include <pid.h>
36 #include "pathfollowerfsm.h"
38 class PIDControlNE {
39 public:
40 PIDControlNE();
41 ~PIDControlNE();
42 void Deactivate();
43 void Activate();
44 void UpdateParameters(float kp, float ki, float kd, __attribute__((unused)) float ilimit, float dT, float velocityMax);
45 void UpdatePositionalParameters(float kp);
46 void UpdatePositionState(float pvNorth, float pvEast);
47 void UpdatePositionSetpoint(float setpointNorth, float setpointEast);
48 void UpdateVelocitySetpoint(float setpointNorth, float setpointEast);
49 // void RateLimit(float *spDesired, float *spCurrent, float rateLimit);
50 void UpdateVelocityState(float pvNorth, float pvEast);
51 void UpdateCommandParameters(float minCommand, float maxCommand, float velocityFeedforward);
52 void ControlPosition();
53 void ControlPositionWithPath(struct path_status *progress);
54 void GetNECommand(float *northCommand, float *eastCommand);
55 void GetVelocityDesired(float *north, float *east);
56 void UpdateBrakeVelocity(float startingVelocity, float dT, float brakeRate, float currentVelocity, float *updatedVelocity);
57 void UpdateVelocityStateWithBrake(float pvNorth, float pvEast, float path_time, float brakeRate);
59 private:
60 struct pid2 PIDvel[2]; // North, East
61 float mVelocitySetpointTarget[2];
62 float mVelocityState[2];
63 struct pid PIDposH[2];
64 float mPositionSetpointTarget[2];
65 float mPositionState[2];
68 float deltaTime;
69 float mVelocitySetpointCurrent[2];
70 float mNECommand;
71 float mNeutral;
72 float mVelocityMax;
73 float mMinCommand;
74 float mMaxCommand;
75 float mVelocityFeedforward;
76 uint8_t mActive;
79 #endif // PIDCONTROLNE_H