-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOBR_Robot.h
83 lines (55 loc) · 1.61 KB
/
OBR_Robot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
OBR_Robot.h - Logic control class header.
Created by Rafael Piacsek, May 24, 2017.
Private code, for OBR use only.
*/
#ifndef OBR_Robot_h
#define OBR_Robot_h
#include "Arduino.h"
#include "OBR_Motor.h"
#include "OBR_QA.h"
#include "OBR_PID.h"
#include "OBR_Gyro.h"
#include <NewPing.h>
/* Classes parameters:
// OBR_Motor.h
(byte left_1, byte left_2, byte leftPwm, byte right_1, byte right_2, byte rightPwm)
// OBR_QA.h
(byte QAPin_0, byte QAPin_1, byte QAPin_2, byte QAPin_3)
// OBR_Ultrasound.h
(byte trigPin, byte echoPin)
// OBR_PID.h
(float kP, float kI, float kD)
*/
class OBR_Robot {
private:
// Instantiate all necessary objects.
OBR_Motor _Motor = OBR_Motor(17, 16, 2, 15, 14, 3);
OBR_QA _QA = OBR_QA(A10, A11, A12, A13, A14, A15);
NewPing _UltrasoundFront = NewPing(53, 52, 15); // (trigPin, echoPin, maxDist)
NewPing _UltrasoundBack = NewPing(49, 48, 15);
NewPing _UltrasoundLeft = NewPing(47, 46, 15);
NewPing _UltrasoundRight = NewPing(51, 50, 15);
// PID-related variables and objects.
OBR_PID _PID = OBR_PID(.1, .001, 0.01);
// Gyro-related object.
OBR_Gyro _Gyro = OBR_Gyro();
// Target speed.
const int _targetSpeed = 200; // DEFAULT IS 200!
public:
// Define Contructor method.
OBR_Robot();
// Define some values.
byte LEFT = -90;
byte RIGHT = 90;
byte AROUND = 180;
// Methods.
void debug(int delayTime=500);
void calibrate();
void run();
void firstStage();
void secondStage();
void avoidObstacle(byte direction);
void turn(byte direction);
};
#endif