Fly using mavlink with no gps

We are trying to fly indoors so we don’t need the GPS
We are able to arm the drone and get the motors spinning but the mavlink takeoff command always fails. (fail code is 4)

 #ARM
            self.Arm_mas.mav.command_long_send(
                    self.Arm_mas.target_system,  # target_system
                    self.Arm_mas.target_component,
                    mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM, # command
                    0, # confirmation
                    1, # param1 (1 to indicate arm)
                    0, # param2 0 to arm/disarm unless prevented by saftey checks 21196 to force arming/disarming
                    0, # param3 all other params meaningless)
                    0, # param4
                    0, # param5
                    0, # param6
                    0) # param7
            mesg = self.Arm_mas.recv_match(type='COMMAND_ACK', blocking= True)
            print(mesg)

#take off
def TakeOff(self):
        
        master = self.Arm_mas
        
        msg =  master.wait_heartbeat()
        print(msg)
        
        master.mav.command_long_send(
                master.target_system,  # target_system
                master.target_component,
                mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, # command
                0, # confirmation
                0, # param1 Pitch(deg)
                0, # param2 empty
                0, # param3 empty
                0, # param4 Yaw angle(deg)
                0, # param5 Latitude
                0, # param6 Longitude
                1) # param7 Altitude(m)
        mesg = master.recv_match(type='COMMAND_ACK', blocking= True)
        print(mesg)

You need to use the GUIDED_NOGPS flight mode and you need to explicitly set the home location first. Did you read the documentation?

We do change the flight mode to GUIDED_NOGPS in the code below

#Change Flight mode 
            self.Arm_mas.mav.command_long_send(
                    self.Arm_mas.target_system,  # target_system
                    self.Arm_mas.target_component,
                    mavutil.mavlink.MAV_CMD_DO_SET_MODE, # command
                    0, # confirmation
                    193, # param1 
                    5, # param2 
                    20, # param3 
                    0, # param4
                    0, # param5
                    0, # param6
                    0) # param7
            
            
            mesg = self.Arm_mas.recv_match(type='COMMAND_ACK', blocking= True)
            print(mesg)
            

However, when I asked about it on a different question I got this answer “There is no implementation of takeoff in guided_nogps”

So I am not sure what to do. And which documentation specifically are you talking about?

This is the documentation:
https://ardupilot.org/copter/docs/common-non-gps-navigation-landing-page.html

Ok thanks, how do we set the home location?