Wyatt  1.0.1
Robot.h
1 //
2 // Created by Tucker Haydon on 4/25/17.
3 //
4 
5 #pragma once
6 
7 #include "Communicator.h"
8 #include "sensors/SensorManager.h"
9 #include "sensors/ISensorManager.h"
10 #include "hardwareinterface/MotorAdapter.h"
11 #include "hardwareinterface/EncoderAdapter.h"
12 #include "hardwareinterface/AdafruitPWMServoHat.h"
13 #include "wiringPiInclude.h"
14 #include "sensors/EncoderSensor.h"
15 #include "sensors/ISensor.h"
16 #include "CommandManager.h"
17 #include "commands/DriveMotorRPM.h"
18 #include "commands/DriveRobotCommand.h"
19 #include <unistd.h>
20 
21 #define RIGHT_MOTOR_FORWARD_PIN 0
22 #define RIGHT_MOTOR_BACKWARD_PIN 1
23 #define LEFT_MOTOR_FORWARD_PIN 3
24 #define LEFT_MOTOR_BACKWARD_PIN 2
25 
26 #define ENCODER_TICKS_PER_REVOLUTION 64
27 #define LEFT_ENCODER_PIN_A 1
28 #define LEFT_ENCODER_PIN_B 2
29 #define RIGHT_ENCODER_PIN_A 3
30 #define RIGHT_ENCODER_PIN_B 4
31 
32 
33 // Wheel diameter in cm
34 #define WHEEL_DIAMETER (double) 10.16
35 
36 // Drivetrain diameter in cm
37 #define DRIVETRAIN_DIAMETER (double) 20.32
38 
42 class Robot {
43 
44 public:
49  static Robot* instance() {
50  static Robot* instance = new Robot();
51  return instance;
52  }
53 
57  ~Robot();
58 
62  void run();
63 
64  /* Redefine these methods to prevent copies */
65  Robot(Robot const&) = delete;
66  void operator=(Robot const&) = delete;
67 
68 private:
69  Robot();
70 
71  /* Hardware Adapters */
72  MotorAdapter* leftMotorAdapter;
73  MotorAdapter* rightMotorAdapter;
74  EncoderAdapter* leftEncoderAdapter;
75  EncoderAdapter* rightEncoderAdapter;
76 
77  /* Sensors */
78  EncoderSensor* leftEncoderSensor;
79  EncoderSensor* rightEncoderSensor;
80 
81  /* Adafruit PWM driver */
82  AdafruitPWMServoHat* pwmServoHat;
83 
84  /* Sensor manager */
85  ISensorManager* sensorManager;
86 
87  /* Communicator */
88  Communicator* communicator;
89 
90  /* Command Manager */
91  CommandManager* commander;
92 
93 };
Definition: Robot.h:42
~Robot()
Definition: Robot.cpp:79
static Robot * instance()
Definition: Robot.h:49
void run()
Definition: Robot.cpp:52