To allow the companion computer to control my drone ( hex x multirotor) overriding the remote control, I tried the method as below. However, I find it only worked while turn the autopilot on without turning the remote control on. If I run the code and turn the remote control on, I find that the remote control doesn’t work (the QGC still shows the channel as set in the code) even after I cancel running the code. If I open the remote control first and then run the code next, the code cannot override the channel 6 as expected.
So what could possibly be the reason? What else information should I provide? Thank you!
Note: the sending result was always Success during test
Frame info:
the PX4 version is 1.14.0
the frame is Generic Hexarotor x geometry
The autopilot is Holybro Pixhawk 6X
code:
void send_rc_override(MavlinkPassthrough& mavlink_passthrough) {
MavlinkPassthrough::Result result = mavlink_passthrough.queue_message([&](MavlinkAddress
                                                                       mavlink_address,
                                                                   uint8_t channel) {
    mavlink_message_t message;
    std::cout << "mavlink_address.system_id = " << mavlink_address.system_id
              << ", component_id = " << mavlink_address.component_id << "channel = " << channel
              << "\n";
    unsigned chan_6 = 1900;
    mavlink_msg_rc_channels_override_pack(
        // mavlink_address.system_id,
        245,
        // mavlink_address.component_id,
        1,
        // channel,
        &message,
        0, // target system id 
        0, // target component id 
        UINT16_MAX, // chan1_raw
        UINT16_MAX, // chan2_raw
        UINT16_MAX, // chan3_raw
        UINT16_MAX, // chan4_raw
        UINT16_MAX, // chan5_raw
        chan_6, // chan6_raw (test)
        UINT16_MAX, // chan7_raw
        UINT16_MAX, // chan8_raw
        UINT16_MAX, // chan9_raw
        UINT16_MAX, // chan10_raw
        UINT16_MAX, // chan11_raw
        UINT16_MAX, // chan12_raw
        UINT16_MAX, // chan13_raw
        UINT16_MAX, // chan14_raw
        UINT16_MAX, // chan15_raw
        UINT16_MAX, // chan16_raw
        UINT16_MAX, // chan17_raw
        UINT16_MAX); // chan18_raw
    return message;
});
std::cout << "the sending result is: " << result << "\n";
}