Not finished. This is my first attemp to make an autonomous vehicle for the Sparkfun Autonomous Competition (https://avc.sparkfun.com/) of June 2015.

Dependencies:   FXOS8700CQ SDFileSystem mbed

Fork of AVC_Robot_Controled_Navigation by AVR Competition

  • For my autonomous robot I will use a GPS, magnometer, accelerometer, and encoders.
  • I control my robot with a remote control to save the GPS points (detect turns) using a xBee radio and save them to a file in a SD card.
Revision:
0:3a322aad8c88
Child:
1:ab09b233da7b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 16 01:59:21 2014 +0000
@@ -0,0 +1,108 @@
+/* ==================================================================================
+    --- TEST 1 ---
+    OBJETIVE:
+    Move the motor via bluetooth and program 90° turns to the right and left using 
+    the magnometer. It will report data from the encoders and limit the movement by
+    the ultrasonic sensors
+    
+    COMPONENTS:
+    * Bluetooth
+    * Magnometer    (FXOS8700CQ & magnometer.h)
+    * Motors        (motors.h)
+    * Encoder
+    * Ultrasonics
+    
+    CONTROLS:
+    w: foward
+    s: reverse
+    a: left turn
+    d: right turn
+    o: 90° left turn
+    p: 90° right turn
+    
+    Credits:
+    * Mayumi Haro
+    * Sarahí Morán
+    * Gerardo Carmona
+    
+    VERSION:
+    1.0 - 10/14/14
+
+    HISTORY:
+    1.0 - 10/14/14
+    (+) Initial release.
+    
+    
+================================================================================== */
+
+// ----- Libraries ------------------------------------------------------------------
+#include "mbed.h"
+#include "motors.h"
+#include "magnometer.h"
+
+// ----- Constants ------------------------------------------------------------------
+#define LED_ERROR       6
+#define LED_NORMAL      5
+#define LED_BUSY        3
+#define BT_TIME         100
+
+// ----- I/O Pins -------------------------------------------------------------------
+Serial pc(USBTX, USBRX);
+Serial bt(PTC15, PTC14);
+//FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1)
+// Leds for status
+BusOut leds(LED_RED, LED_GREEN, LED_BLUE);
+
+// Sensors
+//AnalogIn current_left(A0);
+//AnalogIn current_left(A1);
+AnalogIn ultra_left(A2);
+AnalogIn ultra_right(A3);
+DigitalIn encoder_left(D3);
+DigitalIn encoder_right(D4);
+
+// ----- Others ---------------------------------------------------------------------
+//SRAWDATA accel_data;
+//SRAWDATA magn_data;
+Timer bt_timer;
+Timer gps_timer;
+
+// ----- Variables ------------------------------------------------------------------
+double mag_x, mag_y;
+double average;
+char bt_data;
+
+// ----- Function prototypes --------------------------------------------------------
+//double get_mag_x();
+//double get_mag_y();
+//double get_mag_angle();                             // Read angle from the compass
+char read_bt();
+
+// ----- Main program ---------------------------------------------------------------
+int main(){
+    bt.baud(9600); 
+    pc.baud(9600);
+    //fxos.enable();
+    leds = LED_NORMAL;
+    bt_timer.start();
+    
+    while (true){
+        if (bt_timer.read_ms() >= BT_TIME){
+            bt_data = read_bt();
+            if (bt_data != ' '){
+                move_motors(bt_data, 100, 100);
+            }
+        }
+    }
+}
+
+// ----- Functions ------------------------------------------------------------------
+
+char read_bt(){
+    char c = ' ';
+    if (bt.readable()){
+        c = bt.getc();
+        bt.printf("%c\n\r", c);
+    }
+    return c;
+}
\ No newline at end of file