Skip to content

Instantly share code, notes, and snippets.

@bsamadi
Created October 23, 2023 20:44
Show Gist options
  • Save bsamadi/90e7b3229026e6e27dfaabd4552a9b47 to your computer and use it in GitHub Desktop.
Save bsamadi/90e7b3229026e6e27dfaabd4552a9b47 to your computer and use it in GitHub Desktop.
MAV_CMD_DO_MOUNT_CONTROL
from pymavlink import mavutil
# Set the connection string to your autopilot. This can be a serial port or a network connection.
connection_string = 'udp:127.0.0.1:5800' # Replace with the appropriate connection details
# Create a MAVLink connection
master = mavutil.mavlink_connection(connection_string)
while True:
msg = master.recv_match(type='COMMAND_LONG', blocking=True)
if msg is not None and msg.command == mavutil.mavlink.MAV_CMD_DO_MOUNT_CONTROL:
# Extract and print values from the COMMAND_LONG message
target_system = msg.target_system
target_component = msg.target_component
control_mode = msg.param1
pitch = msg.param2
yaw = msg.param3
roll = msg.param4
duration = msg.param5
print(f"Received MAV_CMD_DO_MOUNT_CONTROL command:")
print(f"Target System: {target_system}")
print(f"Target Component: {target_component}")
print(f"Control Mode: {control_mode}")
print(f"Pitch: {pitch} degrees")
print(f"Yaw: {yaw} degrees")
print(f"Roll: {roll} degrees")
print(f"Duration: {duration} ms")
print("------------------------")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment