test program

Dependencies:   LSM9DS1_Library2 MotorV2 SRF05 Tracker2 mbed nRF24L01P

Fork of DUMP_TRUCK_SPR2017 by Terrabots

Committer:
simplyellow
Date:
Tue Feb 28 21:11:48 2017 +0000
Revision:
10:cf77da9be0b8
Parent:
8:9c94865bd087
Child:
12:502cf4fc6d98
updated dump truck class configured to test the dump truck's driving and object sensing capability.

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 10:cf77da9be0b8 17 //#include "Transceiver.h"
simplyellow 10:cf77da9be0b8 18 #include "SRF05.h"
simplyellow 10:cf77da9be0b8 19
simplyellow 10:cf77da9be0b8 20 // ADD SWITCHES & ULTRASONIC SENSOR implementation
Josahty 0:6942f0e2198c 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 10:cf77da9be0b8 37 // motor functions
simplyellow 10:cf77da9be0b8 38 /*
simplyellow 10:cf77da9be0b8 39 * Drive a certain distance at a desired speed.
simplyellow 10:cf77da9be0b8 40 */
simplyellow 10:cf77da9be0b8 41 void driveDistance(float speed, float distance);// frontMotor
simplyellow 10:cf77da9be0b8 42 /*
simplyellow 10:cf77da9be0b8 43 * Drive at a desired speed.
pvela 6:5cc6a9b6f60e 44 */
simplyellow 10:cf77da9be0b8 45 void drive(float speed);
simplyellow 10:cf77da9be0b8 46 /*
simplyellow 10:cf77da9be0b8 47 * Turn the rear wheels a certain angle.
pvela 6:5cc6a9b6f60e 48 */
simplyellow 10:cf77da9be0b8 49 void turn(float angle); // turnMotor
simplyellow 10:cf77da9be0b8 50 /*
simplyellow 10:cf77da9be0b8 51 * Move the dump truck's bed up/down a certain angle.
pvela 6:5cc6a9b6f60e 52 */
simplyellow 10:cf77da9be0b8 53 void moveBed(bool raise, float angle); // bedMotor
simplyellow 10:cf77da9be0b8 54 /*
simplyellow 10:cf77da9be0b8 55 * Stop driving.
simplyellow 10:cf77da9be0b8 56 */
simplyellow 10:cf77da9be0b8 57 void stop(); // all Motors
pvela 6:5cc6a9b6f60e 58
simplyellow 10:cf77da9be0b8 59 // ultrasonic functions
simplyellow 10:cf77da9be0b8 60 /*
simplyellow 10:cf77da9be0b8 61 * Read from the ultrasonic sensor and determine the dump truck's
simplyellow 10:cf77da9be0b8 62 * proximity from objects.
pvela 6:5cc6a9b6f60e 63 */
simplyellow 10:cf77da9be0b8 64 bool detect(); // returns bool for object too close
pvela 6:5cc6a9b6f60e 65
pvela 6:5cc6a9b6f60e 66
Josahty 0:6942f0e2198c 67 protected:
simplyellow 10:cf77da9be0b8 68 Tracker *track;
simplyellow 10:cf77da9be0b8 69 //IMU *bed;
simplyellow 10:cf77da9be0b8 70 Motor *frontMotor;
simplyellow 10:cf77da9be0b8 71 Motor *turnMotor;
simplyellow 10:cf77da9be0b8 72 Motor *bedMotor;
simplyellow 10:cf77da9be0b8 73 //Transceiver *nrf;
simplyellow 10:cf77da9be0b8 74 SRF05 *srf;
simplyellow 10:cf77da9be0b8 75
simplyellow 10:cf77da9be0b8 76 // add direct control for motor, switch, and ultrasonic sensor.
simplyellow 10:cf77da9be0b8 77
Josahty 0:6942f0e2198c 78 int truckNumber;
simplyellow 10:cf77da9be0b8 79
simplyellow 10:cf77da9be0b8 80 // motor variables
simplyellow 10:cf77da9be0b8 81 float speed; // drive
simplyellow 10:cf77da9be0b8 82 float distance; // drive
simplyellow 10:cf77da9be0b8 83 float potAngle; // turn
simplyellow 10:cf77da9be0b8 84 float bedAngle; // bed
simplyellow 10:cf77da9be0b8 85
simplyellow 10:cf77da9be0b8 86 // bed-specific variables
simplyellow 10:cf77da9be0b8 87 bool switchState; // BusIn the two limit switches
simplyellow 10:cf77da9be0b8 88
simplyellow 10:cf77da9be0b8 89 // ultrasonic-specific variables
simplyellow 10:cf77da9be0b8 90 bool tooClose;
simplyellow 10:cf77da9be0b8 91 float proximity;
Josahty 0:6942f0e2198c 92 };
simplyellow 5:dc4cf6cc24b3 93 #endif