Racing Robots Session

Dependencies:   MbedJSONValue m3pi

This is the library for the Racing Robots session. It supports the M3PI robot of Polulu.

It is based on the "Arduino" principle of the init and loop function.

Just add a main.cpp file which contains:

Racing Robots main file

#include "robot_logic.h"

void init()
{
   //put your initialization logic here
}

void loop()
{
    //put your robot control logic here    
}

Features include:

  1. Controlling the LEDS
  2. Move forward and backward
  3. Turn
  4. Read the sensor values
  5. Use a PID controller
Committer:
sillevl
Date:
Mon Jun 01 14:53:39 2015 +0000
Revision:
9:0385d1bfc38b
Parent:
8:597ce8a7d34b
added Xbee support for start/stop

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pcordemans 4:3743cbfe031b 1 #include "robot_logic.h"
dwini 0:c0ae66a0ec7a 2
dwini 1:43c91152e9ce 3 // External functions called from our library
dwini 1:43c91152e9ce 4 extern void init(void);
dwini 0:c0ae66a0ec7a 5 extern void loop(void);
dwini 0:c0ae66a0ec7a 6
dwini 1:43c91152e9ce 7 /*
dwini 1:43c91152e9ce 8 * System initialization.
dwini 1:43c91152e9ce 9 * Also calls external init() function.
dwini 1:43c91152e9ce 10 */
dwini 0:c0ae66a0ec7a 11 void _init(void) {
dwini 0:c0ae66a0ec7a 12 // DO our init here
dwini 0:c0ae66a0ec7a 13 init(); // Students init
sillevl 8:597ce8a7d34b 14 #ifdef XBBE
sillevl 8:597ce8a7d34b 15 if(!xbee.hasCode()){
sillevl 8:597ce8a7d34b 16 error("no unique code is set when using Xbee for start/stop");
sillevl 8:597ce8a7d34b 17 }
sillevl 8:597ce8a7d34b 18 #endif
dwini 0:c0ae66a0ec7a 19 }
dwini 0:c0ae66a0ec7a 20
dwini 1:43c91152e9ce 21 /*
dwini 1:43c91152e9ce 22 * Entry point.
dwini 1:43c91152e9ce 23 * Also calls external loop function.
dwini 1:43c91152e9ce 24 */
dwini 1:43c91152e9ce 25 int main (void) {
dwini 0:c0ae66a0ec7a 26 // Initialize system
dwini 0:c0ae66a0ec7a 27 _init();
dwini 0:c0ae66a0ec7a 28
dwini 0:c0ae66a0ec7a 29 while (true) {
dwini 0:c0ae66a0ec7a 30 loop(); // Students loop
dwini 0:c0ae66a0ec7a 31 }
dwini 0:c0ae66a0ec7a 32 }