This adds to the existing m3pi mbed library to add driving commands with speeds as integers ranging from -255 for 255, as does the serial slave program for the m3pi. Library for the m3pi robot. This works with a Pololu 3pi robot with the Serial Slave firmware, and exposes an API.

Fork of m3pi by Chris Styles

Revision:
9:3f9c47a7fc66
Parent:
7:9b128cebb3c2
--- a/m3pi.cpp	Thu May 12 13:26:37 2011 +0000
+++ b/m3pi.cpp	Sun May 27 22:06:09 2018 +0000
@@ -75,6 +75,26 @@
     motor(1,0.0);
 }
 
+void m3pi::left_motor(int speed) {
+    if (speed > 0) {
+        _ser.putc(M1_FORWARD);
+        _ser.putc(speed);
+    } else {
+        _ser.putc(M1_BACKWARD);
+        _ser.putc(-speed);
+    }
+}
+
+void m3pi::right_motor(int speed) {
+    if (speed > 0) {
+        _ser.putc(M2_FORWARD);
+        _ser.putc(speed);
+    } else {
+        _ser.putc(M2_BACKWARD);
+        _ser.putc(-speed);
+    }
+}
+
 void m3pi::motor (int motor, float speed) {
     char opcode = 0x0;
     if (speed > 0.0) {