Hi,
My goal is to send data stream from the RPi to the Pixhawk so that everything (flight log and external data) is saved to the sd card neatly in a file. For that, I created my own mavlink message definition I compiled for the RPi and Pixhawk. The RPi is running a Python script that collects the data, encodes the Mavlink message, and sends it through UART. I’m using custom pymavlink and mavutil for this.
Here is part of the RPi Python script code
from pymavlink import mavutil
mav_connection = mavutil.mavserial('/dev/serial0', baud=115200, source_system=1, source_component=191)
mav_connection.wait_heartbeat()
print("Heartbeat system: sysID %u compID %u" % (mav_connection.target_system, mav_connection.target_component)) # Output sysID 1 compID 0
mav_connection.mav.heartbeat_send(mavutil.mavlink.MAV_TYPE_ONBOARD_CONTROLLER, mavutil.mavlink.MAV_AUTOPILOT_INVALID, 0, 0, 0)
last_beat = time.time()
while(True):
if(time.time() - last_beat > 0.95):
mav_connection.mav.heartbeat_send(mavutil.mavlink.MAV_TYPE_ONBOARD_CONTROLLER, mavutil.mavlink.MAV_AUTOPILOT_INVALID, 0, 0, 0)
last_beat = time.time()
values = [fCenterFreq, fAmplitudeDBM, 0, 0, 0]
mav_connection.mav.sensor_raw_send(10,0,2,values,True)
I also modified the messagehandle function in ArduCopter to accept and process the external telemetry from the RPi. However, I cannot get the Pixhawk to see the custom messages. I even tried bypassing the mavlink routing within ArduCopter but the Pixhawk is not seeing it.
Here is part of what I modified in the handlemessage in GCS_Mavlink.cpp
void GCS_MAVLINK_Copter::handleMessage(const mavlink_message_t &msg)
{
.
.
.
switch (msg.msgid) {
// RFE message handle
case MAVLINK_MSG_ID_SENSOR_RAW:
{
// Recieve message from RPi and handle the RFE data
copter.MY_RFE.handle_message(chan, msg);
// Immediately save the data to the SD card
copter.user_RFE_logger();
break;
}
.
.
.
}
At this point, I’m unsure if the problem is with the sender or the receiver. So I hope anyone here can guide me on how to stream data to the Pixhawk. I searched for answers all around the forums and tutorials, but they mainly describe the reverse process (data streams from the Pixhawk out).
Thanks!