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

Fork of ISR_Mini-explorer by ISR UC

Revision:
1:d1443589406e
Parent:
0:15a30802e719
--- a/robot.h	Thu Feb 02 12:21:11 2017 +0000
+++ b/robot.h	Thu Jul 27 13:05:03 2017 +0000
@@ -17,12 +17,11 @@
 #include <math.h>
 #include <string.h>
 #include "VCNL40x0.h"
-#include "nRF24L01P.h"
 
 void Odometria();
 
 // classes adicionais
-nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTC13, PTC12, PTA13);
+
 VCNL40x0 VCNL40x0_Device (PTC9, PTC8, VCNL40x0_ADDRESS);
 Timeout timeout;
 
@@ -490,178 +489,6 @@
     return Vin_b_v_battery;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////     RF COMUNICATION     ///////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
-
-
-/**
- * Initializes the NRF24 module for comunication.
- *
- * Note: if the module is broken or badly connected this init will cause the code to stop,
- *  if all these messages don't appear thats the case
- */
-void config_init_nrf()
-{
-    my_nrf24l01p.powerUp(); // powers module
-    my_nrf24l01p.setRfFrequency (2400); // channel 0 (2400-0 ... 2516-116)
-    my_nrf24l01p.setTransferSize(10);   // number of bytes to be transfer
-    my_nrf24l01p.setCrcWidth(8);
-    my_nrf24l01p.enableAutoAcknowledge(NRF24L01P_PIPE_P0); // pipe where data transfer occurs (0..6)
-    pc.printf( "nRF24L01+ Frequency    : %d MHz\r\n",  my_nrf24l01p.getRfFrequency() );
-    pc.printf( "nRF24L01+ Data Rate    : %d kbps\r\n", my_nrf24l01p.getAirDataRate() );
-    pc.printf( "nRF24L01+ TX Address   : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() );
-    pc.printf( "nRF24L01+ RX Address   : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() );
-    pc.printf( "nRF24L01+ CrC Width    : %d CrC\r\n", my_nrf24l01p.getCrcWidth() );
-    pc.printf( "nRF24L01+ TransferSize : %d Paket Size\r\n", my_nrf24l01p.getTransferSize () );
-    my_nrf24l01p.setReceiveMode();
-    my_nrf24l01p.enable();
-    pc.printf( "Setup complete, Starting While loop\r\n");
-}
-
-
-/**
- * Receives a number from the Arduino.
- *
- * @return The value send by the arduino
- */
-double receiveValue(void)
-{
-    char temp[4];
-    double Val;
-    bool ok=0;
-    my_nrf24l01p.setTransferSize(4);
-    my_nrf24l01p.setReceiveMode();
-    my_nrf24l01p.enable();
-    do {
-        if(my_nrf24l01p.readable(NRF24L01P_PIPE_P0)) {
-            ok = my_nrf24l01p.read( NRF24L01P_PIPE_P0,temp, 4);
-        }
-    } while(ok==0);
-
-    //transformation of temp to convert to original value
-    if(temp[0]==0) // if first elemente is 0 then its negative
-        Val = double(-(int(temp[1])+int(temp[2])*255+int(temp[3])*255*255));
-    else // else its positive
-        Val = double(int(temp[1])+int(temp[2])*255+int(temp[3])*255*255);
-
-    return Val;
-}
-
-
-/**
- * Sends a number to the Arduino
- *
- * @param Value - number to be sent to the Arduino
- */
-void sendValue(long int Value)
-{
-    bool ok=0;  // comunication sucess, o if failed 1 if sucessfull
-    // double math=Value/65025; // temporary variable save results
-    int zero=1;  // 1 byte, ( - ) if 0 ( + ) if 1
-    int one=0;   // 2 byte (0..255), multiplied by 1
-    int two=0;   // 3 byte (0..255), multiplied by 255
-    int three=0; // 4 byte (0..255), multiplied by 255*255
-
-//transformation of Value to send correctly through pipe
-    if (Value<0) {
-        zero=0;
-        Value=abs(Value);
-    }
-    //  Value=abs(Value);
-
-    double math=Value/65025; // temporary variable save results
-
-    if(math<1) {
-        math=Value/255;
-        if(math<1) {
-            two=0;
-            one=Value;
-        } else {
-            two=(int)math;
-            one=Value % 255;
-        }
-    } else {
-        three=(int)math;
-        math=Value/255;
-        if(math<1) {
-            two=0;
-            one=Value;
-        } else {
-            two=(int)math;
-            one=Value % 255;
-        }
-    }
-    char temp[4]= {(int)zero,(int)one,(int)two,(int)three};
-
-    // Apagar depois de testar mais vezes
-    // pc.printf("1 inidice...%i...\r", temp[0]);
-    // pc.printf("2 inidice...%i...\r", temp[1]);
-    // pc.printf("3 inidice...%i...\r", temp[2]);
-    // pc.printf("4 inidice...%i...\r", temp[3]);
-
-    my_nrf24l01p.setTransferSize(4);
-    my_nrf24l01p.setTransmitMode();
-    my_nrf24l01p.enable();
-    do {
-        ok = my_nrf24l01p.write( NRF24L01P_PIPE_P0,temp, 4);
-        if(ok==1)
-            pc.printf("Done.....%i...\r", Value);
-        else {
-            pc.printf("Failed\r");
-            wait(1);
-        }
-    } while(ok==0);
-}
-
-/**
- *  Sends matrix to arduino.
- *
- * @param matrix - Matrix of numbers to send [0..255]
- * @param row - Number of rows
- * @param column - Number of columns
- */
-void sendMatrix(int (*matrix)[18],int row , int column)
-{
-    short ok=0;
-    short int i =0;
-    short int j=0;
-    short int byte=0;
-    int members=column*row;
-    char message[32]= {0};
-    pc.printf("J ...%d... \r",members);
-
-    my_nrf24l01p.setTransferSize(32);
-    my_nrf24l01p.setTransmitMode();
-    my_nrf24l01p.enable();
-
-    do {
-        int* point = matrix[j];
-
-        do {
-            message[byte]= point[i];
-            if (byte==31 || (i+1)*(j+1)==members) {
-
-                do {
-                    ok = my_nrf24l01p.write( NRF24L01P_PIPE_P0,message, 32);
-                    if(ok==0)
-                        wait(1);
-
-                } while(ok==0);
-
-                byte=-1;
-            }
-
-            byte++;
-            i++;
-
-        } while(i<column);
-
-        i=0;
-        j++;
-    } while(j<row);
-
-}
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////      Sonar     ////////////////////////////////////////////
@@ -972,9 +799,9 @@
 {
     init_robot_pins();
     enable_dc_dc_boost();
-    init_Infrared();
-    initEncoders();
-    config_init_nrf();
+    //init_Infrared();
+    //initEncoders();
+
     enable_dc_dc_boost();
     wait_ms(100); //wait for read wait(>=150ms);
     measure_always_on();