How to control the servo connected to AUX1 port using MAV_CMD_DO_SET_SERVO?

A servo is connected to AUX1 port and the function is set as servo 1 in QGC. Now when I use the below code using pymavlink to control the servo it is not moving.

import time
from pymavlink import mavutil

# Set the connection parameters (adjust accordingly)
connection_string = 'udp:localhost:14445'  # Replace with the appropriate connection string (e.g., serial port, UDP address)

# Create the MAVLink connection
mav_connection = mavutil.mavlink_connection(connection_string)

print("Heartbeat from system (system %u component %u)" % (mav_connection.target_system, mav_connection.target_component))

msg = mav_connection.mav.command_long_encode(
        mavutil.mavlink.MAV_CMD_DO_SET_SERVO, 0,
        9, 1500, 0, 0, 0, 0, 0


When I try to send the actuator test command using MAVlink console it is working.
actuator_test set -s 1 -v 1

Getting the below error when I use MAV_CMD_ACTUATOR_TEST:

Traceback (most recent call last):
  File "c:/Users/Dineshkumar.ASTERIA/Desktop/from pymavlink import", line 16, in <module>  
    mavutil.mavlink.MAV_CMD_ACTUATOR_TEST, 0,
AttributeError: module 'pymavlink.dialects.v20.ardupilotmega' has no attribute 'MAV_CMD_ACTUATOR_TEST'

Hi. Did you solve your problem? I’m trying to use servo motor with AUX1 port like you. but CMD_DO_SET_SERVO not working.