Hello,
We are trying to use the Ping360 sonar device on our Linux system through the serial port /dev/ttyUSB0. We cloned the Python library from GitHub - bluerobotics/ping-python: Python scripts and examples for the Ping sonar. . We run the following code, but we are not receiving any data.
Python Code Used:
from brping import Ping360
import time
def main():
device = "/dev/ttyUSB0"
baud = 115200
print(f"Connecting to {device}...")
p = Ping360()
p.connect_serial(device, baud)
if not p.initialize():
print("INITIALIZATION FAILED! (Permission or connection error)")
return
else:
print("Device Connected and Initialized!")
_mode = 1
_gain = 0
_transmit_duration = 32
_sample_period = 80
_transmit_frequency = 740
_number_of_samples = 200
_start_bin = 0
_full_data_length = 200
meters_per_sample = 1500 * (_sample_period * 25e-9) / 2
print(f"Distance Resolution: {meters_per_sample:.4f} meters")
print("STARTING SCAN")
try:
while True:
for angle in range(0, 400, 2):
response = p.control_transducer(
_mode,
_gain,
angle,
_transmit_duration,
_sample_period,
_transmit_frequency,
_number_of_samples,
_start_bin,
_full_data_length
)
if response:
data = list(response.data)
threshold = 150
max_val = 0
max_idx = 0
for i, val in enumerate(data):
if val > threshold and val > max_val:
max_val = val
max_idx = i
if max_val > 0:
distance = max_idx * meters_per_sample
print(f"Angle: {angle:03d} ---> OBSTACLE: {distance:.2f}m (Strength: {max_val})")
time.sleep(0.002)
except KeyboardInterrupt:
print("\nStopped.")
if __name__ == "__main__":
main()
Code Behavior:
- We successfully connect to /dev/ttyUSB0.
- The initialize() function succeeds.
- The scan starts, but no “OBSTACLE” or distance output appears.
Console output:
Connecting to /dev/ttyUSB0...
Opening /dev/ttyUSB0 at 115200 bps
Device Connected and Initialized!
Distance Resolution: 0.0015 meters
STARTING SCAN
We also tested examples/ping360AutoScan.py, but also get no data.
Device is currently being tested in air, not underwater.
Our Questions:
- Does the Ping360 only produce meaningful distance data underwater?
Is air testing unreliable or impossible? - Could the lack of data in our Python script be caused by operating the device in air?
- How can we confirm in PingView whether we are receiving real sonar data?
Which indicators or graphs show actual raw or processed returns? - What starting parameter values do you recommend
(gain, transmit_duration, sample_period, number_of_samples, etc.)? - Do you see any issues or improvements needed in the Python code above?
- We noticed that most users on the BlueRobotics forum use UDP or Ethernet instead of serial.
What are the advantages of UDP/Ethernet for Ping360?
Is /dev/ttyUSB0 still recommended?
What are the limitations of serial communication? - How can we view raw sample data (raw intensities) in PingView?
Does PingView show raw or processed images?
Is there any debug mode for raw samples?
If not, what is the recommended way to inspect raw data?
Our main goal is to obtain distance measurements from the Ping360 for obstacle detection and navigation. We want to learn the most reliable and practical method for reading distance data using Python and determine whether serial, UDP, or Ethernet is preferred.
Thank you for your support.
