Flight mode change not taking - w\ onboard commands

Hi, I am using a Herelink paired with a Pixhawk cube which runs a serial connection (telem2) to a onboard computer + camera. The onboard computer calculates and sends (velocity body) commands to the flight controller (using dronekit-python) based on the images it sees.

I am finding that when I try to change flight mode on my controller, it gets completely ignored (most of the time) by the drone. This only happens while my onboard computer is sending commands.
I am guessing it is because my commands sent via serial are blocking the serial line? ie spamming the flight controller so it can’t receive anything else.

Is there a reasonable/safe rate I can send commands to the flight controller without flight mode changes being ignored? I am currently doing it about 20 frames a second (my frame rate).

I posted here because I figured this is to do with the Arducopter stack and not necessarily the Pixhawk.

If you companion computer is sending “change to GUIDED mode” constantly, then all change mode commands send via serial telemetry are obviouly ignored.

Share your code so that we can take a look.

No I am not constantly sending mode changes from within my code. Using the stripped down version of my code (below), ie just sending velocity body commands with no other functionality, the problem remains.

def send_commands(x,y,z):
    msg = self.vehicle.message_factory.set_position_target_local_ned_encode(
                0,  # time_boot_ms (not used)
                0, 0,  # target system, target component
                # frame ... MAV_FRAME_LOCAL_NED usually used but its local to home
                0b0000111111000111,  # type_mask (only speeds enabled)
                0, 0, 0,  # x, y, z positions (not used)
                self.command_x, self.command_y, self.command_z,  # x, y, z velocity in m/s
                0, 0, 0,  # x, y, z acceleration (not supported yet, ignored in GCS_Mavlink)
                0, 0)  # yaw, yaw_rate (not supported yet, ignored in GCS_Mavlink)


while True:
    # Runs at around 20 iterations / second

    image = read_image()
    x, y, z = calc_commands(image)


My question is about a safe rate I can send commands to the flight controller at without potentially squashing other commands from rc.

For anyone in the future coming across this;

This is nothing to do with Ardupilot nor Pixhawk.

I was using a herelink controller, which apparently also uses dronekit/pymavlink/something to talk to the flight controller in some instances. This means that it connects using the same system source as what my code tries to use (the default is 255), so my connection and the herelink connection were arguing/fighting with each other over who gets to talk to the flight controller. Changed source_system=1 when I connect and it worked out.

Should of read the docs …

What parameter did you change and to what? Also was it as paremeter within mission planner or in your code? Im having the same mode switching issue but the cause is I updated a pixhawk 1 from px4 to ardupilot and now my modes will not switch even though the pwm’s and switches are set up correctly.


But I find it not convincing that this is the solution in youre case.

I changed it within my code, dronekit makes it very easy to change the source id my companion computer uses. My issue was that both my companion computer and the Herelink were fighting over the same id, your issue seems slightly different. As a place to start I think that you can change the id that the herelink uses in its settings? I can’t remember where but it is defaulted to 255 fairly sure.

Maybe read up on mavlink routing to make sure you haven’t made a mistake somewhere