Modified library for the m3pi robot with individual calibrated sensor measurement functionality. This works with a Pololu 3pi robot with the Serial Slave firmware.
Fork of m3pi by
Revision 9:d9682f35e58a, committed 2018-10-02
- Comitter:
- thassyo
- Date:
- Tue Oct 02 16:35:36 2018 +0000
- Parent:
- 8:4b7d6ea9b35b
- Commit message:
- added send calibrated sensor values function
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 |
diff -r 4b7d6ea9b35b -r d9682f35e58a m3pi.cpp --- a/m3pi.cpp Thu May 12 13:26:37 2011 +0000 +++ b/m3pi.cpp Tue Oct 02 16:35:36 2018 +0000 @@ -102,6 +102,17 @@ return(v); } +int * m3pi::calibrated_sensors() { + int i; + static int sensors[5]; + _ser.putc(SEND_CALIBRATED_SENSOR_VALUES); + for(i=0;i<5;i++){ + sensors[i] = _ser.getc(); + sensors[i] += _ser.getc() << 8; + } + return(sensors); +} + float m3pi::line_position() { int pos = 0; _ser.putc(SEND_LINE_POSITION);
diff -r 4b7d6ea9b35b -r d9682f35e58a m3pi.h --- a/m3pi.h Thu May 12 13:26:37 2011 +0000 +++ b/m3pi.h Tue Oct 02 16:35:36 2018 +0000 @@ -32,6 +32,7 @@ #define SEND_SIGNATURE 0x81 #define SEND_RAW_SENSOR_VALUES 0x86 +#define SEND_CALIBRATED_SENSOR_VALUES 0x87 #define SEND_TRIMPOT 0xB0 #define SEND_BATTERY_MILLIVOLTS 0xB1 #define DO_PLAY 0xB3 @@ -155,6 +156,8 @@ * @returns battery voltage as a float */ float battery(void); + + int * calibrated_sensors(void); /** Read the position of the detected line * @returns position as A normalised number -1.0 - 1.0 represents the full range.