How to get the Ping360 sensor data

Hello, I am using the STM32F407 development board to get the data of ping360 sonar, but I know that sonar needs to send a request from the host before returning data, but I do not know the specific request instructions, could you provide a PDF file about the communication protocol ? I just know the Request protocol version command, but I want to continue to get the ping360 sensor data, but I had not found relevant command.So I had to ask for help.

Thank you very much !

Hi @Lin,

As per the Ping360 section of the Ping Protocol, you need to send transducer (2601) messages in order to receive device_data (2300) messages. There’s a proposed auto_transmit message that would allow requesting a scanned region between two angles, but it’s not included in the currently available Ping360 firmware.

If you haven’t already I would recommend taking a look at our ping-cpp library, including the Ping360 transducer example :slight_smile:

@EliotBR 非常感谢您的回答。但是我使用的是keil5 IDE开发,我使用的语言是C,ping-cpp库是否可以使用?

Ping-cpp is a C++ library. There are a few different ways to use C++ from C, including using a C++ compiler, or potentially using a dynamic linked library (which may require modifying the ping-cpp code). It’s not something I have a lot of experience with, but it is possible at least in theory.

As you said, I looked at the protocol for 2601 transducer, but it’s not a hexadecimal instruction, and I want to get data by sending a hex instruction to Ping360, for example, like the get version protocol, sending 0x42, 0x52, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0x05, 0x00, 0xa1, 0x00

I find it easiest to interrogate and play by using an interactive Python terminal together with our ping-python library. In this case to find the hex values you’re after you could do something like

>>> from brping import pingmessage, definitions
>>> m = pingmessage.PingMessage(definitions.PING360_TRANSDUCER)
>>> m.gain_setting = 0
>>> m.angle = 50
>>> m.transmit_duration = 11
>>> m.sample_period = 88
>>> m.transmit_frequency = 750
>>> m.number_of_samples = 400
>>> m.transmit = 1
>>> m.pack_msg_data()
bytearray(b'BR\x0e\x00)\n\x00\x00\x00\x002\x00\x0b\x00X\x00\xee\x02\x90\x01\x01\x00\xec\x02')
>>> m


--------------------------------------------------
ID: 2601 - transducer
Header: start_1: 66 start_2: 82 payload_length: 14 message_id: 2601 src_device_id: 0 dst_device_id: 0
Payload:
  - mode: 0
  - gain_setting: 0
  - angle: 50
  - transmit_duration: 11
  - sample_period: 88
  - transmit_frequency: 750
  - number_of_samples: 400
  - transmit: 1
  - reserved: 0
Checksum: 748 check: 748 pass: True
>>> print(*map(hex, m.msg_data))
0x42 0x52 0xe 0x0 0x29 0xa 0x0 0x0 0x0 0x0 0x32 0x0 0xb 0x0 0x58 0x0 0xee 0x2 0x90 0x1 0x1 0x0 0xec 0x2

which used the ping360 control example as a reference, and some of the default values from Ping Viewer for a 2m scan range (but with 400 samples, instead of the 1200 Ping Viewer uses).

1 Like

I’m really sorry to bother you again. I would like to ask whether you have the sonar underwater detection data set. I would like to conduct the analysis of sonar image processing

The forum is here for people to discuss marine robotics, so no need to apologise :slight_smile:

I’m not certain what you’re asking for here. @btrue has graciously shared some data from his dives here, which may be of interest, but if you’re after a dataset that includes object labels and positioning information or something then I’m not aware of any.

I am also using stm32 for development, but I have no response to send commands to Ping360 :worried:, can you please show me the code you use to send commands to Ping360?

According to the method you provided, I successfully read the sonar data. But if I want to change the scan range to 2m, how can I modify the parameters?

Hi @raccoon, welcome to the forum :slight_smile:

The Ping360 doesn’t provide a direct method for setting the scan range - you’ll need to do the relevant calculations within your code.

This thread was about that process, and should cover the relevant details. Feel free to follow up after going through that if some aspects aren’t clear :slight_smile:

After reading posts, I directly adjusted the values of “sample_period” and “number_of_samples” based on the actual working conditions to change the scanning range. By using a while loop to read data from 0 to 360 degrees, I found that it takes 6-7 minutes to complete the reading, which is much longer than the time Ping Viewer software takes to scan a full circle. I am analyzing whether the software uses the auto_transmit command protocol.

There’s some discussion on Python scanning speeds here, but it should definitely be much faster than that unless you’re either setting a variable incorrectly (e.g. if your scale is off by an order of magnitude or something), or having communication issues that mean several of your requests are timing out.

Have you checked whether you’re actually getting meaningful data from your requests?

Ping360’s auto_* functionality is not yet meaningfully publicly available, so if you’re trying to make use of it then you’re likely just getting a bunch of timeouts.

Ping Viewer is able to make use of it if the device supports it, but it’s highly unlikely your Ping360 has a supporting firmware installed, because we haven’t yet provided a Ping Viewer release that allows flashing on a new firmware.

Thank you for your reply; it has been very helpful to me. I would also like to ask whether the Ping Viewer software has the functionality to retain historical scan data. If so, where can this data be accessed? We hope to integrate it into a sonar-equipped robotic system for display, and we plan to use historical data for testing first. Once again, thank you for your help.