Racing Robots Session

Dependencies:   m3pi mbed

Dependents:   RacingRobots

Fork of racing_robots by Nico De Witte

Revision:
2:356bb8d99326
Parent:
0:c0ae66a0ec7a
Child:
4:3743cbfe031b
--- a/robot_logic.h	Mon Feb 23 12:48:22 2015 +0000
+++ b/robot_logic.h	Mon Feb 23 14:37:37 2015 +0000
@@ -4,13 +4,16 @@
 #ifndef H_ROBOT_LOGIC
 #define H_ROBOT_LOGIC
 
-//typedef enum {
-//    LED_1 = 0,
-//    LED_2 = 1,
-//    LED_3 = 2,
-//    LED_4 = 3
-//    //.....
-//} LedIndex;
+typedef enum {
+   LED_1 = 0,
+   LED_2 = 1,
+   LED_3 = 2,
+   LED_4 = 3,
+   LED_5 = 4,
+   LED_6 = 5,
+   LED_7 = 6,
+   LED_8 = 7
+} LedIndex;
 
 typedef enum {
     LED_ON = 0,
@@ -21,37 +24,72 @@
 
 /*
  * Drive the robot forward or backward.
+ * If the robot was turning it will stop turning and drive in a straight line.
  *
- * @speed The speed percentage with which to drive forward or backward [-100, +100].
+ * @speed The speed percentage with which to drive forward or backward.
+ * Can range from -100 (full throttle backward) to +100 (full throttle forward).
  */
 void drive(int speed);
 
-// speed between -100% en +100%
+/*
+ * Turn the robot left or right while driving.
+ *
+ * @turnspeed The percentage with which to turn the robot.
+ * Can range from -100 (full throttle left) to +100 (full throttle right).
+ */
 void turn(int turnspeed);
 
-// Stop the robot
-void stop();
+/*
+ * Stop the robot.
+ */
+void stop(void);
 
-void sensor_calibrate();
+/*
+ * Calibrate the line follow sensors.
+ * Take note that the pololu should be placed over the line
+ * before this function is called and that it will rotate to
+ * both sides.
+ */
+void sensor_calibrate(void);
 
-// Read the value from the line sensor
-int line_sensor();
+/*
+ * Read the value from the line sensor. The returned value indicates the
+ * position of the line. The value ranges from -100 to +100 where -100 is
+ * fully left, +100 is fully right and 0 means the line is detected in the middle.
+ *
+ * @return The position of the line with a range of -100 to +100.
+ */
+int line_sensor(void);
 
-// PID drive control
+/*
+ * Initialize the PID drive control with
+ * the P, I and T factors.
+ *
+ * @p The P factor
+ * @i The I factor
+ * @d The D factor
+ */
 void pid_init(int p, int i, int d);
 
-
-// returns turnspeed
+/*
+ * Determine PID turnspeed with which the pololu should
+ * turn to follow the line at the given position.
+ *
+ * @line_position The position of the line in a range of [-100, +100]
+ *
+ * @returns The turnspeed in a range of [-100, +100]
+ */
 int pid_turn(int line_position);
 
 // Show drive speed and sensor data
-void showStats();
+void show_stats();
 
-// Show text on display
-void display(char* fmt, ...);
+// Show the name of the robot on the display
+void show_name(char * name);
+
 
 // Turn a led on or off
-//void led(LedIndex i, LedState state);
+void led(LedIndex i, LedState state);
 
 // Wait for a number of milliseconds
 void await(int milliseconds);