Corrected header file include guards.

Fork of HipControl by Bradley Perry

Committer:
nathanhonka
Date:
Thu Jul 02 21:36:58 2015 +0000
Revision:
2:18e264a5b71d
Parent:
1:d87dac5c3658
Corrected header file include guards (did not encapsulate entire header).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
perr1940 0:911517b34248 1 #ifndef HIPCONTROL_H
perr1940 0:911517b34248 2 #define HIPCONTROL_H
perr1940 0:911517b34248 3
perr1940 0:911517b34248 4 /**
perr1940 0:911517b34248 5 * Copyright (c) 2012-2014
perr1940 0:911517b34248 6 * All rights reserved.
perr1940 0:911517b34248 7 *
perr1940 0:911517b34248 8 *
perr1940 0:911517b34248 9 * by Bradley Perry
perr1940 0:911517b34248 10 *
perr1940 0:911517b34248 11 */
perr1940 0:911517b34248 12
perr1940 0:911517b34248 13
perr1940 0:911517b34248 14 /**
perr1940 0:911517b34248 15 * Control strategys for Daniel's Device
perr1940 0:911517b34248 16 *
perr1940 0:911517b34248 17 * @file control.h
perr1940 0:911517b34248 18 * @author Bradley Perry
perr1940 0:911517b34248 19 *
perr1940 0:911517b34248 20 * @brief Control algorithms
perr1940 0:911517b34248 21 */
perr1940 0:911517b34248 22
perr1940 1:d87dac5c3658 23 //TODO: (Brad) Port to base-class structure
perr1940 1:d87dac5c3658 24
perr1940 0:911517b34248 25 #include "mbed.h"
perr1940 0:911517b34248 26 #include "filter.h"
perr1940 0:911517b34248 27
perr1940 0:911517b34248 28 class HipControl
perr1940 0:911517b34248 29 {
perr1940 0:911517b34248 30 public:
perr1940 0:911517b34248 31 HipControl(PinName pwm, PinName dirpin);
perr1940 1:d87dac5c3658 32
perr1940 1:d87dac5c3658 33 /**
perr1940 1:d87dac5c3658 34 * Feedback linearization and gain scheduling controller. Used for all hip trajectory following.
perr1940 1:d87dac5c3658 35 * @param ref Reference point to track.
perr1940 1:d87dac5c3658 36 * @param pos Current position in degrees
perr1940 1:d87dac5c3658 37 * @param Kp Proportional gain
perr1940 1:d87dac5c3658 38 * @param Kd Derivative gain
perr1940 1:d87dac5c3658 39 * @param sat Commanded current saturation
perr1940 1:d87dac5c3658 40 */
perr1940 1:d87dac5c3658 41 //class
perr1940 0:911517b34248 42 void FL(float ref, float pos);
perr1940 1:d87dac5c3658 43
perr1940 1:d87dac5c3658 44 /**
perr1940 1:d87dac5c3658 45 * Vanilla PD controller for set-point tracking. Mostly used for haptics.
perr1940 1:d87dac5c3658 46 * @param ref Reference point to track.
perr1940 1:d87dac5c3658 47 * @param pos Current position in degrees
perr1940 1:d87dac5c3658 48 * @param Kp Proportional gain
perr1940 1:d87dac5c3658 49 * @param Kd Derivative gain
perr1940 1:d87dac5c3658 50 * @param sat Commanded current saturation
perr1940 1:d87dac5c3658 51 */
perr1940 1:d87dac5c3658 52 //class
perr1940 0:911517b34248 53 void PD(float ref, float pos);
perr1940 1:d87dac5c3658 54 //class
perr1940 0:911517b34248 55 void P(float ref, float pos);
perr1940 1:d87dac5c3658 56 //base method
perr1940 0:911517b34248 57 void setGains(float P, float D);
perr1940 1:d87dac5c3658 58 //base method
perr1940 0:911517b34248 59 void setSat(float limit);
perr1940 1:d87dac5c3658 60 //base method
perr1940 0:911517b34248 61 void sampleTime(float time);
perr1940 1:d87dac5c3658 62 //class
perr1940 0:911517b34248 63 void openLoop(float input);
perr1940 1:d87dac5c3658 64 //base method
perr1940 1:d87dac5c3658 65 float readPWM();
perr1940 1:d87dac5c3658 66 //class
perr1940 0:911517b34248 67 void off();
perr1940 1:d87dac5c3658 68 //base method
perr1940 0:911517b34248 69 void flip();
perr1940 1:d87dac5c3658 70 //base method
perr1940 0:911517b34248 71 void clear();
perr1940 1:d87dac5c3658 72 //base method
perr1940 0:911517b34248 73 void pwmPeriod(float a);
perr1940 0:911517b34248 74 private:
perr1940 0:911517b34248 75 //Controller Parameters
perr1940 0:911517b34248 76 //const float Kp=.05;
perr1940 0:911517b34248 77 PwmOut _pwm;
perr1940 0:911517b34248 78 DigitalOut _dir;
perr1940 0:911517b34248 79 float Kp;
perr1940 1:d87dac5c3658 80 /**
perr1940 1:d87dac5c3658 81 * Initial proportional gain before cosine gain schedule
perr1940 1:d87dac5c3658 82 */
perr1940 0:911517b34248 83 const float Kp0;
perr1940 1:d87dac5c3658 84 /**
perr1940 1:d87dac5c3658 85 * Derivative gain
perr1940 1:d87dac5c3658 86 */
perr1940 0:911517b34248 87 float Kd;
perr1940 1:d87dac5c3658 88 /**
perr1940 1:d87dac5c3658 89 * Commanded current saturation
perr1940 1:d87dac5c3658 90 */
perr1940 0:911517b34248 91 float sat;
perr1940 0:911517b34248 92 float u;
perr1940 0:911517b34248 93 float u_prev;
perr1940 0:911517b34248 94 float error[2];
perr1940 1:d87dac5c3658 95 //sample period
perr1940 1:d87dac5c3658 96 float _sample_period;
perr1940 0:911517b34248 97 int sign;
perr1940 0:911517b34248 98 filter controlFilter;
perr1940 0:911517b34248 99 };
perr1940 0:911517b34248 100
perr1940 0:911517b34248 101 //Controller Parameters
perr1940 0:911517b34248 102
perr1940 1:d87dac5c3658 103
perr1940 0:911517b34248 104 /**
perr1940 0:911517b34248 105 * Counter for proportional gain cosine gain scheduling
perr1940 0:911517b34248 106 */
perr1940 0:911517b34248 107 /**
perr1940 0:911517b34248 108 * Vector to store error data
perr1940 0:911517b34248 109 */
perr1940 0:911517b34248 110
perr1940 0:911517b34248 111 /**
perr1940 0:911517b34248 112 * Cosine magnitude for gain scheduling
perr1940 0:911517b34248 113 */
perr1940 0:911517b34248 114 /**
perr1940 0:911517b34248 115 * Cosine frequency for gain scheduling
perr1940 0:911517b34248 116 */
perr1940 0:911517b34248 117 /**
perr1940 0:911517b34248 118 * Offset for gain scheduling
perr1940 0:911517b34248 119 */
perr1940 0:911517b34248 120
perr1940 0:911517b34248 121 #endif
perr1940 0:911517b34248 122
perr1940 0:911517b34248 123
perr1940 1:d87dac5c3658 124