Unable to set Home Point via companion computer in GUIDED_NOGPS mode and Take Off

Greetings, friends. I’ve been reading discussions on this forum for a week, and it seems I’ve done everything I could, but I can’t solve the problem. I’m hoping for your help.

In the following code, I change the flight mode to GUIDED_NOGPS (successfully), arm the drone (successfully), and try to set the home point (unsuccessfully). I tried to execute the take_off command without a home point, but the command also fails to execute.

The drone is equipped with optical flow and a rangefinder. The settings, it seems, are correct.

    master = mavutil.mavlink_connection(connection_string)
    master.wait_heartbeat()
    
    print("Going to GUIDED_NOGPS")
    
    master.mav.command_long_send(
        master.target_system,
        master.target_component,
        mavutil.mavlink.MAV_CMD_DO_SET_MODE,
        0,  # confirmation
        1,  # CUSTOM_MODE_ENABLED=1
        20,  # mode. FLOWHOLD=22; GUIDED_NOGPS=20
        0, 0, 0, 0, 0  # (not used)
    )
    
    while True:
        ack_msg = master.recv_match(type='COMMAND_ACK', blocking=True, timeout=1)
        print(ack_msg)
        if ack_msg is not None:
            if ack_msg.command == 176 and ack_msg.result == 0: break
        time.sleep(1)
    
    time.sleep(2)
    
    print("Checking flight mode")
    
    status_msg = master.recv_match(type='HEARTBEAT', blocking=True, timeout=5)
    if status_msg is not None:
        flight_mode = master.flightmode
        print(f"Mode: {flight_mode}")
    time.sleep(2)

Print:

Going to GUIDED_NOGPS
COMMAND_ACK {command : 176, result : 0, progress : 0, result_param2 : 0, target_system : 255, target_component : 0}
Checking flight mode
Mode: GUIDED_NOGPS

Next:

    print("Going to arm")
    master.mav.command_long_send(
        master.target_system,
        master.target_component,
        mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM,
        0,  # confirmation
        1,  # param1 (1 to arm, 0 to disarm)
        0, 0, 0, 0, 0, 0  # params 2-7 (not used)
    )

    while True:
        ack_msg = master.recv_match(type='COMMAND_ACK', blocking=True)
        print(ack_msg)
        if ack_msg is not None:
            if ack_msg.command == 400 and ack_msg.result == 0: break
            print("ARM. Command=", ack_msg.command, "; result=", ack_msg.result)
        time.sleep(0.5)

    print("Going to set home point")
    master.mav.command_long_send(
        master.target_system,
        master.target_component,
        mavutil.mavlink.MAV_CMD_DO_SET_HOME,
        0, 0, 0, 0, 0,
        55.135,
        61.155,
        190  # height above sea m 
    )
    time.sleep(5)
    while True:
        ack_msg = master.recv_match(type='COMMAND_ACK', blocking=True)
        print(ack_msg)
        if ack_msg is not None:
            print("Set home. Command=", ack_msg.command, "; result=", ack_msg.result)
            break
        time.sleep(0.5)
    
    time.sleep(5)
    print("Going to Fly")

    master.mav.command_long_send(
        master.target_system,
        master.target_component,
        mavutil.mavlink.MAV_CMD_NAV_TAKEOFF,
        0,  # Pitch Angle
        0, 0, 0, 0, 0, 0,
        1  # Alt
    )
    
    while True:
        ack_msg = master.recv_match(type='COMMAND_ACK', blocking=True)
        print(ack_msg)
        if ack_msg is not None:
            if ack_msg.command == 22 and ack_msg.result == 0: break
            print("Take off. Command=", ack_msg.command, "; result=", ack_msg.result)
        time.sleep(0.5)

Print:

Going to arm
COMMAND_ACK {command : 400, result : 0, progress : 0, result_param2 : 0, target_system : 255, target_component : 0}
Going to set home point
COMMAND_ACK {command : 179, result : 4, progress : 0, result_param2 : 0, target_system : 255, target_component : 0}
Set home. Command= 179 ; result= 4
Going to Fly
COMMAND_ACK {command : 22, result : 4, progress : 0, result_param2 : 0, target_system : 255, target_component : 0}
Take off. Command= 22 ; result= 4

if I change mode to GUIDED so I unable to ARM and the same problem with home point:

Set home. Command= 179 ; result= 4
ARM. Command= 400 ; result= 4

Log:

There are no ERR messages in the log.

Flight controller: CUAV Nora+
Computer: Raspberry
Firmware 4.4.4
No GPS installed

Here is my update. I tried a suggestion from the forum to override throttle channel before send take_off command. It doesn’t work. But, I realised all I was needed in my case is pymavlink “rc_channels_override_send”.

May be it will help you. One thing I was found, that if you’re send “rc_channels_override_send” once you want to change some channel signal it works unstable. Sometimes the command works, sometimes not. The only way to have good control is to use rc_channels_override_send constantly. In may case, 2 times a second. I constantly send all 4 channels, even if they don’t change. It gave me stable and smooth control.

Have you look into this parameter? It helped in my case.