librairie pour robot Zumo

Files at this revision

API Documentation at this revision

Comitter:
bouaziz
Date:
Mon Jan 10 08:59:37 2022 +0000
Parent:
10:7935bbc4ebf1
Child:
12:d9c9ef63c5ff
Commit message:
Zumo lib Polytech paris Saclay

Changed in this revision

readme.txt Show annotated file Show diff for this revision Revisions of this file
zumo.cpp Show annotated file Show diff for this revision Revisions of this file
zumo.h Show annotated file Show diff for this revision Revisions of this file
--- a/readme.txt	Wed Dec 08 16:33:24 2021 +0000
+++ b/readme.txt	Mon Jan 10 08:59:37 2022 +0000
@@ -1,6 +1,7 @@
 
 Liste des commandes bas niveau
-speed : 0xAB attente retour 0x0A du robot ensuite envoi des 4 octets vitesse G D
+speed : 0xA4   0xA0 code + 4 nombre d'octets qui suivront,
+         attente retour 0x0A du robot ensuite envoi des 4 octets vitesse G D
 
 
 
--- a/zumo.cpp	Wed Dec 08 16:33:24 2021 +0000
+++ b/zumo.cpp	Mon Jan 10 08:59:37 2022 +0000
@@ -5,12 +5,12 @@
 #include "zumo.h"
 
 zumo::zumo(PinName nrst, PinName tx, PinName rx) : _nrst(nrst), _ser(tx, rx)  {
-    _ser.baud(38400);
+    _ser.baud(57600);
     reset();
 }
 
 zumo::zumo():  _nrst(p23), _ser(p9, p10){
-        _ser.baud(38400);
+        _ser.baud(57600);
     }   
 
 
@@ -19,13 +19,14 @@
 
 
 void zumo::stop (void) {
-    speed(0,0);
+    _ser.putc(SEND_MOTOR_STOP);
+    _ser.getc();
+    
 }
 
 char zumo::speed(short spg,short spd){
-    char v=0xAB;
-    _ser.putc(v);
-    _ser.getc();
+    char v;
+    _ser.putc(SEND_MOTOR_SPEED);
     _ser.putc(spg&0xff);
     _ser.putc((spg>>8)&0xff);
     _ser.putc(spd&0xff);
--- a/zumo.h	Wed Dec 08 16:33:24 2021 +0000
+++ b/zumo.h	Mon Jan 10 08:59:37 2022 +0000
@@ -27,8 +27,11 @@
 #include "platform.h"
 
 
-#define SEND_SIGNATURE 0x81
-#define SEND_RAW_SENSOR_VALUES 0x86
+#define SEND_MOTOR_SPEED 0xA4
+#define SEND_MOTOR_STOP 0xA0
+
+
+
 #define SEND_CALIB_SENSOR_VALUES 0x87
 #define SEND_TRIMPOT 0xB0
 #define SEND_BATTERY_MILLIVOLTS 0xB1