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@16:6530f62dd28b, 2017-04-25 (annotated)
- Committer:
- simplyellow
- Date:
- Tue Apr 25 21:00:53 2017 +0000
- Revision:
- 16:6530f62dd28b
- Parent:
- 15:a4bbdde8ed69
cleaned for doxygen
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 "Motor.h" |
simplyellow | 16:6530f62dd28b | 16 | #include "nRF24L01P.h" |
simplyellow | 10:cf77da9be0b8 | 17 | #include "SRF05.h" |
simplyellow | 14:fd6090cddc2e | 18 | #include "commands.h" |
simplyellow | 13:112b6543909a | 19 | |
simplyellow | 12:502cf4fc6d98 | 20 | #define TRANSFER_SIZE 8 |
simplyellow | 12:502cf4fc6d98 | 21 | |
pvela | 7:dd3a7dcc5c84 | 22 | /** |
pvela | 7:dd3a7dcc5c84 | 23 | * @class DumpTruck |
pvela | 7:dd3a7dcc5c84 | 24 | * |
simplyellow | 10:cf77da9be0b8 | 25 | * @brief Interface for controlling a Dump truck. |
pvela | 7:dd3a7dcc5c84 | 26 | */ |
simplyellow | 10:cf77da9be0b8 | 27 | |
Josahty | 0:6942f0e2198c | 28 | class DumpTruck { |
Josahty | 0:6942f0e2198c | 29 | public: |
pvela | 6:5cc6a9b6f60e | 30 | /** |
simplyellow | 10:cf77da9be0b8 | 31 | * Constructor for the Tracker object. |
pvela | 6:5cc6a9b6f60e | 32 | * |
simplyellow | 10:cf77da9be0b8 | 33 | * @param[in] truckId The dump truck's identifier |
pvela | 6:5cc6a9b6f60e | 34 | */ |
Josahty | 0:6942f0e2198c | 35 | DumpTruck(int truckId); |
pvela | 6:5cc6a9b6f60e | 36 | |
simplyellow | 16:6530f62dd28b | 37 | /** |
simplyellow | 15:a4bbdde8ed69 | 38 | * Process command, parsing it and calling the associated function. |
simplyellow | 13:112b6543909a | 39 | */ |
simplyellow | 13:112b6543909a | 40 | void processCommand(); |
simplyellow | 13:112b6543909a | 41 | |
simplyellow | 16:6530f62dd28b | 42 | /** |
simplyellow | 15:a4bbdde8ed69 | 43 | * Send not acknowledge to base station. |
simplyellow | 13:112b6543909a | 44 | */ |
simplyellow | 13:112b6543909a | 45 | |
simplyellow | 13:112b6543909a | 46 | void sendNack(); |
simplyellow | 13:112b6543909a | 47 | |
simplyellow | 16:6530f62dd28b | 48 | /** |
simplyellow | 15:a4bbdde8ed69 | 49 | * Send acknowledge to base station. |
simplyellow | 13:112b6543909a | 50 | */ |
simplyellow | 13:112b6543909a | 51 | |
simplyellow | 13:112b6543909a | 52 | void sendAck(); |
simplyellow | 13:112b6543909a | 53 | |
simplyellow | 16:6530f62dd28b | 54 | /** |
simplyellow | 15:a4bbdde8ed69 | 55 | * Initialize transceiver and other miscellaneous devices. |
simplyellow | 12:502cf4fc6d98 | 56 | */ |
simplyellow | 12:502cf4fc6d98 | 57 | void startComms(); |
simplyellow | 12:502cf4fc6d98 | 58 | |
simplyellow | 16:6530f62dd28b | 59 | /** |
simplyellow | 12:502cf4fc6d98 | 60 | * Receive a command from base station. |
simplyellow | 12:502cf4fc6d98 | 61 | */ |
simplyellow | 12:502cf4fc6d98 | 62 | void getCommand(); |
simplyellow | 12:502cf4fc6d98 | 63 | |
simplyellow | 16:6530f62dd28b | 64 | /** |
simplyellow | 12:502cf4fc6d98 | 65 | * Send important data back to the base station. |
simplyellow | 12:502cf4fc6d98 | 66 | */ |
simplyellow | 12:502cf4fc6d98 | 67 | void reportData(); |
simplyellow | 12:502cf4fc6d98 | 68 | |
simplyellow | 16:6530f62dd28b | 69 | /** |
simplyellow | 10:cf77da9be0b8 | 70 | * Drive a certain distance at a desired speed. |
simplyellow | 10:cf77da9be0b8 | 71 | */ |
simplyellow | 14:fd6090cddc2e | 72 | void driveDistance();// frontMotor |
simplyellow | 16:6530f62dd28b | 73 | |
simplyellow | 16:6530f62dd28b | 74 | /** |
simplyellow | 10:cf77da9be0b8 | 75 | * Drive at a desired speed. |
pvela | 6:5cc6a9b6f60e | 76 | */ |
simplyellow | 14:fd6090cddc2e | 77 | void drive(); |
simplyellow | 16:6530f62dd28b | 78 | |
simplyellow | 16:6530f62dd28b | 79 | /** |
simplyellow | 10:cf77da9be0b8 | 80 | * Turn the rear wheels a certain angle. |
pvela | 6:5cc6a9b6f60e | 81 | */ |
simplyellow | 14:fd6090cddc2e | 82 | void turn(); // turnMotor |
simplyellow | 16:6530f62dd28b | 83 | |
simplyellow | 16:6530f62dd28b | 84 | /** |
simplyellow | 10:cf77da9be0b8 | 85 | * Move the dump truck's bed up/down a certain angle. |
pvela | 6:5cc6a9b6f60e | 86 | */ |
simplyellow | 14:fd6090cddc2e | 87 | void moveBed(); // bedMotor |
simplyellow | 16:6530f62dd28b | 88 | |
simplyellow | 16:6530f62dd28b | 89 | /** |
simplyellow | 10:cf77da9be0b8 | 90 | * Stop driving. |
simplyellow | 10:cf77da9be0b8 | 91 | */ |
simplyellow | 14:fd6090cddc2e | 92 | void stopDrive(); // all Motors |
simplyellow | 13:112b6543909a | 93 | |
simplyellow | 16:6530f62dd28b | 94 | /** |
simplyellow | 13:112b6543909a | 95 | * Stop turning. |
simplyellow | 13:112b6543909a | 96 | */ |
simplyellow | 14:fd6090cddc2e | 97 | void stopTurn(); // all Motors |
simplyellow | 15:a4bbdde8ed69 | 98 | |
simplyellow | 16:6530f62dd28b | 99 | /** |
simplyellow | 15:a4bbdde8ed69 | 100 | * Stop all motors if an object comes within range of the |
simplyellow | 15:a4bbdde8ed69 | 101 | * ultrasonic sensor |
simplyellow | 15:a4bbdde8ed69 | 102 | */ |
simplyellow | 15:a4bbdde8ed69 | 103 | void detectStop(); |
simplyellow | 13:112b6543909a | 104 | |
simplyellow | 16:6530f62dd28b | 105 | /** |
simplyellow | 13:112b6543909a | 106 | * Stop bed. |
simplyellow | 13:112b6543909a | 107 | */ |
simplyellow | 14:fd6090cddc2e | 108 | void stopBed(); // all Motors |
pvela | 6:5cc6a9b6f60e | 109 | |
simplyellow | 16:6530f62dd28b | 110 | /** |
simplyellow | 10:cf77da9be0b8 | 111 | * Read from the ultrasonic sensor and determine the dump truck's |
simplyellow | 10:cf77da9be0b8 | 112 | * proximity from objects. |
pvela | 6:5cc6a9b6f60e | 113 | */ |
simplyellow | 10:cf77da9be0b8 | 114 | bool detect(); // returns bool for object too close |
simplyellow | 13:112b6543909a | 115 | |
simplyellow | 13:112b6543909a | 116 | int txDataCnt; |
simplyellow | 13:112b6543909a | 117 | int rxDataCnt; |
simplyellow | 13:112b6543909a | 118 | char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE]; |
simplyellow | 13:112b6543909a | 119 | char acked[TRANSFER_SIZE]; |
simplyellow | 13:112b6543909a | 120 | char nacked[TRANSFER_SIZE]; |
simplyellow | 13:112b6543909a | 121 | bool received; |
simplyellow | 14:fd6090cddc2e | 122 | int numCommands; |
simplyellow | 14:fd6090cddc2e | 123 | int commandValue; |
simplyellow | 14:fd6090cddc2e | 124 | typedef void (DumpTruck::*funcArray)(void); |
simplyellow | 14:fd6090cddc2e | 125 | funcArray commArr[sizeof(commands)/sizeof(*commands)]; |
simplyellow | 15:a4bbdde8ed69 | 126 | float zeroAngle; |
simplyellow | 15:a4bbdde8ed69 | 127 | bool interrupted; |
simplyellow | 14:fd6090cddc2e | 128 | |
simplyellow | 14:fd6090cddc2e | 129 | protected: |
simplyellow | 10:cf77da9be0b8 | 130 | Tracker *track; |
simplyellow | 10:cf77da9be0b8 | 131 | //IMU *bed; |
simplyellow | 10:cf77da9be0b8 | 132 | Motor *frontMotor; |
simplyellow | 10:cf77da9be0b8 | 133 | Motor *turnMotor; |
simplyellow | 10:cf77da9be0b8 | 134 | Motor *bedMotor; |
simplyellow | 12:502cf4fc6d98 | 135 | nRF24L01P *nrf; //Transceiver *nrf; |
simplyellow | 10:cf77da9be0b8 | 136 | SRF05 *srf; |
simplyellow | 15:a4bbdde8ed69 | 137 | AnalogIn *pot; |
simplyellow | 10:cf77da9be0b8 | 138 | |
simplyellow | 10:cf77da9be0b8 | 139 | // add direct control for motor, switch, and ultrasonic sensor. |
simplyellow | 10:cf77da9be0b8 | 140 | |
Josahty | 0:6942f0e2198c | 141 | int truckNumber; |
simplyellow | 10:cf77da9be0b8 | 142 | |
simplyellow | 10:cf77da9be0b8 | 143 | // motor variables |
simplyellow | 10:cf77da9be0b8 | 144 | float speed; // drive |
simplyellow | 10:cf77da9be0b8 | 145 | float distance; // drive |
simplyellow | 10:cf77da9be0b8 | 146 | float potAngle; // turn |
simplyellow | 10:cf77da9be0b8 | 147 | float bedAngle; // bed |
simplyellow | 10:cf77da9be0b8 | 148 | |
simplyellow | 10:cf77da9be0b8 | 149 | // bed-specific variables |
simplyellow | 10:cf77da9be0b8 | 150 | bool switchState; // BusIn the two limit switches |
simplyellow | 10:cf77da9be0b8 | 151 | |
simplyellow | 10:cf77da9be0b8 | 152 | // ultrasonic-specific variables |
simplyellow | 10:cf77da9be0b8 | 153 | bool tooClose; |
simplyellow | 10:cf77da9be0b8 | 154 | float proximity; |
Josahty | 0:6942f0e2198c | 155 | }; |
simplyellow | 5:dc4cf6cc24b3 | 156 | #endif |