Ping 360 time info/split image

Some initial data (from three trials of each) - Ping360 via ethernet connection:

Angular Step Size [gradians] Distance [m] Sample Period [ticks] Transmit Duration [us] Ping Viewer avg. time [s] Python avg. time [s] Python slower by
1 2 88 11 10.74 11.80 9.84%
1 20 888 107 20.57 21.61 5.04%
1 50 2222 267 37.6 38.42 2.17%
10 2 88 11 3.29 3.29 0.00%
10 20 888 107 4.19 4.32 3.18%
10 50 2222 267 5.89 6.01 1.98%

On average, Python was 3.70% slower (so, measurable, but not too bad).

Common testing parameters:

parameter value
gain 0 (low)
sector angle 360 degrees
speed of sound 1500
transmit freq 750kHz
number of samples 1200

I would note that the update to 0.1.2 included this PR, which provided a 27% speedup for a Ping360 (tested on a 2M baud USB-serial connection), so performance-wise that update is quite important for ping-python being anywhere close to the C++/Ping Viewer performance.

I should be able to change my interface over and do some USB-serial tests next week :slight_smile:

Thanks for your data. I will try that out this week and report our findings.

@EliotBR
My Findings are the Following(With USB3, important with 2M baudrate on Normal Desktop Computer):
I just copied your table, and changed the measurements.

Edit: This was tested with Intel i9 CPU and is much faster than RPI4, which was used by @EliotBR

Angular Step Size [gradians] Distance [m] Sample Period [ticks] Transmit Duration [us] Ping Viewer avg. time [s] Python avg. time [s] Python slower by
1 2 88 11 6.7 7.8 16.4%
1 20 888 107 17.0 18.4 8,2%
1 50 2222 267 33.8 35.0 3.6%
10 2 88 11 2.83 2.88 1.7%
10 20 888 107 3.8 3.92 3.2%
10 50 2222 267 5.5 5.65 2.7%

As far as I can see is the speed much better with USB and a Baudrate of 2M in contrast to Ethernet.
For me, I just learned how much of a difference there is with different baud rates.
I think using USB results in slower python code compared to C++, but generally is faster. But maybe there is something different in the setup you used.

You can test it yourself again if you want, but for me, I think I am very pleased with the result. Thanks for your Help.

I’ve just done my Python tests with serial-USB on an RPi4 running Bullseye (Lite), with Python 3.9.2. The fastest baudrate I could get to initialise was 2823529, so I used that.

I ended up with

Angular Step Size [gradians] Distance [m] Sample Period [ticks] Transmit Duration [us] Python Serial avg. time [s] Python Ethernet avg. time [s] Serial slower by
1 2 88 11 13.85 11.80 17.38%
1 20 888 107 23.51 21.61 8.82%
1 50 2222 267 42.03 38.42 9.41%
10 2 88 11 3.57 3.29 8.72%
10 20 888 107 4.60 4.32 6.56%
10 50 2222 267 6.28 6.01 4.50%

Ethernet is definitely capable of going faster than serial, so likely there are setup differences. My ethernet setup was Ping360 → Ethernet Switch → Fathom-X → tether → Fathom-X → Ethernet-to-USB2 → computer running Python/Ping Viewer, so it’s possible there are slowdowns somewhere in there.

That said, my serial setup was Ping360 → RPi4 USB port, running Python, and it was on average 9.23% slower than the topside Python with the ethernet connection, so perhaps there was some other difference between our setups.

If it’s helpful/relevant, my testing code was basically

from brping import Ping360
from time import perf_counter

p = Ping360()
device = '/dev/ttyUSB0'

# determine highest working baudrate
b_min = 115_200
b_max = 3_000_000
step = (b_max - b_min) // 2
while step > 1:
    p.connect_serial(device, b_max)
    if p.initialize():
        # connection worked -> try a higher baudrate
        b_min = b_max
        b_max += step
        p.iodev.close() # disconnect again
    else:
        # connection failed -> try a lower baudrate
        b_max -= step
    step = round(step / 2)

print('highest working baudrate:', b_min)
p.connect_serial(device, b_min)
p.initialize()

def test(angles):
    start = perf_counter()
    for angle in angles:
        p.transmitAngle(angle)
    return perf_counter() - start

p.set_transmit_frequency(750)
p.set_number_of_samples(1200)

conditions = ((88, 11), (888, 107), (2222, 267))
for sample_period, transmit_duration in conditions:
    print(f'{sample_period=}, {transmit_duration=}')
    p.set_sample_period(sample_period)
    p.set_transmit_duration(transmit_duration)
    
    for step in (1, 10):
        print(f'{step = } gradians')
        results = [test(range(0, 400, step)) for _ in range(3)]
        print(results, sum(results) / 3)

My setup is really just Ping360 → USB3(2M) ->Ubuntu 20.04(Intel i9 CPU) with either Python3.8.10 or Ping-Viewer.
The code is very similar to mine, except the fancy baudrate finder.

Now after testing it with my RPI4, I come basically on the same numbers as you do.
This just shows again how “slow” the RPI4 i/o interface can be.
I will keep the numbers on my top post but add that it was done on a faster Computer.

The speed up with Ethernet can be an option for many, maybe this is even faster with the RPI4.

1 Like