hallo

Dependencies:   Servo mbed pixy

Fork of PES1 by Gruppe 3

Committer:
itslinear
Date:
Sat May 13 16:50:57 2017 +0000
Revision:
20:a90e5b54bf7b
Parent:
19:adae367247d4
Child:
21:69ee872b8ee9
huiiii

Who changed what in which revision?

UserRevisionLine numberNew 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 19:adae367247d4 19 void ausweichen1();
itslinear 19:adae367247d4 20 int ausweichen2();
itslinear 19:adae367247d4 21 int readSensors();
itslinear 18:3ee1b02ed3aa 22 int pickup();
itslinear 18:3ee1b02ed3aa 23 void anfahren(float cam);
itslinear 18:3ee1b02ed3aa 24 int geradeFahren();
itslinear 18:3ee1b02ed3aa 25 int kreisFahren();
itslinear 20:a90e5b54bf7b 26 int stateAuswahl(float cam, int tempState, int temp);
itslinear 18:3ee1b02ed3aa 27 void initSpeedcontrol();
itslinear 18:3ee1b02ed3aa 28 void speedCtrl();
itslinear 19:adae367247d4 29 int back();
itslinear 6:4af735d26b7a 30
itslinear 3:24e098715b78 31
itslinear 0:306a2438de17 32
itslinear 18:3ee1b02ed3aa 33 static const float PERIOD = 0.001f; // period of control task, given in [s]
itslinear 18:3ee1b02ed3aa 34 static const float COUNTS_PER_TURN = 1200.0f; // resolution of encoder counter
itslinear 18:3ee1b02ed3aa 35 static const float LOWPASS_FILTER_FREQUENCY = 300.0f; // frequency of lowpass filter for actual speed values, given in [rad/s]
itslinear 18:3ee1b02ed3aa 36 static const float KN = 40.0f; // speed constant of motor, given in [rpm/V]
itslinear 18:3ee1b02ed3aa 37 static const float KP = 0.2f; // speed controller gain, given in [V/rpm]
itslinear 18:3ee1b02ed3aa 38 static const float MAX_VOLTAGE = 12.0f; // supply voltage for power stage in [V]
itslinear 18:3ee1b02ed3aa 39 static const float MIN_DUTY_CYCLE = 0.02f; // minimum allowed value for duty cycle (2%)
itslinear 18:3ee1b02ed3aa 40 static const float MAX_DUTY_CYCLE = 0.98f; // maximum allowed value for duty cycle (98%)
itslinear 18:3ee1b02ed3aa 41 static const float correction = 0.97f; // Korrekturfaktor für speedControl
itslinear 18:3ee1b02ed3aa 42 static const float v = 20.0f; // Min. Geschw.
itslinear 18:3ee1b02ed3aa 43
itslinear 18:3ee1b02ed3aa 44
itslinear 1:4e84271a70c6 45 private:
itslinear 18:3ee1b02ed3aa 46
itslinear 1:4e84271a70c6 47 IRSensor sensors[6];
itslinear 3:24e098715b78 48
itslinear 1:4e84271a70c6 49 PwmOut* pwmL;
itslinear 1:4e84271a70c6 50 PwmOut* pwmR;
itslinear 18:3ee1b02ed3aa 51 Servo* servo1;
itslinear 18:3ee1b02ed3aa 52 Servo* servo2;
itslinear 18:3ee1b02ed3aa 53
itslinear 18:3ee1b02ed3aa 54 //speed control------------------
itslinear 18:3ee1b02ed3aa 55
itslinear 18:3ee1b02ed3aa 56 EncoderCounter* counterRight;
itslinear 18:3ee1b02ed3aa 57 EncoderCounter* counterLeft;
itslinear 18:3ee1b02ed3aa 58 DigitalOut* enableMotorDriver;
itslinear 18:3ee1b02ed3aa 59
itslinear 18:3ee1b02ed3aa 60 short previousValueCounterRight;
itslinear 18:3ee1b02ed3aa 61 short previousValueCounterLeft;
itslinear 3:24e098715b78 62
itslinear 18:3ee1b02ed3aa 63 float desiredSpeedLeft;
itslinear 18:3ee1b02ed3aa 64 float desiredSpeedRight;
itslinear 3:24e098715b78 65
itslinear 18:3ee1b02ed3aa 66 float actualSpeedLeft;
itslinear 18:3ee1b02ed3aa 67 float actualSpeedRight;
itslinear 0:306a2438de17 68
itslinear 18:3ee1b02ed3aa 69 LowpassFilter speedLeftFilter;
itslinear 18:3ee1b02ed3aa 70 LowpassFilter speedRightFilter;
itslinear 0:306a2438de17 71
itslinear 18:3ee1b02ed3aa 72 Ticker t1;
itslinear 18:3ee1b02ed3aa 73
itslinear 18:3ee1b02ed3aa 74 //speed control------------------
itslinear 0:306a2438de17 75
itslinear 1:4e84271a70c6 76 };
itslinear 0:306a2438de17 77
itslinear 1:4e84271a70c6 78 #endif