I was testing Grove ultrasonic and DI distance sensors on my GoPiGo2 using the library
easygopigo and noticed that the measurement time for two sensors was very different. For the ultrasonic sensor it’s 0.42 seconds and for the distance sensor - 0.16 seconds. When I switched to the older library
gopigo and tested the ultrasonic sensor again, I’ve got 0.09 seconds. Since the DI distance sensor is not supported in
gopigo, I don’t have results for it.
The measurement time is crucial for me because I need to perform 5 distance measurements within 1 second (ideally within 0.5 second) for my adaptive cruise control project. It needs to be compatible with both sensors and should be programmed with
easygopigo on my GoPiGo2 because the code will be later transferred to GoPiGo3 using
So I checked the code of
easygopigo and looked into the class
DistanceSensor. They both include 3 attempts of measurements to account for faulty measurements that occur from time to time. Moreover, each attempt in
UltraSonicSensor has an extra delay of 0.05 second (line 509) while each attempt in
DistanceSensor only 0.001 second (line 899). For the ultrasonic sensor this time adds up (0.09 + 0.05) * 3 = 0.42 and gives exactly the same measurement time as I reported previously.
Based on these observations I have the following questions/suggestions for both
- Would it be possible to adjust the delay time for each attempt in
UltraSonicSensorto 0.001 second (just like in
- Would it be possible to decrease the number of attempts to 2 for both
DistanceSensor? So far I have never seen the faulty measurement more than one time in a row.
- Would it be possible for me to adjust the local copies of
easygopigo3on my SD card to bypass the above mentioned restrictions?
Thank you very much!