Final Project files for mBed development.

Dependencies:   m3pi mbed

Committer:
lsaristo
Date:
Wed Dec 10 18:49:45 2014 +0000
Revision:
34:3066686d5152
Parent:
32:8b589710632b
Child:
35:a1c14c6d9282
Everything done on Tuesday night. This code actually produces a closed box of side length 500!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lsaristo 8:12d780f7443e 1 /**
lsaristo 10:94b068b2ce1d 2 * @file main.h
lsaristo 8:12d780f7443e 3 * @brief Main header file for includes and whatnot
lsaristo 8:12d780f7443e 4 * for the other project files.
lsaristo 8:12d780f7443e 5 * @author John Wilkey
lsaristo 29:459ff10d2a07 6 * @author Alec Guertin
lsaristo 29:459ff10d2a07 7 * @author Chester Chu
lsaristo 8:12d780f7443e 8 */
lsaristo 8:12d780f7443e 9
lsaristo 10:94b068b2ce1d 10 #ifndef _MAIN_H
lsaristo 10:94b068b2ce1d 11 #define _MAIN_H
lsaristo 8:12d780f7443e 12
lsaristo 8:12d780f7443e 13 #include "mbed.h"
lsaristo 8:12d780f7443e 14 #include "m3pi.h"
lsaristo 9:3a0433c391cb 15 #include <string.h>
lsaristo 9:3a0433c391cb 16 #include <stdarg.h>
lsaristo 9:3a0433c391cb 17 #include <stdio.h>
lsaristo 21:0c80a5d89ea3 18 #include <math.h>
lsaristo 21:0c80a5d89ea3 19 #define TURN_SPEED 0.15
lsaristo 34:3066686d5152 20 #define DRIVE_SPEED 0.25
lsaristo 8:12d780f7443e 21 #define ERR_SUCCESS 0
lsaristo 8:12d780f7443e 22 #define ERR_FAILURE 1
lsaristo 9:3a0433c391cb 23 #define DRIVE_RATE 1/50
chstrchu 31:1e950ee04481 24 #define TIME_FACT 1780
lsaristo 34:3066686d5152 25 #define CAL_SPEED .25
alecguertin 22:46b9d9b2e35c 26 #define CLOSE_ENOUGH .0008
lsaristo 8:12d780f7443e 27
lsaristo 29:459ff10d2a07 28 /** @brief Move the robot from its current position to (x,y) */
alecguertin 18:eab7b0e89398 29 void move(int x, int y, int draw);
alecguertin 18:eab7b0e89398 30
lsaristo 8:12d780f7443e 31 /**
alecguertin 17:c72c092fcdf7 32 * @brief get values of next PostScript instruction.
alecguertin 17:c72c092fcdf7 33 *
alecguertin 17:c72c092fcdf7 34 * @param buf Buffer with PS instructions.
alecguertin 17:c72c092fcdf7 35 * @param x Pointer to storage for x coordinate.
alecguertin 17:c72c092fcdf7 36 * @param y Pointer to storage for y coordinate.
alecguertin 17:c72c092fcdf7 37 * @param draw Pointer to storage for draw/move boolean.
alecguertin 17:c72c092fcdf7 38 *
alecguertin 17:c72c092fcdf7 39 * @return Success or failure code.
alecguertin 17:c72c092fcdf7 40 */
alecguertin 17:c72c092fcdf7 41 int retrieve_inst(char *buf, int *x, int *y, int *draw);
alecguertin 17:c72c092fcdf7 42
alecguertin 17:c72c092fcdf7 43 /**
lsaristo 29:459ff10d2a07 44 * @brief Driver forward for a time.
lsaristo 8:12d780f7443e 45 *
lsaristo 29:459ff10d2a07 46 * @param[in] amt Amount to drive forward. In milliseconds.
lsaristo 8:12d780f7443e 47 */
lsaristo 29:459ff10d2a07 48 void forward(int amt);
lsaristo 8:12d780f7443e 49
lsaristo 8:12d780f7443e 50 /**
lsaristo 29:459ff10d2a07 51 * @brief Drive backward for a time.
lsaristo 8:12d780f7443e 52 *
lsaristo 29:459ff10d2a07 53 * @param[in] amt Amount to drive backward. In milliseconds.
lsaristo 8:12d780f7443e 54 */
lsaristo 29:459ff10d2a07 55 void backward(int amt);
lsaristo 8:12d780f7443e 56
lsaristo 8:12d780f7443e 57 /**
lsaristo 29:459ff10d2a07 58 * @brief Turn right by some angle.
lsaristo 8:12d780f7443e 59 *
lsaristo 29:459ff10d2a07 60 * @param[in] deg Desired final turn angle in degrees from start.
lsaristo 29:459ff10d2a07 61 * Note that a negative angle will turn in the opposite
lsaristo 29:459ff10d2a07 62 * direction.
lsaristo 8:12d780f7443e 63 */
lsaristo 29:459ff10d2a07 64 void right(float deg);
lsaristo 8:12d780f7443e 65
lsaristo 8:12d780f7443e 66 /**
lsaristo 29:459ff10d2a07 67 * @brief Turn left by some angle.
lsaristo 8:12d780f7443e 68 *
lsaristo 29:459ff10d2a07 69 * @param[in] deg Desired final turn angle in degrees from start.
lsaristo 29:459ff10d2a07 70 * Note that a negative angle will turn in the opposite
lsaristo 29:459ff10d2a07 71 * direction.
lsaristo 8:12d780f7443e 72 */
lsaristo 29:459ff10d2a07 73 void left (float deg);
lsaristo 8:12d780f7443e 74
lsaristo 21:0c80a5d89ea3 75 /**
lsaristo 29:459ff10d2a07 76 * @brief Wait for a number of seconds, possibly fractional.
lsaristo 29:459ff10d2a07 77 *
lsaristo 29:459ff10d2a07 78 * Timer resolution is on the order of microseconds. A negative wait
lsaristo 29:459ff10d2a07 79 * time does nothing.
lsaristo 21:0c80a5d89ea3 80 *
lsaristo 29:459ff10d2a07 81 * @param[in] amt Time to wait, in seconds.
lsaristo 21:0c80a5d89ea3 82 */
lsaristo 29:459ff10d2a07 83 void timerWait(float amt);
lsaristo 29:459ff10d2a07 84 #endif