Based upon a serial interface description that I found at
http://forums.trossenrobotics.com/tutorials/how-to-diy-128/complete-control-of-an-arduino-via-serial-3300/, I have decided to try doing the interface in a like manner. I could use firmata but I do not want to program the RPi in python. Here is what I have come up with so far:
Robot Interface Protocol (Serial)
1 - write
1 - digital pin write
"pin number"
"1 for LOW, 2 for HIGH" --> sets pin to value, returns OK
2 - analog pin write
"pin number"
"frequency (0-255)" --> sets pwm on pin to value, returns OK
3 - LCD panel error display
"error number"
2 - read
1 - digital
"pin number" --> returns digital pin value (0 or 1)
2 - analog
"pin number" --> returns analog pin value (0 - 1024)
3 - servo (via Maestro)
1 - read
"servo number" --> returns pwm value
2 - write
"servo number"
"pwm value" --> sets servo to pwm value, returns OK
4 - IR distance sensor (GP2D12 and servo)
1 - set sweep range
"low sweep pwm value (4000 - 8000)"
"high sweep pwm value (4000 - 8000)"
"sweep speed (0.25 us / 10 ms)"
"sample rate in ms" --> returns OK
2 - set IR distance servo
"pwm value" --> returns OK
3 - sample IR distance sensor (raw) --> returns "IR", raw value
4 - sample IR distance sensor (computed) --> returns "IR", computed value
5 - start continuous sample
-->starts sweep back and forth; returns "IR", pwm, computed,
raw at sample rate
6 - stop continuous sample --> returns OK
7 - get statistics at current pwm
"number of samples" --> returns "IR", pwm, mean, sd of computed, mean, sd of raw
8 - display samples on LCD panel
1 - start --> returns OK, starts showing samples on LCD panel
2 - stop --> stops showing samples, clears LCD panel, returns OK
5 - Ultrasonic distance sensor (HC-SR04 and servo)
1 - set sweep range
"low sweep pwm value (4000 - 8000)"
"high sweep pwm value (4000 - 8000)"
"sweep speed (0.25 us / 10 ms)"
"sample rate in ms" --> returns OK
2 - set Ultrasonic distance servo
"pwm value" --> returns OK
3 - sample Ultrasonic distance sensor (raw) --> returns "UL", raw value
4 - sample Ultrasonic distance sensor (computed) --> returns "UL",
computed value
5 - start continuous sample
-->starts sweep back and forth; returns "UL", pwm, computed,
raw at sample rate
6 - stop continuous sample --> returns OK
7 - get statistics at current pwm
"number of samples" --> returns "UL", pwm, mean, sd of computed, mean, sd of raw
8 - display samples on LCD panel
1 - start --> returns OK, starts showing samples on LCD panel
2 - stop --> stops showing samples, clears LCD panel, returns OK
6 - camera pan and tilt servos
1 - set sweep range for pan
"low sweep pwm value (4000 - 8000)"
"high sweep pwm value (4000 - 8000)"
"sweep speed (0.25 us / 10 ms)" --> returns OK
2 - set sweep range for pan
"low sweep pwm value (4000 - 8000)"
"high sweep pwm value (4000 - 8000)"
"sweep speed (0.25 us / 10 ms)" --> returns OK
3 - set camera pan and tilt servos
"pan pwm value"
"tilt pwm value" --> returns OK
4 - start continuous sweep
-->starts sweep back and forth; returns OK
5 - stop continuous sweep --> returns OK
7 - reset all to setup conditions