@@ -2398,6 +2398,125 @@ def reboot(self):
23982398
23992399 self .send_mavlink (reboot_msg )
24002400
2401+ def calibrate_gyro (self ):
2402+ """Request gyroscope calibration."""
2403+
2404+ calibration_command = self .message_factory .command_long_encode (
2405+ 0 , 0 , # target_system, target_component
2406+ mavutil .mavlink .MAV_CMD_PREFLIGHT_CALIBRATION , # command
2407+ 0 , # confirmation
2408+ 1 , # param 1, 1: gyro calibration, 3: gyro temperature calibration
2409+ 0 , # param 2, 1: magnetometer calibration
2410+ 0 , # param 3, 1: ground pressure calibration
2411+ 0 , # param 4, 1: radio RC calibration, 2: RC trim calibration
2412+ 0 , # param 5, 1: accelerometer calibration, 2: board level calibration, 3: accelerometer temperature calibration, 4: simple accelerometer calibration
2413+ 0 , # param 6, 2: airspeed calibration
2414+ 0 , # param 7, 1: ESC calibration, 3: barometer temperature calibration
2415+ )
2416+ self .send_mavlink (calibration_command )
2417+
2418+ def calibrate_magnetometer (self ):
2419+ """Request magnetometer calibration."""
2420+
2421+ # APM requires the MAV_CMD_DO_START_MAG_CAL command, only present in the APM MAVLink dialect
2422+ if self ._autopilot_type == mavutil .mavlink .MAV_AUTOPILOT_ARDUPILOTMEGA :
2423+ calibration_command = self .message_factory .command_long_encode (
2424+ 0 , 0 , # target_system, target_component
2425+ mavutil .mavlink .MAV_CMD_DO_START_MAG_CAL , # command
2426+ 0 , # confirmation
2427+ 0 , # param 1, uint8_t bitmask of magnetometers (0 means all).
2428+ 1 , # param 2, Automatically retry on failure (0=no retry, 1=retry).
2429+ 1 , # param 3, Save without user input (0=require input, 1=autosave).
2430+ 0 , # param 4, Delay (seconds).
2431+ 1 , # param 5, Autoreboot (0=user reboot, 1=autoreboot).
2432+ 0 , # param 6, Empty.
2433+ 0 , # param 7, Empty.
2434+ )
2435+ else :
2436+ calibration_command = self .message_factory .command_long_encode (
2437+ 0 , 0 , # target_system, target_component
2438+ mavutil .mavlink .MAV_CMD_PREFLIGHT_CALIBRATION , # command
2439+ 0 , # confirmation
2440+ 0 , # param 1, 1: gyro calibration, 3: gyro temperature calibration
2441+ 1 , # param 2, 1: magnetometer calibration
2442+ 0 , # param 3, 1: ground pressure calibration
2443+ 0 , # param 4, 1: radio RC calibration, 2: RC trim calibration
2444+ 0 , # param 5, 1: accelerometer calibration, 2: board level calibration, 3: accelerometer temperature calibration, 4: simple accelerometer calibration
2445+ 0 , # param 6, 2: airspeed calibration
2446+ 0 , # param 7, 1: ESC calibration, 3: barometer temperature calibration
2447+ )
2448+
2449+ self ._logger .critical (calibration_command )
2450+ self .send_mavlink (calibration_command )
2451+
2452+ def calibrate_accelerometer (self ):
2453+ """Request accelerometer calibration."""
2454+
2455+ calibration_command = self .message_factory .command_long_encode (
2456+ 0 , 0 , # target_system, target_component
2457+ mavutil .mavlink .MAV_CMD_PREFLIGHT_CALIBRATION , # command
2458+ 0 , # confirmation
2459+ 0 , # param 1, 1: gyro calibration, 3: gyro temperature calibration
2460+ 0 , # param 2, 1: magnetometer calibration
2461+ 0 , # param 3, 1: ground pressure calibration
2462+ 0 , # param 4, 1: radio RC calibration, 2: RC trim calibration
2463+ 1 , # param 5, 1: accelerometer calibration, 2: board level calibration, 3: accelerometer temperature calibration, 4: simple accelerometer calibration
2464+ 0 , # param 6, 2: airspeed calibration
2465+ 0 , # param 7, 1: ESC calibration, 3: barometer temperature calibration
2466+ )
2467+ self .send_mavlink (calibration_command )
2468+
2469+ def calibrate_accelerometer_simple (self ):
2470+ """Request simple accelerometer calibration."""
2471+
2472+ calibration_command = self .message_factory .command_long_encode (
2473+ 0 , 0 , # target_system, target_component
2474+ mavutil .mavlink .MAV_CMD_PREFLIGHT_CALIBRATION , # command
2475+ 0 , # confirmation
2476+ 0 , # param 1, 1: gyro calibration, 3: gyro temperature calibration
2477+ 0 , # param 2, 1: magnetometer calibration
2478+ 0 , # param 3, 1: ground pressure calibration
2479+ 0 , # param 4, 1: radio RC calibration, 2: RC trim calibration
2480+ 4 , # param 5, 1: accelerometer calibration, 2: board level calibration, 3: accelerometer temperature calibration, 4: simple accelerometer calibration
2481+ 0 , # param 6, 2: airspeed calibration
2482+ 0 , # param 7, 1: ESC calibration, 3: barometer temperature calibration
2483+ )
2484+ self .send_mavlink (calibration_command )
2485+
2486+ def calibrate_board_level (self ):
2487+ """Request board level calibration."""
2488+
2489+ calibration_command = self .message_factory .command_long_encode (
2490+ 0 , 0 , # target_system, target_component
2491+ mavutil .mavlink .MAV_CMD_PREFLIGHT_CALIBRATION , # command
2492+ 0 , # confirmation
2493+ 0 , # param 1, 1: gyro calibration, 3: gyro temperature calibration
2494+ 0 , # param 2, 1: magnetometer calibration
2495+ 0 , # param 3, 1: ground pressure calibration
2496+ 0 , # param 4, 1: radio RC calibration, 2: RC trim calibration
2497+ 2 , # param 5, 1: accelerometer calibration, 2: board level calibration, 3: accelerometer temperature calibration, 4: simple accelerometer calibration
2498+ 0 , # param 6, 2: airspeed calibration
2499+ 0 , # param 7, 1: ESC calibration, 3: barometer temperature calibration
2500+ )
2501+ self .send_mavlink (calibration_command )
2502+
2503+ def calibrate_barometer (self ):
2504+ """Request barometer calibration."""
2505+
2506+ calibration_command = self .message_factory .command_long_encode (
2507+ 0 , 0 , # target_system, target_component
2508+ mavutil .mavlink .MAV_CMD_PREFLIGHT_CALIBRATION , # command
2509+ 0 , # confirmation
2510+ 0 , # param 1, 1: gyro calibration, 3: gyro temperature calibration
2511+ 0 , # param 2, 1: magnetometer calibration
2512+ 1 , # param 3, 1: ground pressure calibration
2513+ 0 , # param 4, 1: radio RC calibration, 2: RC trim calibration
2514+ 0 , # param 5, 1: accelerometer calibration, 2: board level calibration, 3: accelerometer temperature calibration, 4: simple accelerometer calibration
2515+ 0 , # param 6, 2: airspeed calibration
2516+ 0 , # param 7, 1: ESC calibration, 3: barometer temperature calibration
2517+ )
2518+ self .send_mavlink (calibration_command )
2519+
24012520
24022521class Gimbal (object ):
24032522 """
0 commit comments