![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
test program
Dependencies: LSM9DS1_Library2 MotorV2 SRF05 Tracker2 mbed nRF24L01P
Fork of DUMP_TRUCK_SPR2017 by
Diff: DumpTruck.h
- Revision:
- 10:cf77da9be0b8
- Parent:
- 8:9c94865bd087
- Child:
- 12:502cf4fc6d98
--- a/DumpTruck.h Tue Feb 14 14:46:37 2017 -0500 +++ b/DumpTruck.h Tue Feb 28 21:11:48 2017 +0000 @@ -1,110 +1,93 @@ /** * @file DumpTruck.h * -* @brief DumpTruck class implements API for commanding the dump truck and -* for implementing proprioceptive sensing. +* @brief DumpTruck class integrates multiple sensors into one API. * * @author Terrabots Team * */ - #ifndef MBED_DUMP_TRUCK_H #define MBED_DUMP_TRUCK_H - + #include "mbed.h" +#include "Tracker.h" +//#include "IMU.h" +#include "Motor.h" +//#include "Transceiver.h" +#include "SRF05.h" + +// ADD SWITCHES & ULTRASONIC SENSOR implementation /** * @class DumpTruck * -* @brief Interface for controlling a Dump Truck configured "robot." +* @brief Interface for controlling a Dump truck. */ + class DumpTruck { public: - /** - * Constructor for the DumpTruck object. + * Constructor for the Tracker object. * - * @param[in] truckId Not sure. + * @param[in] truckId The dump truck's identifier */ DumpTruck(int truckId); - /** - * Command the dump truck to drive with a desired sped for a specified - * distance. - * - * @param[in] mSpeed The desired motor speed. - * @param[in] dDist The desired driver distance. + // motor functions + /* + * Drive a certain distance at a desired speed. + */ + void driveDistance(float speed, float distance);// frontMotor + /* + * Drive at a desired speed. */ - void drive(); // Drive DC motors with a desired motor speed and distance - - /** - * Command the dump truck to stop. - * + void drive(float speed); + /* + * Turn the rear wheels a certain angle. */ - void stop(); - - /** - * Perform calibration routine. It will ... FILL OUT - * + void turn(float angle); // turnMotor + /* + * Move the dump truck's bed up/down a certain angle. */ - void Calibrate(); + void moveBed(bool raise, float angle); // bedMotor + /* + * Stop driving. + */ + void stop(); // all Motors - /** - * WHAT IS THIS ABOUT? - * - */ - //void RotateTo(); - - /** - * Move the bed to the fully down position. The down switch should - * engage. - * + // ultrasonic functions + /* + * Read from the ultrasonic sensor and determine the dump truck's + * proximity from objects. */ - void BedDown(); - - /** - * Move the bed to the fully up position. The up switch should - * engage. - * - */ - void BedUp(); - - /** - * Raise the bed to the desired angle. Only effective if the bed angle - * estimate has been zeroed out. - * - */ - //void raiseTo(); + bool detect(); // returns bool for object too close - /** - * NOT SURE. HOW DIFFERENT FROM ABOVE? raiseTo should raise to any - * arbitrary angle within limits. - * - */ - //void LowerBed(); - - protected: + Tracker *track; + //IMU *bed; + Motor *frontMotor; + Motor *turnMotor; + Motor *bedMotor; + //Transceiver *nrf; + SRF05 *srf; + + // add direct control for motor, switch, and ultrasonic sensor. + int truckNumber; - float speed; // desired speed to drive the robot, a number between -1 and 1 - float distance; - float getDistance(); // input of desired distance to be traveled - float setTruckSpeed(); // set truck speed - float setTruckDistance(); // set distance to be traveled - //getBedAngle(); //Get data from Bed potentiometer, Hari is looking into the component for this - //getPivotAngle(double PivotAngle); //Get data from potentiometer - //SetPivotSpeed(double PivotSpeed); //Set arbitrary rotation of servo motor - //SetBedSpeed(); //Set arbitrary rotation of DC Motor - //bool GetBedUpperSwitch(); //Checks if bed is all the way up - //bool GetBedLowerSwitch(); //Checks if bed is all the way down - //bool SwitchState; //Switch state variable for Up and down bed functions - //float DesiredPivotAngle; // User Input of desired angle for the bed to be pivoted - //float DesiredBedAngle; //User Input of desired bed angle to be raised. - //float BedSpeed; //User input of desired speed for the dump truck's bed to rotate - //float PivotSpeed; //User input of desired speed for the dump truck to pivot its back at - - //bool isCalibrated;// returns 0 and 1 to check if the robot has been calibrated + + // motor variables + float speed; // drive + float distance; // drive + float potAngle; // turn + float bedAngle; // bed + + // bed-specific variables + bool switchState; // BusIn the two limit switches + + // ultrasonic-specific variables + bool tooClose; + float proximity; }; #endif