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

Committer:
tnhnrl
Date:
Tue Jun 12 15:41:51 2018 +0000
Revision:
55:f4ec445c42fe
Working v2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tnhnrl 55:f4ec445c42fe 1 #ifndef OUTERLOOP_HPP
tnhnrl 55:f4ec445c42fe 2 #define OUTERLOOP_HPP
tnhnrl 55:f4ec445c42fe 3
tnhnrl 55:f4ec445c42fe 4 #include "mbed.h"
tnhnrl 55:f4ec445c42fe 5 #include "PidController.hpp"
tnhnrl 55:f4ec445c42fe 6 #include "PosVelFilter.hpp"
tnhnrl 55:f4ec445c42fe 7
tnhnrl 55:f4ec445c42fe 8 // This class is an outer loop controller with its own instance of a position velocity filter.
tnhnrl 55:f4ec445c42fe 9
tnhnrl 55:f4ec445c42fe 10 class OuterLoop {
tnhnrl 55:f4ec445c42fe 11 public:
tnhnrl 55:f4ec445c42fe 12 OuterLoop(float interval, int sensor);
tnhnrl 55:f4ec445c42fe 13
tnhnrl 55:f4ec445c42fe 14 // functions for setting up
tnhnrl 55:f4ec445c42fe 15 void init();
tnhnrl 55:f4ec445c42fe 16 void update();
tnhnrl 55:f4ec445c42fe 17 void start();
tnhnrl 55:f4ec445c42fe 18 void stop();
tnhnrl 55:f4ec445c42fe 19
tnhnrl 55:f4ec445c42fe 20 // setting and getting variables
tnhnrl 55:f4ec445c42fe 21 void setCommand(float cmd);
tnhnrl 55:f4ec445c42fe 22 float getCommand();
tnhnrl 55:f4ec445c42fe 23
tnhnrl 55:f4ec445c42fe 24 float getOutput();
tnhnrl 55:f4ec445c42fe 25
tnhnrl 55:f4ec445c42fe 26 float getPosition();
tnhnrl 55:f4ec445c42fe 27 float getVelocity();
tnhnrl 55:f4ec445c42fe 28
tnhnrl 55:f4ec445c42fe 29 void setControllerP(float P);
tnhnrl 55:f4ec445c42fe 30 float getControllerP();
tnhnrl 55:f4ec445c42fe 31
tnhnrl 55:f4ec445c42fe 32 void setControllerI(float I);
tnhnrl 55:f4ec445c42fe 33 float getControllerI();
tnhnrl 55:f4ec445c42fe 34
tnhnrl 55:f4ec445c42fe 35 void setControllerD(float D);
tnhnrl 55:f4ec445c42fe 36 float getControllerD();
tnhnrl 55:f4ec445c42fe 37
tnhnrl 55:f4ec445c42fe 38 void setTravelLimit(float limit);
tnhnrl 55:f4ec445c42fe 39 float getTravelLimit();
tnhnrl 55:f4ec445c42fe 40
tnhnrl 55:f4ec445c42fe 41 void setFilterFrequency(float frequency);
tnhnrl 55:f4ec445c42fe 42 float getFilterFrequency;
tnhnrl 55:f4ec445c42fe 43
tnhnrl 55:f4ec445c42fe 44 void setDeadband(float deadband);
tnhnrl 55:f4ec445c42fe 45 bool toggleDeadband(bool toggle);
tnhnrl 55:f4ec445c42fe 46
tnhnrl 55:f4ec445c42fe 47 void setOutputOffset(float offset);
tnhnrl 55:f4ec445c42fe 48 float getOutputOffset();
tnhnrl 55:f4ec445c42fe 49
tnhnrl 55:f4ec445c42fe 50 protected:
tnhnrl 55:f4ec445c42fe 51 PosVelFilter _filter;
tnhnrl 55:f4ec445c42fe 52 PIDController _pid;
tnhnrl 55:f4ec445c42fe 53 Ticker _pulse;
tnhnrl 55:f4ec445c42fe 54
tnhnrl 55:f4ec445c42fe 55 void refreshPVState();
tnhnrl 55:f4ec445c42fe 56
tnhnrl 55:f4ec445c42fe 57 float _SetPoint;
tnhnrl 55:f4ec445c42fe 58 float _sensorVal;
tnhnrl 55:f4ec445c42fe 59
tnhnrl 55:f4ec445c42fe 60 // position and velocity in raw units
tnhnrl 55:f4ec445c42fe 61 float _position;
tnhnrl 55:f4ec445c42fe 62 float _velocity;
tnhnrl 55:f4ec445c42fe 63
tnhnrl 55:f4ec445c42fe 64 // setup parameters
tnhnrl 55:f4ec445c42fe 65 float _Pgain;
tnhnrl 55:f4ec445c42fe 66 float _Igain;
tnhnrl 55:f4ec445c42fe 67 float _Dgain;
tnhnrl 55:f4ec445c42fe 68 float _dt;
tnhnrl 55:f4ec445c42fe 69 float _filterFrequency;
tnhnrl 55:f4ec445c42fe 70 float _deadband;
tnhnrl 55:f4ec445c42fe 71 char _sensor;
tnhnrl 55:f4ec445c42fe 72 float _offset;
tnhnrl 55:f4ec445c42fe 73 };
tnhnrl 55:f4ec445c42fe 74
tnhnrl 55:f4ec445c42fe 75 #endif