Pre-arm check list

I am trying to get the pre-arm check list status using pymavlink. Actually when I am trying to arm my drone using Mission Planner, it arm perfectly fine, but when I am using pymavlink, it failed to arm. So I need to see pre arm check list status.

    def turn_on_motor(self):
        # arm the motors
        self.vehicle.arducopter_arm()
        ack = self.vehicle.recv_match(type='COMMAND_ACK', blocking=True, timeout=10)
        if ack and ack.command == 400 and ack.result == 0:
            print("Turning on Motors")
        else:
            print("Failed to turn on Motors")

the same function, I tested om SITL, it works, not sure why it is not working when I am testing on actual hardware.

Maybe you can write a method which listen for the STATUSTEXT messages and print them out to give you clues as to why it does not want to arm.
These are the messages displayed in the Messages tab of MP.

I rerun the code, and I was able to arm the motors when the flight mode was in stabilize, but when the flight mode is in guided mode, it doesn’t arm, however I checked the gps signals, it was also giving me the expected values. What am I doing wrong? Or if the guided mode is only used when a companion computer is connected with the flight control?

No, the problem is that you need more than a GNSS signal. You need a good quality, stable and periodic GNSS signal, and until you get that you will not be able to arm in guided.

ok thanks, I will try fly drone in an open environment so I can get enough GNSS signals.

is there anyway where I can set all the parameters values using a file, currently I am using the following code, it works correctly when I am trying to set one parameter value at a time, but when I am setting the values from a file, I am having issue on parameter type.

    def get_parameter_value(self, parameter_name):
        parameter_type = None
        # Request the parameter value
        self.vehicle.mav.param_request_read_send(
            self.vehicle.target_system, self.vehicle.target_component,
            parameter_name.encode('utf-8'),
            -1  # Request the value of all instances (use 0 for specific index)
        )
        message = self.vehicle.recv_match(type='PARAM_VALUE', blocking=True).to_dict()
        print(message)
        return message['param_value'], message['param_type']


    def set_parameter_value(self, param_id, param_value):
        # get parameter type first
        _, param_type = self.get_parameter_value(param_id)
        time.sleep(0.1)
        # To set ardu-pilot parameters
        self.vehicle.mav.param_set_send(
            self.vehicle.target_system,
            self.vehicle.target_component,
            param_id.encode('utf-8'),
            param_value,
            param_type
        )
        # Optionally wait for ACK (PARAM_VALUE message) to confirm parameter was set
        ack_msg = self.vehicle.recv_match(type='PARAM_VALUE', blocking=True)
        print(ack_msg)

    def load_all_parameters(self, file_path):
        with open(file_path, 'r') as f:
            lines = f.readlines()
            for line in lines:
                param_name, param_value = line.strip().split(',')
                if '.' in param_value:
                    param_value = float(param_value)
                    self.set_parameter_value(param_name, param_value)
                else:
                    param_value = int(param_value)
                    self.set_parameter_value(param_name, param_value)

This is my param file.
crsf_params.param (16.5 KB)

Sure, here it is: MethodicConfigurator/MethodicConfigurator/backend_flightcontroller.py at master · ArduPilot/MethodicConfigurator · GitHub look at the __download_params_via_mavlink() and set_param() methods.

All parameters are floats remove the else.