Main repository for dump truck API development in Spring 2017
Dependencies: Tracker mbed MotorV2 SRF05 nRF24L01P
Fork of DUMP_TRUCK_TEST_V1 by
Activities
This Week
If needed, please contact Milo Pan at mpan9@gatech.edu for rights and access to this repository.
DumpTruck.h@12:502cf4fc6d98, 2017-03-30 (annotated)
- Committer:
- simplyellow
- Date:
- Thu Mar 30 17:27:21 2017 +0000
- Revision:
- 12:502cf4fc6d98
- Parent:
- 10:cf77da9be0b8
- Child:
- 13:112b6543909a
began work on transceiver
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pvela | 6:5cc6a9b6f60e | 1 | /** |
pvela | 6:5cc6a9b6f60e | 2 | * @file DumpTruck.h |
pvela | 6:5cc6a9b6f60e | 3 | * |
simplyellow | 10:cf77da9be0b8 | 4 | * @brief DumpTruck class integrates multiple sensors into one API. |
pvela | 6:5cc6a9b6f60e | 5 | * |
pvela | 6:5cc6a9b6f60e | 6 | * @author Terrabots Team |
pvela | 6:5cc6a9b6f60e | 7 | * |
pvela | 6:5cc6a9b6f60e | 8 | */ |
pvela | 6:5cc6a9b6f60e | 9 | |
Josahty | 0:6942f0e2198c | 10 | #ifndef MBED_DUMP_TRUCK_H |
Josahty | 0:6942f0e2198c | 11 | #define MBED_DUMP_TRUCK_H |
simplyellow | 10:cf77da9be0b8 | 12 | |
Josahty | 0:6942f0e2198c | 13 | #include "mbed.h" |
simplyellow | 10:cf77da9be0b8 | 14 | #include "Tracker.h" |
simplyellow | 10:cf77da9be0b8 | 15 | //#include "IMU.h" |
simplyellow | 10:cf77da9be0b8 | 16 | #include "Motor.h" |
simplyellow | 12:502cf4fc6d98 | 17 | #include "nRF24L01P.h" //Transceiver library |
simplyellow | 10:cf77da9be0b8 | 18 | #include "SRF05.h" |
simplyellow | 10:cf77da9be0b8 | 19 | |
simplyellow | 12:502cf4fc6d98 | 20 | #define TRANSFER_SIZE 8 |
simplyellow | 12:502cf4fc6d98 | 21 | |
simplyellow | 10:cf77da9be0b8 | 22 | // ADD SWITCHES & ULTRASONIC SENSOR implementation |
Josahty | 0:6942f0e2198c | 23 | |
pvela | 7:dd3a7dcc5c84 | 24 | /** |
pvela | 7:dd3a7dcc5c84 | 25 | * @class DumpTruck |
pvela | 7:dd3a7dcc5c84 | 26 | * |
simplyellow | 10:cf77da9be0b8 | 27 | * @brief Interface for controlling a Dump truck. |
pvela | 7:dd3a7dcc5c84 | 28 | */ |
simplyellow | 10:cf77da9be0b8 | 29 | |
Josahty | 0:6942f0e2198c | 30 | class DumpTruck { |
Josahty | 0:6942f0e2198c | 31 | public: |
pvela | 6:5cc6a9b6f60e | 32 | /** |
simplyellow | 10:cf77da9be0b8 | 33 | * Constructor for the Tracker object. |
pvela | 6:5cc6a9b6f60e | 34 | * |
simplyellow | 10:cf77da9be0b8 | 35 | * @param[in] truckId The dump truck's identifier |
pvela | 6:5cc6a9b6f60e | 36 | */ |
Josahty | 0:6942f0e2198c | 37 | DumpTruck(int truckId); |
pvela | 6:5cc6a9b6f60e | 38 | |
simplyellow | 12:502cf4fc6d98 | 39 | /* |
simplyellow | 12:502cf4fc6d98 | 40 | * Initialize transceiver. |
simplyellow | 12:502cf4fc6d98 | 41 | */ |
simplyellow | 12:502cf4fc6d98 | 42 | void startComms(); |
simplyellow | 12:502cf4fc6d98 | 43 | |
simplyellow | 12:502cf4fc6d98 | 44 | /* |
simplyellow | 12:502cf4fc6d98 | 45 | * Receive a command from base station. |
simplyellow | 12:502cf4fc6d98 | 46 | */ |
simplyellow | 12:502cf4fc6d98 | 47 | void getCommand(); |
simplyellow | 12:502cf4fc6d98 | 48 | |
simplyellow | 12:502cf4fc6d98 | 49 | /* |
simplyellow | 12:502cf4fc6d98 | 50 | * Send important data back to the base station. |
simplyellow | 12:502cf4fc6d98 | 51 | */ |
simplyellow | 12:502cf4fc6d98 | 52 | void reportData(); |
simplyellow | 12:502cf4fc6d98 | 53 | |
simplyellow | 10:cf77da9be0b8 | 54 | // motor functions |
simplyellow | 10:cf77da9be0b8 | 55 | /* |
simplyellow | 10:cf77da9be0b8 | 56 | * Drive a certain distance at a desired speed. |
simplyellow | 10:cf77da9be0b8 | 57 | */ |
simplyellow | 10:cf77da9be0b8 | 58 | void driveDistance(float speed, float distance);// frontMotor |
simplyellow | 10:cf77da9be0b8 | 59 | /* |
simplyellow | 10:cf77da9be0b8 | 60 | * Drive at a desired speed. |
pvela | 6:5cc6a9b6f60e | 61 | */ |
simplyellow | 10:cf77da9be0b8 | 62 | void drive(float speed); |
simplyellow | 10:cf77da9be0b8 | 63 | /* |
simplyellow | 10:cf77da9be0b8 | 64 | * Turn the rear wheels a certain angle. |
pvela | 6:5cc6a9b6f60e | 65 | */ |
simplyellow | 10:cf77da9be0b8 | 66 | void turn(float angle); // turnMotor |
simplyellow | 10:cf77da9be0b8 | 67 | /* |
simplyellow | 10:cf77da9be0b8 | 68 | * Move the dump truck's bed up/down a certain angle. |
pvela | 6:5cc6a9b6f60e | 69 | */ |
simplyellow | 10:cf77da9be0b8 | 70 | void moveBed(bool raise, float angle); // bedMotor |
simplyellow | 10:cf77da9be0b8 | 71 | /* |
simplyellow | 10:cf77da9be0b8 | 72 | * Stop driving. |
simplyellow | 10:cf77da9be0b8 | 73 | */ |
simplyellow | 10:cf77da9be0b8 | 74 | void stop(); // all Motors |
pvela | 6:5cc6a9b6f60e | 75 | |
simplyellow | 10:cf77da9be0b8 | 76 | // ultrasonic functions |
simplyellow | 10:cf77da9be0b8 | 77 | /* |
simplyellow | 10:cf77da9be0b8 | 78 | * Read from the ultrasonic sensor and determine the dump truck's |
simplyellow | 10:cf77da9be0b8 | 79 | * proximity from objects. |
pvela | 6:5cc6a9b6f60e | 80 | */ |
simplyellow | 10:cf77da9be0b8 | 81 | bool detect(); // returns bool for object too close |
pvela | 6:5cc6a9b6f60e | 82 | |
pvela | 6:5cc6a9b6f60e | 83 | |
Josahty | 0:6942f0e2198c | 84 | protected: |
simplyellow | 10:cf77da9be0b8 | 85 | Tracker *track; |
simplyellow | 10:cf77da9be0b8 | 86 | //IMU *bed; |
simplyellow | 10:cf77da9be0b8 | 87 | Motor *frontMotor; |
simplyellow | 10:cf77da9be0b8 | 88 | Motor *turnMotor; |
simplyellow | 10:cf77da9be0b8 | 89 | Motor *bedMotor; |
simplyellow | 12:502cf4fc6d98 | 90 | nRF24L01P *nrf; //Transceiver *nrf; |
simplyellow | 10:cf77da9be0b8 | 91 | SRF05 *srf; |
simplyellow | 10:cf77da9be0b8 | 92 | |
simplyellow | 10:cf77da9be0b8 | 93 | // add direct control for motor, switch, and ultrasonic sensor. |
simplyellow | 10:cf77da9be0b8 | 94 | |
Josahty | 0:6942f0e2198c | 95 | int truckNumber; |
simplyellow | 10:cf77da9be0b8 | 96 | |
simplyellow | 10:cf77da9be0b8 | 97 | // motor variables |
simplyellow | 10:cf77da9be0b8 | 98 | float speed; // drive |
simplyellow | 10:cf77da9be0b8 | 99 | float distance; // drive |
simplyellow | 10:cf77da9be0b8 | 100 | float potAngle; // turn |
simplyellow | 10:cf77da9be0b8 | 101 | float bedAngle; // bed |
simplyellow | 10:cf77da9be0b8 | 102 | |
simplyellow | 10:cf77da9be0b8 | 103 | // bed-specific variables |
simplyellow | 10:cf77da9be0b8 | 104 | bool switchState; // BusIn the two limit switches |
simplyellow | 10:cf77da9be0b8 | 105 | |
simplyellow | 10:cf77da9be0b8 | 106 | // ultrasonic-specific variables |
simplyellow | 10:cf77da9be0b8 | 107 | bool tooClose; |
simplyellow | 10:cf77da9be0b8 | 108 | float proximity; |
simplyellow | 12:502cf4fc6d98 | 109 | |
simplyellow | 12:502cf4fc6d98 | 110 | int txDataCnt; |
simplyellow | 12:502cf4fc6d98 | 111 | int rxDataCnt; |
simplyellow | 12:502cf4fc6d98 | 112 | char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE]; |
simplyellow | 12:502cf4fc6d98 | 113 | bool received; |
Josahty | 0:6942f0e2198c | 114 | }; |
simplyellow | 5:dc4cf6cc24b3 | 115 | #endif |