Trying Garmin Lidar V3 for the first time. Using Girls of Steel doc have wired the Lidar via PWM scheme to DIO port. Have wrapped the Lidar code in a class and added it to LiveWindow so we can watch the Lidar distance values in Test mode. This sort of works. We see the distance value jumping all over the place, more less centered around the actual distance to target. For instance, if target is 10 inches away from Lidar, it returns values ranging from 5 to 20, mostly in the 7 to 15 range, changing constantly. Since LW updates on each scheduler cycle, we see the value change on almost every update. It seems like the further away the target, the more the distance reading settles down. We were expecting a fairly constant value if the target is not moving in relation to the sensor.
Im not sure if there is any way to tune the sensor better, but you could use the wpilib rolling average filter or some similar technique. Rolling average filter
Consider using a median filter or throwing away measurements that are too far from a moving average of the measurements.
Your use observations about it settling at farther ranges seems to be supported by their documentation: " * Accuracy: +/- 2.5cm at distances greater than 1 meter. Refer to manual for complete operating specifications."
From their manual it looks like things get a little non linear under 1m so that could be the variation you see
What is the surface that the LIDAR is sensing?
Do you have a way to connect the sensor using I2C to compare the readings to the PWM connection?
Your noise level sounds like more than would be expected, even at short distances. We used a LIDAR Lite V3 in 2019 to sense distance to the orange cargo balls in Deep Space. We would stop feedback control at 12 inches, but up to that point the distance signal was pretty solid. I don’t know if we could say that we were getting +/- 1 inch all the way down to 12 inches, but I’m sure it wasn’t +/- 5 inches.
Thanks for all the suggestions. I have filters coded and ready to try but I posted here because, like paulonis suggests, the variability seems well over what I would expect.
The surface is cardboard and also wood. So far surface does not seem to be a factor. I went PWM to keep the I2C port free and the code is simpler. To try I2C I will need to make a cable and get the code together, which will take time, and these days I am not at the lab much, but it’s a good idea.
Median filter settled it right down. Works good beyond 15 inches, gets less accurate below that but still usable.