zhaw_st16b_pes2_10 / Mbed 2 deprecated progr_Pes2_st16b_10_Giona-Arm

Dependencies:   Servo mbed

Fork of progr_Pes2_st16b_10_Giona by zhaw_st16b_pes2_10

Committer:
beacon
Date:
Wed Apr 12 12:45:21 2017 +0000
Revision:
12:68eb5e319c39
Parent:
10:4e14a2de6011
Child:
13:f3fea9f5c990
l

Who changed what in which revision?

UserRevisionLine numberNew contents of line
beacon 7:29b49f65700a 1 #ifndef ROBOT_H
beacon 7:29b49f65700a 2 #define ROBOT_H
beacon 7:29b49f65700a 3
beacon 7:29b49f65700a 4 #include <cstdlib>
beacon 7:29b49f65700a 5 #include <mbed.h>
beacon 10:4e14a2de6011 6 #include "Servo.h"
beacon 7:29b49f65700a 7
beacon 7:29b49f65700a 8 #include "mbed.h"
beacon 7:29b49f65700a 9
beacon 7:29b49f65700a 10
beacon 7:29b49f65700a 11 /* Declarations for the Motors in the Robot in order to drive -------- */
beacon 7:29b49f65700a 12
beacon 7:29b49f65700a 13 class DistanceSensors
beacon 7:29b49f65700a 14 {
beacon 7:29b49f65700a 15 public:
beacon 7:29b49f65700a 16
beacon 7:29b49f65700a 17 DistanceSensors(AnalogIn* sensorVoltage, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number);
beacon 7:29b49f65700a 18 DistanceSensors();
beacon 7:29b49f65700a 19
beacon 7:29b49f65700a 20 void init(AnalogIn* sensorVoltage, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number);
beacon 7:29b49f65700a 21 virtual ~DistanceSensors();
beacon 7:29b49f65700a 22 float read();
beacon 7:29b49f65700a 23
beacon 7:29b49f65700a 24 operator float(); //Is here to constantly return the value of read.
beacon 7:29b49f65700a 25
beacon 7:29b49f65700a 26 private:
beacon 7:29b49f65700a 27
beacon 7:29b49f65700a 28 AnalogIn* sensorVoltage;
beacon 7:29b49f65700a 29 DigitalOut* bit0;
beacon 7:29b49f65700a 30 DigitalOut* bit1;
beacon 7:29b49f65700a 31 DigitalOut* bit2;
beacon 7:29b49f65700a 32
beacon 7:29b49f65700a 33 int number;
beacon 7:29b49f65700a 34
beacon 7:29b49f65700a 35 };
beacon 7:29b49f65700a 36
beacon 10:4e14a2de6011 37 class Farbsensor
beacon 10:4e14a2de6011 38 {
beacon 10:4e14a2de6011 39 public:
beacon 10:4e14a2de6011 40
beacon 10:4e14a2de6011 41 Farbsensor();
beacon 10:4e14a2de6011 42 Farbsensor(AnalogIn* FarbVoltage);
beacon 10:4e14a2de6011 43
beacon 10:4e14a2de6011 44 void init(AnalogIn* FarbVoltage);
beacon 10:4e14a2de6011 45 int read();
beacon 10:4e14a2de6011 46 operator int();
beacon 10:4e14a2de6011 47
beacon 10:4e14a2de6011 48 private:
beacon 10:4e14a2de6011 49
beacon 10:4e14a2de6011 50 AnalogIn* FarbVoltage;
beacon 10:4e14a2de6011 51 };
beacon 10:4e14a2de6011 52 /*
beacon 10:4e14a2de6011 53 class Arm{
beacon 10:4e14a2de6011 54
beacon 10:4e14a2de6011 55 public:
beacon 10:4e14a2de6011 56 Arm(Servo joint);
beacon 10:4e14a2de6011 57 Arm();
beacon 10:4e14a2de6011 58 void init(Servo joint);
beacon 10:4e14a2de6011 59
beacon 10:4e14a2de6011 60 void down();
beacon 10:4e14a2de6011 61 void neutral();
beacon 10:4e14a2de6011 62 void back();
beacon 10:4e14a2de6011 63 void setAngle(float angle);
beacon 10:4e14a2de6011 64
beacon 10:4e14a2de6011 65 private:
beacon 10:4e14a2de6011 66 Servo joint;
beacon 10:4e14a2de6011 67
beacon 10:4e14a2de6011 68 };
beacon 10:4e14a2de6011 69 */
beacon 10:4e14a2de6011 70
beacon 7:29b49f65700a 71 class Robot
beacon 7:29b49f65700a 72 {
beacon 7:29b49f65700a 73
beacon 7:29b49f65700a 74 public:
beacon 7:29b49f65700a 75
beacon 7:29b49f65700a 76 //Robot related:
beacon 10:4e14a2de6011 77 Robot(PwmOut* left, PwmOut* right, DigitalOut* enableSignal, DigitalOut* leds, AnalogIn* FarbVoltage );
beacon 12:68eb5e319c39 78
beacon 12:68eb5e319c39 79 //Drive Functions
beacon 7:29b49f65700a 80 void drive();
beacon 12:68eb5e319c39 81 void driveB();
beacon 12:68eb5e319c39 82
beacon 7:29b49f65700a 83 void turnLeft();
beacon 12:68eb5e319c39 84 void turnLeftS();
beacon 7:29b49f65700a 85 void turnRight();
beacon 12:68eb5e319c39 86 void turnRightS();
beacon 7:29b49f65700a 87 void turnAround(int left);
beacon 7:29b49f65700a 88 void stop();
beacon 7:29b49f65700a 89
beacon 12:68eb5e319c39 90 //Functions that use the drive functions
beacon 12:68eb5e319c39 91 void wallRight(int* counter, int* timer, int* lastAct);
beacon 12:68eb5e319c39 92 void wallLeft(int* counter, int* timer, int* lastAct);
beacon 12:68eb5e319c39 93 void wallFront(int* counter, int* timer, int* lastAct);
beacon 12:68eb5e319c39 94 void counterMax(int* counter, int* timer, int* lastAct, int* rando);
beacon 12:68eb5e319c39 95
beacon 12:68eb5e319c39 96 void legoFront(int* counter, int* timer, int* lastAct, int* legoFound);
beacon 12:68eb5e319c39 97 void legoRight(int* counter, int* timer, int* lastAct, int* legoFound);
beacon 12:68eb5e319c39 98 void legoLeft(int* counter, int* timer, int* lastAct, int* legoFound);
beacon 12:68eb5e319c39 99
beacon 12:68eb5e319c39 100 void nothingFound(int* counter, int* timer, int* lastAct);
beacon 12:68eb5e319c39 101
beacon 12:68eb5e319c39 102 void search(int* counter, int* timer);
beacon 10:4e14a2de6011 103 void lego(int* counter, Timer* t);
beacon 9:89aa06bcfaa3 104
beacon 7:29b49f65700a 105 //DistanceSensors related:
beacon 7:29b49f65700a 106 DistanceSensors sensors[6];
beacon 7:29b49f65700a 107
beacon 9:89aa06bcfaa3 108 void initializeDistanceSensors();
beacon 7:29b49f65700a 109 //void init();
beacon 7:29b49f65700a 110
beacon 7:29b49f65700a 111 //LEDS related:
beacon 7:29b49f65700a 112 DigitalOut* leds;
beacon 7:29b49f65700a 113
beacon 10:4e14a2de6011 114 //Farbsensors related:
beacon 10:4e14a2de6011 115 Farbsensor FarbVoltage;
beacon 10:4e14a2de6011 116
beacon 7:29b49f65700a 117 private:
beacon 7:29b49f65700a 118
beacon 7:29b49f65700a 119 //Robot related:
beacon 7:29b49f65700a 120 PwmOut* left;
beacon 7:29b49f65700a 121 PwmOut* right;
beacon 7:29b49f65700a 122
beacon 7:29b49f65700a 123 DigitalOut* powerSignal;
beacon 7:29b49f65700a 124 DigitalIn* errorSignal;
beacon 7:29b49f65700a 125 DigitalIn* overtemperatur;
beacon 7:29b49f65700a 126
beacon 7:29b49f65700a 127
beacon 7:29b49f65700a 128 };
beacon 7:29b49f65700a 129
beacon 7:29b49f65700a 130 #endif