Gruppe 3
/
PES3
hallo
Fork of PES1 by
Roboter.h@18:3ee1b02ed3aa, 2017-05-09 (annotated)
- Committer:
- itslinear
- Date:
- Tue May 09 15:25:54 2017 +0000
- Revision:
- 18:3ee1b02ed3aa
- Parent:
- 17:caf5ae550f2e
- Child:
- 19:adae367247d4
new
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
itslinear | 0:306a2438de17 | 1 | #ifndef ROBOTER_H |
itslinear | 0:306a2438de17 | 2 | #define ROBOTER_H |
itslinear | 0:306a2438de17 | 3 | |
itslinear | 0:306a2438de17 | 4 | #include <mbed.h> |
itslinear | 0:306a2438de17 | 5 | #include "IRSensor.h" |
schneju2 | 2:953263712480 | 6 | #include "Servo.h" |
Shukle | 10:75a18bf17c86 | 7 | #include "readCamera.h" |
itslinear | 18:3ee1b02ed3aa | 8 | #include "EncoderCounter.h" |
itslinear | 18:3ee1b02ed3aa | 9 | #include "LowpassFilter.h" |
itslinear | 18:3ee1b02ed3aa | 10 | |
itslinear | 0:306a2438de17 | 11 | |
itslinear | 1:4e84271a70c6 | 12 | class Roboter |
itslinear | 0:306a2438de17 | 13 | { |
itslinear | 1:4e84271a70c6 | 14 | |
itslinear | 0:306a2438de17 | 15 | public: |
itslinear | 0:306a2438de17 | 16 | |
itslinear | 18:3ee1b02ed3aa | 17 | Roboter(AnalogIn* distance, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, PwmOut* pwmL, PwmOut* pwmR, Servo* servo1, Servo* servo2, EncoderCounter* counterLeft, EncoderCounter* counterRight, DigitalOut* enableMotorDriver); |
itslinear | 1:4e84271a70c6 | 18 | |
itslinear | 1:4e84271a70c6 | 19 | void bandeAusweichen(); |
itslinear | 1:4e84271a70c6 | 20 | float readSensor1(); |
itslinear | 18:3ee1b02ed3aa | 21 | int pickup(); |
itslinear | 18:3ee1b02ed3aa | 22 | void anfahren(float cam); |
itslinear | 18:3ee1b02ed3aa | 23 | int geradeFahren(); |
itslinear | 18:3ee1b02ed3aa | 24 | int kreisFahren(); |
itslinear | 18:3ee1b02ed3aa | 25 | int stateAuswahl(float cam, int temp); |
itslinear | 18:3ee1b02ed3aa | 26 | void initSpeedcontrol(); |
itslinear | 18:3ee1b02ed3aa | 27 | void speedCtrl(); |
itslinear | 6:4af735d26b7a | 28 | |
itslinear | 3:24e098715b78 | 29 | |
itslinear | 0:306a2438de17 | 30 | |
itslinear | 18:3ee1b02ed3aa | 31 | static const float PERIOD = 0.001f; // period of control task, given in [s] |
itslinear | 18:3ee1b02ed3aa | 32 | static const float COUNTS_PER_TURN = 1200.0f; // resolution of encoder counter |
itslinear | 18:3ee1b02ed3aa | 33 | static const float LOWPASS_FILTER_FREQUENCY = 300.0f; // frequency of lowpass filter for actual speed values, given in [rad/s] |
itslinear | 18:3ee1b02ed3aa | 34 | static const float KN = 40.0f; // speed constant of motor, given in [rpm/V] |
itslinear | 18:3ee1b02ed3aa | 35 | static const float KP = 0.2f; // speed controller gain, given in [V/rpm] |
itslinear | 18:3ee1b02ed3aa | 36 | static const float MAX_VOLTAGE = 12.0f; // supply voltage for power stage in [V] |
itslinear | 18:3ee1b02ed3aa | 37 | static const float MIN_DUTY_CYCLE = 0.02f; // minimum allowed value for duty cycle (2%) |
itslinear | 18:3ee1b02ed3aa | 38 | static const float MAX_DUTY_CYCLE = 0.98f; // maximum allowed value for duty cycle (98%) |
itslinear | 18:3ee1b02ed3aa | 39 | static const float correction = 0.97f; // Korrekturfaktor für speedControl |
itslinear | 18:3ee1b02ed3aa | 40 | static const float v = 20.0f; // Min. Geschw. |
itslinear | 18:3ee1b02ed3aa | 41 | |
itslinear | 18:3ee1b02ed3aa | 42 | |
itslinear | 1:4e84271a70c6 | 43 | private: |
itslinear | 18:3ee1b02ed3aa | 44 | |
itslinear | 1:4e84271a70c6 | 45 | IRSensor sensors[6]; |
itslinear | 3:24e098715b78 | 46 | |
itslinear | 1:4e84271a70c6 | 47 | PwmOut* pwmL; |
itslinear | 1:4e84271a70c6 | 48 | PwmOut* pwmR; |
itslinear | 18:3ee1b02ed3aa | 49 | Servo* servo1; |
itslinear | 18:3ee1b02ed3aa | 50 | Servo* servo2; |
itslinear | 18:3ee1b02ed3aa | 51 | |
itslinear | 18:3ee1b02ed3aa | 52 | //speed control------------------ |
itslinear | 18:3ee1b02ed3aa | 53 | |
itslinear | 18:3ee1b02ed3aa | 54 | EncoderCounter* counterRight; |
itslinear | 18:3ee1b02ed3aa | 55 | EncoderCounter* counterLeft; |
itslinear | 18:3ee1b02ed3aa | 56 | DigitalOut* enableMotorDriver; |
itslinear | 18:3ee1b02ed3aa | 57 | |
itslinear | 18:3ee1b02ed3aa | 58 | short previousValueCounterRight; |
itslinear | 18:3ee1b02ed3aa | 59 | short previousValueCounterLeft; |
itslinear | 3:24e098715b78 | 60 | |
itslinear | 18:3ee1b02ed3aa | 61 | float desiredSpeedLeft; |
itslinear | 18:3ee1b02ed3aa | 62 | float desiredSpeedRight; |
itslinear | 3:24e098715b78 | 63 | |
itslinear | 18:3ee1b02ed3aa | 64 | float actualSpeedLeft; |
itslinear | 18:3ee1b02ed3aa | 65 | float actualSpeedRight; |
itslinear | 0:306a2438de17 | 66 | |
itslinear | 18:3ee1b02ed3aa | 67 | LowpassFilter speedLeftFilter; |
itslinear | 18:3ee1b02ed3aa | 68 | LowpassFilter speedRightFilter; |
itslinear | 0:306a2438de17 | 69 | |
itslinear | 18:3ee1b02ed3aa | 70 | Ticker t1; |
itslinear | 18:3ee1b02ed3aa | 71 | |
itslinear | 18:3ee1b02ed3aa | 72 | //speed control------------------ |
itslinear | 0:306a2438de17 | 73 | |
itslinear | 1:4e84271a70c6 | 74 | }; |
itslinear | 0:306a2438de17 | 75 | |
itslinear | 1:4e84271a70c6 | 76 | #endif |