I would like to try and access the the raw Ping data in Python on the Raspberry PI.
I am looking for (I assume) an array of { x,y, value }. How is that best achieved? I see there are some likely functions in the device API guide but wanted to confirm.
Initially I would like to see if I can replicate Ping Viewer at the source (ROV) rather than the client PC. Beside less versions of the application software to support for me it could provide a more seamless and consistent user experience. You could also have the ability to integrate with all other available sensor data at source. See:
(The mobile phone is the lowest common denominator. Besides being convenient, it ensures suitable performance is built in. If it works there, it will work on larger devices and tablets)
Moving forward as you look towards autonomous operation, automatic obstacle avoidance, and potentially a stitched array of ping devices providing a wider arc of view, I believe most of the smart processing will occur real-time at the ROV end which is where I am thinking I should focus some time?
I am also thinking about clustering some Raspberry PI devices in the 4" enclosure to provide dedicated compute resource if neededâŠ
I was hoping to get a slightly longer introduction to the those two functions as I think the doco is a bit brief on background explanation and that appears to be where most of the core data collection occurs?
I have the following sample code returning an error with the get_profile function:
#!/usr/bin/env python
#echoprofile.py
from brping import Ping1D
#Make a new Ping
myPing = Ping1D("/dev/ttyUSB0" , 115200)
if myPing.initialize() is False:
print("Failed to initialize Ping!")
exit(1)
# set speed of sound in water
myPing.set_speed_of_sound(1450000)
# Read some sample Ping data successfully
distancedata = myPing.get_distance()
print (distancedata["distance"])
print (myPing.get_device_id())
print (myPing.get_firmware_version())
print (myPing.get_general_info())
print (myPing.get_pcb_temperature())
print (myPing.get_processor_temperature())
# Read some sample Ping Profile data unsuccessfully
profiledata = myPing.get_profile()
The above errors with the message: AttributeError: âPingMessageâ object has no attribute âpayload_field_namesâ
I see that get_profile() is returning an array within an array? Do I need to declare a special data type such as pingmessage.PING1D_PROFILE to remove the error?
Also just an FYI, there are some broken links on this page
You can see it in the output. It is in data["profile_data"]. 'profile_data': "\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd'0\x08\x00\x01\x01\x08\x01\x00\x01\x00\x02\x04\x03\x06\x08\x10\x03\x00\x01\x00\x00\x00\x00\x03\x01\x01\x01\x03\n\x03\x03\x01\x00\x03\x08\x03\x03\x00\x00\x00\x02\x02\x05\x00\x00\x00\x00\x01\x05\x01\x04\x04\x06\x06\x00\x00\x00\x00\x01\x00\x02\x02\x02\x02\x00\x00\x02\x03\x00\x00\x00\x00\x00\x03\x04\x03\x00\x00\x00\x00\x03\x02\x05\x04\x04\x04\x00\x01\x00\x00\x00\x00\x00\x00\x03\x03\x03\x01\x00\x00\x00\x00\x00\x00\x00\x03\x05\x04\x02\x00\x00\x01\x02\x0b\x0c\x04\x07\r+?5.\x16\t\x02\x07\x01\x01\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x00\x00\x04\x02\x03\x05\x00\x00\x01\x01\x00\x00\x03\x02\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00.\xfd8\x00"
I am new using the ping sonar, I follow the instructions from the link: GitHub - bluerobotics/ping-python: Python scripts and examples for the Ping sonar.. However I was not able to run simplePingExample.py. Actually, I included in the bash profile the path that is suggested in the link above. However I am getting the following error
Traceback (most recent call last):
File âsimplePingExample.pyâ, line 5, in
from brping import Ping1D
File âbuild/bdist.linux-x86_64/egg/brping/init.pyâ, line 2, in
ImportError: No module named definitions
I am also new in python, checking online I figure out that probably python is not recognizing import Ping1D
Any suggestion, I would appreciate your help. Thanks in advance
did you follow our instructions ?
You should install it via pip and from that use the quick start guide.
I just tested it in a fresh OS (ubuntu 18.04) and itâs working.
I could manage to run the example, however to use the USB in Linux 16.04, I had to install the version 0.0.8 or lower. So Definitely, the latest version can not installed in Linux 16.04. And I had to include the following line to use the USB port
sudo chmod 666 /dev/ttyUSB*
Thank you so much for your help. It really worked!