Generate Distance Sensor Test Data and Display 180/360 Views

I have created a Python module for displaying a “Forward 180” view or an “All Directions 360” view of ultrasound or distance sensor “r-theta” data.

These routines are configurable for print width / resolution and valid data filtering.

Additionally, there are a number of test data generators, that will be useful to anyone developing algorithms to interpret sensor data, such as “Is there a wall in front of me?”, “Find the nearest corner (to sit in)”, “How long is that wall”, “Do I have room to turn around?”, “What’s behind that wall?” just to brainstorm a few possible uses.

The test data generators can also be configured to introduce sensor accuracy errors to stress test interpretation algorithms.

All the routines are in printmaps.py on github

Here are samples of the test data as printed with the view180() and view360() functions:

pi@Carl:~/Carl/Projects/Scan360 $ ./printmaps.py
***** TEST printmaps.py *******


CREATE and DISPLAY: 180 Degree Sector READINGS 

Map:                        60 inches
 ---------------------------------------------------------
|                        o o o o o                        |
|                   o o             o o                   |
|              o  o                     o o               |
|           oo                               oo           |
|         o                                     o         |
|       o                                         o       |
|      o                                           o      |
|    o                                               o    |
|   o                                                 o   |
|  o                                                   o  |
| o                                                     o |
| o                                                     o |
| o                                                     o |
|o                           +                           o|
 ----------------------------0---------------------------- 60 inches
Each '-' is 2.1 inches      Each '|' is 4.5 inches
Closest Object: 60.0 inches  Farthest Valid Object: 60.0 inches
Farthest Reading: 60.0 inches


CREATE and DISPLAY: 120 Degree Sector READINGS 

Map:                        230 cm
 ---------------------------------------------------------
|                            o                            |
|                     o             o                     |
|              o                          o               |
|                                                         |
|         o                                     o         |
|                                                         |
|                                                         |
|    o                                               o    |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                            +                            |
 ----------------------------0---------------------------- 230 cm
Each '-' is 8.2 cm      Each '|' is 17.4 cm
Closest Object: 230.0 cm  Farthest Valid Object: 230.0 cm
Farthest Reading: 230.0 cm


CREATE and DISPLAY: 120 Degree Sector RANDOMIZED READINGS

Map:                        80 inches
 ---------------------------------------------------------
|                          o                              |
|                  oo o oooooooooooo                      |
|             o  oooooooooooooooooo oooo oo               |
|           ooooooooooooooooooooooo o oo  o o             |
|          o  oo ooo ooooooo oo oooooooooooooo o          |
|       ooo oooooo ooooooo ooo ooooooo oooooooooo         |
|      o o  oo ooooo oooo  ooooo ooooooooooooooooo o      |
|     oo oooo ooo oooooooooooo o ooooooooo ooooooo o      |
|          ooooooo oooooooooooooooo ooooooooooooooo       |
|            oooooooooooooooooooooooooooooooo o           |
|              o ooooooooooooooooooo oooooo               |
|                   ooooooooooooooooooo                   |
|                       oooooooooooo                      |
|                         ooo+oo                          |
 ----------------------------0---------------------------- 80 inches
Each '-' is 2.9 inches      Each '|' is 6.0 inches
Closest Object: 2.0 inches  Farthest Valid Object: 79.9 inches
Farthest Reading: 79.9 inches


CREATE and DISPLAY: 60 Degree Sector of WALL AT 90 degrees

Map:                        14 inches
 ---------------------------------------------------------
|                                                         |
|                                                         |
|              o       o     o     o      o               |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                            +                            |
 ----------------------------0---------------------------- 14 inches
Each '-' is 0.5 inches      Each '|' is 1.0 inches
Closest Object: 12.0 inches  Farthest Valid Object: 13.9 inches
Farthest Reading: 13.9 inches


CREATE and DISPLAY: 60 Degree Sector of Wall (NORMAL 15deg) with SENSOR ERRORS

Map:                        16 inches
 ---------------------------------------------------------
|                                                         |
|                                                         |
|              o                                          |
|                       o                                 |
|                            o                            |
|                                 o    o                  |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                                                         |
|                            +                            |
 ----------------------------0---------------------------- 16 inches
Each '-' is 0.6 inches      Each '|' is 1.2 inches
Closest Object: 11.5 inches  Farthest Valid Object: 16.3 inches
Farthest Reading: 16.3 inches


CREATE and DISPLAY: 360 Degree Scan

Map:                        90 deg
 --------------------------------------------------------- 230 cm
|                            o                            |
|                     o             o                     |
|              o                          o               |
|                                                         |
|         o                                     o         |
|                                                         |
|                                                         |
|    o                                               o    |
|                                                         |
|                                                         |
| o                                                     o |
|                                                         |
|                                                         |
|o                           +                           o0  180 deg
|                                                         |
|                                                         |
| o                                                     o |
|                                                         |
|                                                         |
|    o                                               o    |
|                                                         |
|                                                         |
|         o                                     o         |
|                                                         |
|              o                           o              |
|                     o             o                     |
 ----------------------------0---------------------------- 230 cm
Each '-' is 8.2 cm      Each '|' is 17.4 cm
Closest Object: 230.0 cm  Farthest Valid Object: 230.0 cm
Farthest Reading: 230.0 cm


CREATE and DISPLAY: 360 Degree Scan with RANDOMIZED READINGS

Map:                        90 deg
 --------------------------------------------------------- 228 cm
|                                                         |
|                                                         |
|                            o            o               |
|                      o           o                      |
|                                                         |
|                  o                                      |
|                                            o            |
|              o                                    o     |
|         o                                               |
|                                                         |
|   o                                                o    |
|                                                         |
|                                                         |
|      o                     +                  o         0  180 deg
|                                                         |
|          o                                   o          |
|                                                         |
|                                                         |
|                                                         |
|      o                                           o      |
|             o                                           |
|                                      o                  |
|                       o                       o         |
|                                  o                      |
|               o                                         |
|                            o                            |
 ----------------------------0---------------------------- 228 cm
Each '-' is 8.2 cm      Each '|' is 17.3 cm
Closest Object: 153.5 cm  Farthest Valid Object: 228.4 cm
Farthest Reading: 228.4 cm


CREATE and DISPLAY: 360 Degree Scan of FOUR WALLS

Map:                        90 deg
 --------------------------------------------------------- 25 cm
|                            o                            |
|                                                         |
|                         o     o                         |
|                       o         o                       |
|                    o               o                    |
|                  o                   o                  |
|                o                       o                |
|              o                          o               |
|             o                             o             |
|           o                                 o           |
|         o                                     o         |
|      o                                           o      |
|    o                                               o    |
| o                          +                           o0  180 deg
|    o                                               o    |
|      o                                           o      |
|         o                                     o         |
|           o                                 o           |
|             o                             o             |
|               o                          o              |
|                o                       o                |
|                  o                   o                  |
|                    o               o                    |
|                       o         o                       |
|                         o     o                         |
|                                                         |
 ----------------------------0---------------------------- 25 cm
Each '-' is 0.9 cm      Each '|' is 1.9 cm
Closest Object: 17.7 cm  Farthest Valid Object: 25.0 cm
Farthest Reading: 25.0 cm


CREATE and DISPLAY: 360 Degree Scan of FOUR WALLS with 15% SENSOR ERRORS

Map:                        90 deg
 --------------------------------------------------------- 26 cm
|                                                         |
|                                                         |
|                         o  o                            |
|                              o                          |
|                       o         o                       |
|                     o             o                     |
|                o  o                 o                   |
|              o                       o  o               |
|             o                            o              |
|           o                                o            |
|        o                                     o          |
|       o                                         o       |
|    o                                             o      |
|o                           +                        o   0  180 deg
|     o                                             o     |
|        o                                       o        |
|          o                                   o          |
|           o                                o            |
|             o                             o             |
|              o  o                    o  o               |
|                   o                 o                   |
|                                   o                     |
|                     o                                   |
|                       o         o                       |
|                         o     o                         |
|                                                         |
 ----------------------------0---------------------------- 26 cm
Each '-' is 0.9 cm      Each '|' is 2.0 cm
Closest Object: 16.7 cm  Farthest Valid Object: 26.4 cm
Farthest Reading: 26.4 cm
pi@Carl:~/Carl/Projects/Scan360 $ 

That’s a really cool thing. I’m gonna put this in our backlog to have it implemented in ours if that’s okay with you.

Thank you!

1 Like

Thanks. Use and improve!

(e.g. It will be cool to “see” what your kmeans intelligent object avoider is “thinking.” )

And by tuning the egpg.WHEEL_DIAMETER and egpg.WHEEL_CIRCUMFERENCE to values found with wheelDiaRotateTest.py, I can get consistent scans with myDS360scan.py:

pi@Carl:~/Carl/Projects/Scan360 $ ./myDS360scan.py 

SPIN 360 AND SCAN at speed=120

Map:                                  90 deg
 ----------------------------------------------------------------------------- 174 cm
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                              o o o o o oo o  o    o       o                 |
|           o                  o                                              |
|                                                         o                   |
|        o                             +              o                       0  180 deg
|                                                                             |
|       o                                                                     |
|                                                                             |
|                                    o o                                      |
|           o        o                                                        |
|                         o   o                                               |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                        o                                                    |
|                                                                             |
 --------------------------------------0-------------------------------------- 174 cm
Each '-' is 4.6 cm      Each '|' is 9.7 cm
Closest Object: 34.7 cm  Farthest Valid Object: 174.5 cm
Farthest Reading: 300.0 cm
Readings:35

SPIN 360 AND SCAN at speed=120

Map:                                  90 deg
 ----------------------------------------------------------------------------- 173 cm
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                               o  o ooo oo  o  o    o        o               |
|                              o                                              |
|         o                    o                                              |
|       o                              +                                      0  180 deg
|                                                     o                       |
|                                                                             |
|        o                                                                    |
|                                    o o                                      |
|               o                                                             |
|                     o     o                                     o           |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                    o        |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
|                                                                             |
 --------------------------------------0-------------------------------------- 173 cm
Each '-' is 4.6 cm      Each '|' is 9.7 cm
Closest Object: 34.4 cm  Farthest Valid Object: 173.3 cm
Farthest Reading: 300.0 cm
Readings:30