function correction on motor control adding get individual sensor function

Dependents:   m3PI_TP_POPS_II2015v0 m3PI_TP_POPS_II2015v0 ourproject m3PI_TP_SETI ... more

Fork of m3pi by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
bouaziz
Date:
Mon Nov 23 23:22:28 2015 +0000
Parent:
8:4b7d6ea9b35b
Commit message:
update ; motor inversion control + get individual sensor function; POPS PAris Sud

Changed in this revision

m3pi.cpp Show annotated file Show diff for this revision Revisions of this file
m3pi.h Show annotated file Show diff for this revision Revisions of this file
--- a/m3pi.cpp	Thu May 12 13:26:37 2011 +0000
+++ b/m3pi.cpp	Mon Nov 23 23:22:28 2015 +0000
@@ -43,11 +43,11 @@
 }
 
 void m3pi::left_motor (float speed) {
-    motor(0,speed);
+    motor(1,speed);
 }
 
 void m3pi::right_motor (float speed) {
-    motor(1,speed);
+    motor(0,speed);
 }
 
 void m3pi::forward (float speed) {
@@ -112,6 +112,15 @@
     return(fpos);
 }
 
+void m3pi::calibrated_sensors(unsigned short ltab[5]) {
+    unsigned i;
+    _ser.putc(SEND_CALIB_SENSOR_VALUES);
+    for(i=0;i<5;i++){
+        ltab[i] = (unsigned short) _ser.getc();
+        ltab[i] += _ser.getc() << 8;
+    }
+}
+
 char m3pi::sensor_auto_calibrate() {
     _ser.putc(AUTO_CALIBRATE);
     return(_ser.getc());
--- a/m3pi.h	Thu May 12 13:26:37 2011 +0000
+++ b/m3pi.h	Mon Nov 23 23:22:28 2015 +0000
@@ -32,6 +32,7 @@
 
 #define SEND_SIGNATURE 0x81
 #define SEND_RAW_SENSOR_VALUES 0x86
+#define SEND_CALIB_SENSOR_VALUES 0x87
 #define SEND_TRIMPOT 0xB0
 #define SEND_BATTERY_MILLIVOLTS 0xB1
 #define DO_PLAY 0xB3
@@ -163,7 +164,12 @@
      *   1.0 means the line is on the right
      */
     float line_position (void);
-
+    /** lecture capteurs calibres
+    * @returns tableau val capteurs de gauche à droite 
+    *  0 blanc (reflexion max)
+    *  1000 noir (pas de reflexion)
+    */
+    void calibrated_sensors(unsigned short ltab[5]);
 
     /** Calibrate the sensors. This turns the robot left then right, looking for a line
      *