Hello, I am currently working on software using data from the scanning imaging sonar (Ping360).
Part of the software is creating a collision avoidance system, and in that regard I need to change the scan length. I am using the python libraries.
From the data sheet it is given that the ranged is from 0.75m til 50m.
I am using an example program from Github, but I am not sure how to actually find what range I am scanning. Which class methods should I use to set a new scan range? I am guessing it have to do something with the transmit_duration, but osme help would be greatly appreciated.
It makes it a bit clearer, however as I am implementing my logic in Python, some of the c++ code example is a bit confusing to me. For example what is a good substitution for the qFuzzyCompare functions.
Are there any other examples of setting range implemented in Python?
Or could I get some additional help in setting up the functions, and some help with which parameters I should set?
I see that there is implemented setting range functions in Ping1D, is there any particular reason that it is not in Ping360?
qFuzzyCompare is a Qt function that checks if two numbers are equivalent (same as the == operator in Python). In the set_range function, it’s being used to check if the new commanded range is the same as the existing stored range, and if so returning early (there’s not much value in commanding a settings change without actually changing any settings).
I’ve raised an issue for us to add an implementation of it in the library (because I think it would be a useful addition), but I don’t know what kind of timeline that will have. I’m not aware of any existing Python implementations.
What help are you after, specifically? The thread I linked you to covers the parameters that determine the range (sample_period and number_of_sampes), as well as the equation that relates them. The Ping Viewer implementation that’s linked to covers the actual set_range functionality, which calculates the sample period (calculateSamplePeriod) from the currently specified sound speed and number of samples, and updates the transmit duration (adjustTransmitDuration) to stay within reasonable limits for the sensor.
Basically, the Ping360 firmware provides more direct access to the device itself, and additional abstraction needs to be implemented by the code that’s communicating with it. Our libraries currently only implement the ping-protocol and what’s required to make a connection (e.g. serial / udp connection functions), which provides access to everything the devices themselves can do.
Additional abstract functionality could definitely be useful, but interface and accessibility improvements are frequently prioritised below fixing or implementing critical functionality elsewhere. Our software team is small, and time is unfortunately a limited resource.
Hello. I have tried to implement the range functionality as described in the ping-viewer c++ program that is mentioned previously. However I am a bit stuck as it is difficult to test my functions properly, as I can only operate the sonar above water for the time being. Below is a sample of my script, all functions are implemented within the ping360 Class. When I set the “_sample_period” to 80, and the “_number_of_samples” to 800. And finally call the “range” function, it outputs only 1.2 meters.
My problem is that I don’t know if this is a correct output, as I have no reference.
Does this value under the given parameters make sense?
Additionally, I would appreciate if I could get some direction as to where to find which values would give what range readings.
Could I get some example parameters, and the resulting range value?
That would help me with testing the software.
Finally, in the Ping360 class there is some explanation about parameters, as for example “sample_period” and “transmit_frequency”.
But is there some place where I could find more precise information about the parameters, as for minimum and maximum values for good sonar readings?
# Multiply with samplePeriodTickDuration which is 25 nanoseconds
return self._sample_period * 25E-9
# Returns the set scanning range currently set
# 1500 is the speed of sound and is constant
print("Number of samples", self._number_of_samples)
return self.samplePeriod() * self._number_of_samples * 1500 / 2
# Sets new sonar scan range
def set_range(self, newRange):
# Checks if new argument is different from set range
if (newRange == range()):
Yes, that’s correct. 800 2 microsecond samples with a sound speed of 1500m/s gives a total distance travelled of 2.4m, and since the sonar measures reflections then the range is half of that, which is 1.2m
Your calculations are already correct, but if you want to double check you can turn on debug mode in Ping Viewer, and see what the parameters are for a given range.
“Good” depends on the operating conditions, but the parameters are described in the ping protocol docs. The parameter descriptions in the Ping Viewer docs may also be useful, together with the Ping Viewer implementation for setting default values.
Thank you for the help, the ping viewer troubleshooter interface is a good tool.
So to reiterate, the adjusting of range functionality, will in practice be determined by to parameters. Which is “number_of_samples” and “sample_period”.
Follow up question: when adjusting from my 1.2 meter scan settings as described above, which parameters should be changed for best quality output signal? Should I only change one of the parameters, or should I scale up both with a certain relationship?
For example if I want to change the scan range to 50 meters? Does this depend on operating conditions, or are there some general rule of thumb to follow?
Yes, sample_period and number_of_samples are the Ping360 parameters that define the range, although the speed of sound is also part of the calculation.
More samples means more data you need to process, which may or may not be a problem. Shorter sample period means higher range resolution, so you can detect finer details. Ping Viewer just uses as many samples as possible for the range (which is basically always 1200), but you may want/need to use fewer samples per ping if your processing isn’t fast enough for the rotation/scanning rate you want.
Note that the transmit duration and gain are relevant to signal quality, and should both in general go up with the range.