I have created an updated version of the DI GoPiGo ultrasonic sensor servo scan code for the GoPiGo3 with DI Servo Package and DI Distance Sensor.
My code is available here, with a draft README.
This update also
- adjusts printing scale factor selected by farthest object measurement,
- explains dimension of axis ticks resulting from the scale factor
- adds x and y dimension on map
- adds a REVERSE_AXIS flag for users with non-Dexter Servos that rotate opposite
- communicates “Closest Object” found in each scan
- communicates basis for move or stay(quit program) decision
- communicates distance moved between successive scans
- logs scan for objects in output
- adds a “Stopping to enjoy the view” pause to mark each collection/print cycle and allow perusal of the result map.
and adds optional debug printing of data along the processes of:
- collecting the sparse matrix of r-theta data points,
- conversion to cartesian coordinate data points,
- rotation and origin-translation of sparse data array for printing,
- creation of a non-sparse object/no-object binary value matrix
- selection of a print character for each point in the non-sparse matrix
Sample output from this version:
*** SCANNING ***
Map: 75 cm
---------------------------------------------------
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| o ooooooooooooooo |
| oo o o |
| o |
| o o |
| o o |
| o |
| o oo |
| o o |
| o oo |
| o + o |
--------------------------------------------------- 75 cm
Closest Object: 13 cm, Each '-' is 3 cm
*** STOPPING TO ENJOY THE VIEW ***
*** WE HAVE CLEARANCE TO MOVE 3.9cm ***
*** SCANNING ***
Map: 50 cm
---------------------------------------------------
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| o o oo o o ooo o |
| o o oo oo ooooo o |
| o |
| o |
| o o |
| o o |
| o |
| o o |
| |
| o o |
| o o |
| o |
| o + o |
--------------------------------------------------- 50 cm
Closest Object: 12 cm, Each '-' is 2 cm
*** STOPPING TO ENJOY THE VIEW ***
*** WE HAVE CLEARANCE TO MOVE 3.6cm ***
*** SCANNING ***
Map: 50 cm
---------------------------------------------------
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| o |
| o o oo |
| o oooo |
| oooooooooooo |
| o oo oo o |
| o o |
| o + o |
--------------------------------------------------- 50 cm
Closest Object: 8 cm, Each '-' is 2 cm
!!! FREEZE - THERE IS SOMETHING INSIDE MY PERSONAL SPACE !!!