most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown
Dependencies: mbed MODSERIAL FATFileSystem
Diff: OuterLoop/OuterLoop.hpp
- Revision:
- 10:085ab7328054
- Child:
- 11:3b241ecb75ed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OuterLoop/OuterLoop.hpp Mon Oct 23 12:50:53 2017 +0000 @@ -0,0 +1,69 @@ +#ifndef OUTERLOOP_HPP +#define OUTERLOOP_HPP + +#include "mbed.h" +#include "PidController.hpp" +#include "PosVelFilter.hpp" + +// This class is an outer loop controller with its own instance of a position velocity filter. + +class OuterLoop { +public: + OuterLoop(float interval, int sensor); + + // functions for setting up + void init(); + void update(); + void start(); + void stop(); + + // setting and getting variables + void setCommand(float cmd); + float getOutput(); + + float getPosition(); + float getVelocity(); + + void setControllerP(float P); + float getControllerP(); + + void setControllerI(float I); + float getControllerI(); + + void setControllerD(float D); + float getControllerD(); + + void setTravelLimit(float limit); + float getTravelLimit(); + + void setFilterFrequency(float frequency); + float getFilterFrequency; + + void setDeadband(float deadband); + bool toggleDeadband(bool toggle); + +protected: + PosVelFilter _filter; + PIDController _pid; + Ticker _pulse; + + void refreshPVState(); + + float _SetPoint; + float _sensorVal; + + // position and velocity in raw units + float _position; + float _velocity; + + // setup parameters + float _Pgain; + float _Igain; + float _Dgain; + float _dt; + float _filterFrequency; + float _deadband; + char _sensor; +}; + +#endif \ No newline at end of file