Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ISR_Mini-explorer_Rangefinder
Fork of ISR_Mini-explorer by
Diff: robot.h
- Revision:
- 4:f6fddeae358e
- Parent:
- 3:215c9544480d
- Child:
- 5:43215ff15665
--- a/robot.h Fri Mar 16 16:49:02 2018 +0000
+++ b/robot.h Thu Apr 19 15:44:26 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,6 +559,8 @@
init_Infrared();
+ init_rangefinder(&i2c1, &mutex_i2c1);
+
thread.start(odometry_thread);
