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)
mav_connection.wait_heartbeat()
print("Heartbeat from system (system %u component %u)" % (mav_connection.target_system, mav_connection.target_component))
msg = mav_connection.mav.command_long_encode(
mav_connection.target_system,
mav_connection.target_component,
mavutil.mavlink.MAV_CMD_DO_SET_SERVO, 0,
9, 1500, 0, 0, 0, 0, 0
)
mav_connection.mav.send(msg)
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 mavutil.py", line 16, in <module>
mavutil.mavlink.MAV_CMD_ACTUATOR_TEST, 0,
AttributeError: module 'pymavlink.dialects.v20.ardupilotmega' has no attribute 'MAV_CMD_ACTUATOR_TEST'