bluerobotics / bluerobotics/ping-python

set sound speed

Abierto
#169 2 comentarios 0 reacciones 1 asignado Reclamado por @RaulTrombin Ver en GitHub
Lenguaje dominante
Python
Estrellas
60
Forks
39
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Hi

i try to set the speed of the sound but it's not working.

```
from brping import Ping1D

# ---------- Configuration ----------
PORT = "/dev/serial0"
BAUDRATE = 115200
SOUND_SPEED_MS = 1447 # à adapter à ton milieu

# -----------------------------------

# Timestamp à l'initialisation
start_time = datetime.now()
FILENAME = f"ping_depth_{start_time.strftime('%Y%m%d_%H%M%S')}.csv"

myPing = Ping1D()
myPing.connect_serial(PORT, BAUDRATE)
rg = myPing.get_profile()
print(f"get_profile: {rg}")

# Conversion en mm/s pour Ping1D
SOUND_SPEED_MM_S = 1450000 # exemple

ok = myPing.set_speed_of_sound(SOUND_SPEED_MM_S)
print(ok)

res = myPing.get_speed_of_sound()
print(res)
```

when i run my code I receive this issue
```
styx4d@Echosondeur:~/Documents $ python Pind1D_only.py
Opening /dev/serial0 at 115200 bps
get_profile: {'distance': 4449, 'confidence': 0, 'transmit_duration': 191, 'ping_number': 45983, 'scan_start': 0, 'scan_length': 6782, 'gain_setting': 6, 'profile_data': b'\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfdH\x0f,\x90w%\x05\x15@-\x12\x02\x03\x06\x07\t\x06\x02\x01\x02\x00\x00\x01\x03\x04\x01\x00\x01\x00\x00\x00\x00\x01\x01\x00\x00\x03\x06\x06\x01\x01\x00\x00\x00\x00\x00\x01\x05\x03\x00\x00\x00\x00\x01\x00\x00\x00\x01\x01\x00\x00\x01\x04\x00\x00\x00\x01\x02\x00\x02\x01\x00\x00\x00\x00\x03\x06\x08\x07\t\x04\x03\x01\x00\x00\x00\x01\x02\x03\t\n\x10\x0b\x03\x02\x00\x00\x03\x04\x01\x01\x00\x00\x03\x04\x04\x05\x01\x00\x00\x00\x02\x05\x07\x04\x03\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00%\x00\x00\x00\x00\x1f\xffu\x8a\x906\x1e`\x19\x00fF\x17\x00\x1b+\x1f"\x00..~\xed\xfd\x02g\x14\x00(g^P&QN '}
Traceback (most recent call last):
File "/home/styx4d/Documents/Pind1D_only.py", line 26, in
ok = myPing.set_speed_of_sound(SOUND_SPEED_MM_S)
File "/home/styx4d/.local/lib/python3.13/site-packages/bluerobotics_ping-0.2.3-py3.13.egg/brping/ping1d.py", line 520, in set_speed_of_sound
and (self._speed_of_sound != speed_of_sound)):
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Ping1D' object has no attribute '_speed_of_sound'. Did you mean: 'get_speed_of_sound'?
```

Thanks for your help

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.