test program

Dependencies:   LSM9DS1_Library2 MotorV2 SRF05 Tracker2 mbed nRF24L01P

Fork of DUMP_TRUCK_SPR2017 by Terrabots

Committer:
simplyellow
Date:
Thu Apr 13 17:32:44 2017 +0000
Revision:
13:112b6543909a
Parent:
12:502cf4fc6d98
Child:
14:192e103d5246
.

Who changed what in which revision?

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