a

Dependencies:   Servo ServoArm mbed

Fork of PES_Official-TestF by zhaw_st16b_pes2_10

Committer:
beacon
Date:
Mon May 15 17:35:24 2017 +0000
Revision:
16:f157e5ccd7d3
Parent:
15:915f8839fe48
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
beacon 0:d267b248eff4 1 #ifndef ROBOT_H
beacon 0:d267b248eff4 2 #define ROBOT_H
beacon 0:d267b248eff4 3
beacon 0:d267b248eff4 4 #include <cstdlib>
beacon 0:d267b248eff4 5 #include <mbed.h>
beacon 4:67d7177c213f 6 #include "Servo.h"
beacon 10:f76476943a6c 7 #include "ServoArm.h"
beacon 0:d267b248eff4 8
beacon 0:d267b248eff4 9 #include "mbed.h"
beacon 0:d267b248eff4 10
beacon 0:d267b248eff4 11
beacon 0:d267b248eff4 12 /* Declarations for the Motors in the Robot in order to drive -------- */
beacon 1:388c915756f5 13
beacon 1:388c915756f5 14 class DistanceSensors
beacon 1:388c915756f5 15 {
beacon 1:388c915756f5 16 public:
beacon 1:388c915756f5 17
beacon 4:67d7177c213f 18 DistanceSensors(AnalogIn* sensorVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number);
beacon 1:388c915756f5 19 DistanceSensors();
beacon 1:388c915756f5 20
beacon 4:67d7177c213f 21 void init(AnalogIn* sensorVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number);
beacon 1:388c915756f5 22 virtual ~DistanceSensors();
beacon 1:388c915756f5 23 float read();
beacon 1:388c915756f5 24
beacon 1:388c915756f5 25 operator float(); //Is here to constantly return the value of read.
beacon 1:388c915756f5 26
beacon 1:388c915756f5 27 private:
beacon 1:388c915756f5 28
beacon 1:388c915756f5 29 AnalogIn* sensorVoltage;
beacon 4:67d7177c213f 30 AnalogIn* frontS;
beacon 4:67d7177c213f 31 AnalogIn* leftS;
beacon 4:67d7177c213f 32 AnalogIn* rightS;
beacon 4:67d7177c213f 33
beacon 1:388c915756f5 34 DigitalOut* bit0;
beacon 1:388c915756f5 35 DigitalOut* bit1;
beacon 1:388c915756f5 36 DigitalOut* bit2;
beacon 1:388c915756f5 37
beacon 1:388c915756f5 38 int number;
beacon 1:388c915756f5 39
beacon 1:388c915756f5 40 };
beacon 1:388c915756f5 41
beacon 1:388c915756f5 42 class Farbsensor
beacon 1:388c915756f5 43 {
beacon 1:388c915756f5 44 public:
beacon 1:388c915756f5 45
beacon 1:388c915756f5 46 Farbsensor();
beacon 1:388c915756f5 47 Farbsensor(AnalogIn* FarbVoltage);
beacon 1:388c915756f5 48
beacon 1:388c915756f5 49 void init(AnalogIn* FarbVoltage);
beacon 1:388c915756f5 50 int read();
beacon 1:388c915756f5 51 operator int();
beacon 1:388c915756f5 52
beacon 1:388c915756f5 53 private:
beacon 1:388c915756f5 54
beacon 1:388c915756f5 55 AnalogIn* FarbVoltage;
beacon 1:388c915756f5 56 };
beacon 6:ba26dd3251b3 57
beacon 4:67d7177c213f 58 class Arm{
beacon 4:67d7177c213f 59
beacon 4:67d7177c213f 60 public:
beacon 6:ba26dd3251b3 61
beacon 4:67d7177c213f 62 Arm();
beacon 10:f76476943a6c 63 Arm(ServoArm* servoArm);
beacon 4:67d7177c213f 64
beacon 10:f76476943a6c 65 void init(ServoArm* servoArm);
beacon 6:ba26dd3251b3 66
beacon 11:292bdbd85a9c 67 int collectToDown();
beacon 11:292bdbd85a9c 68 int downToCollect();
beacon 11:292bdbd85a9c 69 int collectToBack();
beacon 11:292bdbd85a9c 70 int backToCollect();
beacon 4:67d7177c213f 71
beacon 4:67d7177c213f 72 private:
beacon 10:f76476943a6c 73 ServoArm* arm;
beacon 6:ba26dd3251b3 74 float angle;
beacon 4:67d7177c213f 75
beacon 4:67d7177c213f 76 };
beacon 1:388c915756f5 77
EpicG10 14:b61fbd13a7c9 78 class Leiste{
EpicG10 14:b61fbd13a7c9 79
EpicG10 14:b61fbd13a7c9 80 public:
EpicG10 14:b61fbd13a7c9 81
EpicG10 14:b61fbd13a7c9 82 Leiste();
EpicG10 14:b61fbd13a7c9 83 Leiste(Servo* servoLeiste);
EpicG10 14:b61fbd13a7c9 84
EpicG10 14:b61fbd13a7c9 85 void init(Servo* servoLeiste);
EpicG10 14:b61fbd13a7c9 86
beacon 16:f157e5ccd7d3 87 int upToDown();
beacon 16:f157e5ccd7d3 88 int downToUp();
EpicG10 14:b61fbd13a7c9 89
EpicG10 14:b61fbd13a7c9 90
EpicG10 14:b61fbd13a7c9 91 private:
EpicG10 14:b61fbd13a7c9 92 Servo* leiste;
EpicG10 14:b61fbd13a7c9 93
EpicG10 14:b61fbd13a7c9 94
EpicG10 14:b61fbd13a7c9 95 };
EpicG10 14:b61fbd13a7c9 96
beacon 10:f76476943a6c 97 class Greifer
beacon 10:f76476943a6c 98 {
beacon 10:f76476943a6c 99
beacon 10:f76476943a6c 100 public:
beacon 10:f76476943a6c 101
beacon 10:f76476943a6c 102 Greifer(Servo* greifer);
beacon 10:f76476943a6c 103 Greifer();
beacon 10:f76476943a6c 104
beacon 10:f76476943a6c 105 void init(Servo* greifer);
beacon 11:292bdbd85a9c 106 int take();
beacon 11:292bdbd85a9c 107 int leave();
EpicG10 15:915f8839fe48 108 void nullPos();
beacon 10:f76476943a6c 109
beacon 10:f76476943a6c 110 private:
beacon 10:f76476943a6c 111 Servo* greifer;
beacon 10:f76476943a6c 112
beacon 10:f76476943a6c 113 };
beacon 10:f76476943a6c 114
beacon 0:d267b248eff4 115 class Robot
beacon 0:d267b248eff4 116 {
beacon 0:d267b248eff4 117
beacon 0:d267b248eff4 118 public:
beacon 0:d267b248eff4 119
beacon 0:d267b248eff4 120 //Robot related:
EpicG10 15:915f8839fe48 121 Robot(PwmOut* left, PwmOut* right, DigitalOut* powerSignal, DigitalOut* leds, AnalogIn* FarbVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, ServoArm* Arm, Servo* Greifer, Servo* Leiste );
beacon 4:67d7177c213f 122
beacon 4:67d7177c213f 123 //Drive Functions
beacon 0:d267b248eff4 124 void drive();
beacon 4:67d7177c213f 125 void driveB();
beacon 4:67d7177c213f 126
beacon 0:d267b248eff4 127 void turnLeft();
beacon 4:67d7177c213f 128 void turnLeftS();
beacon 0:d267b248eff4 129 void turnRight();
beacon 4:67d7177c213f 130 void turnRightS();
beacon 0:d267b248eff4 131 void turnAround(int left);
beacon 1:388c915756f5 132 void stop();
beacon 1:388c915756f5 133
beacon 4:67d7177c213f 134 //Functions that use the drive functions
beacon 16:f157e5ccd7d3 135 void driveSlowly();
beacon 16:f157e5ccd7d3 136 void driveBackSlowly();
beacon 4:67d7177c213f 137 void wallRight(int* counter, int* timer, int* lastAct);
beacon 4:67d7177c213f 138 void wallLeft(int* counter, int* timer, int* lastAct);
beacon 4:67d7177c213f 139 void wallFront(int* counter, int* timer, int* lastAct);
beacon 4:67d7177c213f 140 void counterMax(int* counter, int* timer, int* lastAct, int* rando);
beacon 4:67d7177c213f 141
beacon 5:1aaf5de776ff 142 void legoFront(int* counter, int* timer, int* lastAct, int* legoFound, int* found);
beacon 4:67d7177c213f 143 void legoRight(int* counter, int* timer, int* lastAct, int* legoFound);
beacon 4:67d7177c213f 144 void legoLeft(int* counter, int* timer, int* lastAct, int* legoFound);
beacon 4:67d7177c213f 145
beacon 4:67d7177c213f 146 void nothingFound(int* counter, int* timer, int* lastAct);
beacon 4:67d7177c213f 147
beacon 11:292bdbd85a9c 148 int search(int* timer);
beacon 10:f76476943a6c 149
beacon 10:f76476943a6c 150 int getErrorMotor();
beacon 0:d267b248eff4 151
beacon 0:d267b248eff4 152 //DistanceSensors related:
beacon 4:67d7177c213f 153 DistanceSensors sensors[9];
beacon 4:67d7177c213f 154 AnalogIn* frontS;
beacon 4:67d7177c213f 155 AnalogIn* leftS;
beacon 4:67d7177c213f 156 AnalogIn* rightS;
beacon 4:67d7177c213f 157
beacon 1:388c915756f5 158
beacon 1:388c915756f5 159 void initializeDistanceSensors();
beacon 1:388c915756f5 160 //void init();
beacon 0:d267b248eff4 161
beacon 1:388c915756f5 162 //LEDS related:
beacon 6:ba26dd3251b3 163 DigitalOut* leds;
beacon 0:d267b248eff4 164
beacon 1:388c915756f5 165 //Farbsensors related:
beacon 6:ba26dd3251b3 166 Farbsensor FarbVoltage;
beacon 6:ba26dd3251b3 167
beacon 6:ba26dd3251b3 168 //Arm related:
beacon 6:ba26dd3251b3 169 Arm Arm;
beacon 0:d267b248eff4 170
beacon 10:f76476943a6c 171 //Greifer related:
beacon 10:f76476943a6c 172 Greifer Greifer;
beacon 10:f76476943a6c 173
EpicG10 15:915f8839fe48 174 //Leiste related:
EpicG10 15:915f8839fe48 175 Leiste Leiste;
EpicG10 15:915f8839fe48 176
beacon 0:d267b248eff4 177 private:
beacon 0:d267b248eff4 178
beacon 0:d267b248eff4 179 //Robot related:
beacon 0:d267b248eff4 180 PwmOut* left;
beacon 0:d267b248eff4 181 PwmOut* right;
beacon 10:f76476943a6c 182 DigitalIn* errorMotor;
beacon 0:d267b248eff4 183
beacon 0:d267b248eff4 184 DigitalOut* powerSignal;
beacon 0:d267b248eff4 185 DigitalIn* errorSignal;
beacon 0:d267b248eff4 186 DigitalIn* overtemperatur;
beacon 0:d267b248eff4 187
beacon 10:f76476943a6c 188 Servo* greifer;
EpicG10 15:915f8839fe48 189 Servo* leiste;
beacon 10:f76476943a6c 190 ServoArm* arm;
beacon 0:d267b248eff4 191 };
beacon 0:d267b248eff4 192
beacon 0:d267b248eff4 193 #endif