Hi,
After some attempts to write custom drivers for a sensor I am hoping to integrate, I have decided that the best way to use it is by having an Arduino read all the data and send that over serial to the Raspberry Pi.
I was wondering therefore how to get the data from Raspberry Pi to Qgroundcontrol. I understand that I should use NAMED_VALUE_FLOAT, but I was wondering where I should place the code.
You may read the sensor with the python serial module. Then you may send the value with the pymavlink module using the named_float_send function. This code needs to live on the Raspberry Pi.
Something like that, it looks like you have pulled some code out of ardupilot, which is written in c++, not python. I think the CHECK_PAYLOAD_SIZE macro does not exist in your python code.
Alright. One more question: I am getting this error:
Traceback (most recent call last):
File “send_sensors.py”, line 5, in
master = mavutil.mavlink_connection(‘udp:192.168.2.1:14550’)
File “/usr/local/lib/python2.7/dist-packages/pymavlink-2.2.4-py2.7-linux-armv7
l.egg/pymavlink/mavutil.py”, line 1221, in mavlink_connection
return mavudp(device[4:], input=input, source_system=source_system, source_c
omponent=source_component, use_native=use_native)
File “/usr/local/lib/python2.7/dist-packages/pymavlink-2.2.4-py2.7-linux-armv7
l.egg/pymavlink/mavutil.py”, line 880, in init
self.port.bind((a[0], int(a[1])))
File “/usr/lib/python2.7/socket.py”, line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 99] Cannot assign requested address
This seems to me as if I can not assign that as the address to send the message to, however that is the address for QGroundcontrol no? What is the problem?
Traceback (most recent call last):
File “send_sensors.py”, line 24, in
master.mav.send_named_float(“intTemp”, temp)
AttributeError: ‘MAVLink’ object has no attribute ‘send_named_float’
Do you know what the actual command I should use is?
Make sure you are using udpout:192.168.2.1:14550, and try sending a heartbeat message using sysid=2, compid=2, then it should show a heartbeat separately from the normal autopilot telemetry. (I know the widget will show heartbeats, maybe it will not show named_value_int).
You can use network tools like netcat or wireshark to verify that data is coming in on the expected port (maybe unplug the autopilot so that telemetry does not come through while you are working on it).