Do NOT modify!

Dependencies:   mbed Servo ServoArm

Fork of PES_Yanick by zhaw_st16b_pes2_10

Committer:
beacon
Date:
Sat May 06 13:33:23 2017 +0000
Revision:
11:292bdbd85a9c
Parent:
10:f76476943a6c
Nenne dieses Programm "PES_Official" und l?sche das alte.

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
beacon 10:f76476943a6c 78 class Greifer
beacon 10:f76476943a6c 79 {
beacon 10:f76476943a6c 80
beacon 10:f76476943a6c 81 public:
beacon 10:f76476943a6c 82
beacon 10:f76476943a6c 83 Greifer(Servo* greifer);
beacon 10:f76476943a6c 84 Greifer();
beacon 10:f76476943a6c 85
beacon 10:f76476943a6c 86 void init(Servo* greifer);
beacon 11:292bdbd85a9c 87 int take();
beacon 11:292bdbd85a9c 88 int leave();
beacon 10:f76476943a6c 89
beacon 10:f76476943a6c 90 private:
beacon 10:f76476943a6c 91 Servo* greifer;
beacon 10:f76476943a6c 92
beacon 10:f76476943a6c 93 };
beacon 10:f76476943a6c 94
beacon 0:d267b248eff4 95 class Robot
beacon 0:d267b248eff4 96 {
beacon 0:d267b248eff4 97
beacon 0:d267b248eff4 98 public:
beacon 0:d267b248eff4 99
beacon 0:d267b248eff4 100 //Robot related:
beacon 10:f76476943a6c 101 Robot(PwmOut* left, PwmOut* right, DigitalOut* powerSignal, DigitalOut* leds, AnalogIn* FarbVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, ServoArm* Arm, Servo* Greifer );
beacon 4:67d7177c213f 102
beacon 4:67d7177c213f 103 //Drive Functions
beacon 0:d267b248eff4 104 void drive();
beacon 4:67d7177c213f 105 void driveB();
beacon 4:67d7177c213f 106
beacon 0:d267b248eff4 107 void turnLeft();
beacon 4:67d7177c213f 108 void turnLeftS();
beacon 0:d267b248eff4 109 void turnRight();
beacon 4:67d7177c213f 110 void turnRightS();
beacon 0:d267b248eff4 111 void turnAround(int left);
beacon 1:388c915756f5 112 void stop();
beacon 1:388c915756f5 113
beacon 4:67d7177c213f 114 //Functions that use the drive functions
beacon 4:67d7177c213f 115 void wallRight(int* counter, int* timer, int* lastAct);
beacon 4:67d7177c213f 116 void wallLeft(int* counter, int* timer, int* lastAct);
beacon 4:67d7177c213f 117 void wallFront(int* counter, int* timer, int* lastAct);
beacon 4:67d7177c213f 118 void counterMax(int* counter, int* timer, int* lastAct, int* rando);
beacon 4:67d7177c213f 119
beacon 5:1aaf5de776ff 120 void legoFront(int* counter, int* timer, int* lastAct, int* legoFound, int* found);
beacon 4:67d7177c213f 121 void legoRight(int* counter, int* timer, int* lastAct, int* legoFound);
beacon 4:67d7177c213f 122 void legoLeft(int* counter, int* timer, int* lastAct, int* legoFound);
beacon 4:67d7177c213f 123
beacon 4:67d7177c213f 124 void nothingFound(int* counter, int* timer, int* lastAct);
beacon 4:67d7177c213f 125
beacon 11:292bdbd85a9c 126 int search(int* timer);
beacon 10:f76476943a6c 127
beacon 10:f76476943a6c 128 int getErrorMotor();
beacon 0:d267b248eff4 129
beacon 0:d267b248eff4 130 //DistanceSensors related:
beacon 4:67d7177c213f 131 DistanceSensors sensors[9];
beacon 4:67d7177c213f 132 AnalogIn* frontS;
beacon 4:67d7177c213f 133 AnalogIn* leftS;
beacon 4:67d7177c213f 134 AnalogIn* rightS;
beacon 4:67d7177c213f 135
beacon 1:388c915756f5 136
beacon 1:388c915756f5 137 void initializeDistanceSensors();
beacon 1:388c915756f5 138 //void init();
beacon 0:d267b248eff4 139
beacon 1:388c915756f5 140 //LEDS related:
beacon 6:ba26dd3251b3 141 DigitalOut* leds;
beacon 0:d267b248eff4 142
beacon 1:388c915756f5 143 //Farbsensors related:
beacon 6:ba26dd3251b3 144 Farbsensor FarbVoltage;
beacon 6:ba26dd3251b3 145
beacon 6:ba26dd3251b3 146 //Arm related:
beacon 6:ba26dd3251b3 147 Arm Arm;
beacon 0:d267b248eff4 148
beacon 10:f76476943a6c 149 //Greifer related:
beacon 10:f76476943a6c 150 Greifer Greifer;
beacon 10:f76476943a6c 151
beacon 0:d267b248eff4 152 private:
beacon 0:d267b248eff4 153
beacon 0:d267b248eff4 154 //Robot related:
beacon 0:d267b248eff4 155 PwmOut* left;
beacon 0:d267b248eff4 156 PwmOut* right;
beacon 10:f76476943a6c 157 DigitalIn* errorMotor;
beacon 0:d267b248eff4 158
beacon 0:d267b248eff4 159 DigitalOut* powerSignal;
beacon 0:d267b248eff4 160 DigitalIn* errorSignal;
beacon 0:d267b248eff4 161 DigitalIn* overtemperatur;
beacon 0:d267b248eff4 162
beacon 10:f76476943a6c 163 Servo* greifer;
beacon 10:f76476943a6c 164 ServoArm* arm;
beacon 0:d267b248eff4 165 };
beacon 0:d267b248eff4 166
beacon 0:d267b248eff4 167 #endif