Energy harvesting mobile robot. Developed at Institute of Systems and Robotics — University of Coimbra.

Dependencies:   RF24

Fork of ISR_Mini-explorer by ISR UC

Revision:
4:560d24c0e5f8
Parent:
3:215c9544480d
--- a/robot.h	Fri Mar 16 16:49:02 2018 +0000
+++ b/robot.h	Thu Apr 19 15:35:29 2018 +0000
@@ -2,26 +2,22 @@
 
 #include "mbed.h"
 #include <math.h>
-#include <string.h>
 #include "VCNL40x0.h"
-#include <RF24.h>
+#include "Radio.h"
 #include "Encoder.h"
+#include "Rangefinder.h"
 
 I2C i2c(PTC9,PTC8);
 I2C i2c1(PTC11,PTC10);
-
+Mutex mutex_i2c0;
+Mutex mutex_i2c1;
 
-    float X=20;
-    float Y=20;
-    float THETA;
-    
-    Mutex mutex_i2c0, mutex_i2c1;
-    Encoder esquerdo(&i2c, &mutex_i2c0, 0);
-    Encoder direito(&i2c1, &mutex_i2c1, 1);
-    
-    Thread thread;
-    
-
+float X=20;
+float Y=20;
+float THETA;
+Encoder esquerdo(&i2c, &mutex_i2c0, 0);
+Encoder direito(&i2c1, &mutex_i2c1, 1);
+Thread thread;
 
 void odometry_thread()
 {
@@ -64,14 +60,8 @@
     }
 }
 
-
 // classes adicionais
-RF24 radio(PTD2, PTD3, PTD1,  PTC12 ,PTC13);
 VCNL40x0 VCNL40x0_Device (PTC9, PTC8, VCNL40x0_ADDRESS);
-
-
-Timeout timeout;
-
 Serial pc(PTE0,PTE1);
 
 
@@ -137,7 +127,6 @@
 DigitalOut    q_led_gre_rea     (PTA1);     //Led Green Rear
 DigitalOut    q_led_blu_rea     (PTA2);     //Led Blue Rear
 
-
 //SAIDAS DIGITAIS (pwm)
 PwmOut      pwm_mot_rig         (PTE20);    //PWM Enable Motor Right
 PwmOut      pwm_mot_lef         (PTE31);    //PWM Enable Motor Left
@@ -476,54 +465,6 @@
 }
 
 
-///////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////     RF COMMUNICATION      ////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
-
-/**
- * Initializes nrf24l01 module, return value 1 if module is working correcty and 0 if it's not.
- * 
- ** @param channel - Which RF channel to comunicate on, 0-125
- *
- * \warning Channel on Robot and Board has to be the same.
- */
- void init_nRF(int channel){
-        int result;
-      result = radio.begin();
-      
-      pc.printf( "Initialation nrf24l01=%d\r\n",  result ); // 1-working,0-not working
-      radio.setDataRate(RF24_250KBPS);
-      radio.setCRCLength(RF24_CRC_16);
-      radio.enableDynamicPayloads();
-      radio.setChannel(channel);
-      radio.setAutoAck(true);
-    
-      radio.openWritingPipe(0x314e6f6465);
-      radio.openReadingPipe(1,0x324e6f6465);
-    
-      radio.startListening();
-}
-
-char q[1];
-
-void radio_send_string(char *str)
-{
-    const int max_len = 30;
-    char *ptr;
-
-    ptr = str;
-
-    while(strlen(ptr) > max_len) {
-        radio.stopListening();
-        radio.write(ptr, max_len);
-        radio.startListening();
-        ptr += max_len;
-    }
-
-    radio.stopListening();
-    radio.write(ptr, strlen(ptr));
-    radio.startListening();
-}
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////      MISC.      ////////////////////////////////////////////
@@ -618,7 +559,6 @@
    
     init_Infrared();
     
-    
     thread.start(odometry_thread);
     
     float value = value_of_Batery();