Hi everyone, thank you for this wonderfull forum I found a lot of answers in there!
I have a surface boat drone. On board, I have rpanion running, it is connected to pixhawk and forward telemetry of the drone to udp 14550. Now I also have a pymavlink script on board that is running and connected to the pixhawk. I send orders such as mode changes, manual joystick control, and do set servo orders with mission planner and they are received by the drone.
I tried to read those messages with my pymavlink script and i couldn’t do it. I only get command_ack messages from pixhawk but I can’t access all details (like the servo and pwm) that are sent in command_long messages. Here’s my script, if someone can help me it would be really nice ! I wonder if maybe i should connect with a source_system but I am not sure…
My goal is to be able to send 8 different orders from mission planner to my script so if there is an easier solution than do_set_servo I take all advices !
# connect to vehicle
# vehicle = utility.mavlink_connection(device="tcpin:127.0.0.1:5765")
vehicle = utility.mavlink_connection(device="udp:0.0.0.0:14560")
vehicle.wait_heartbeat()
print("Connected to system:", vehicle.target_system, ", component:", vehicle.target_component)
liste_id_auvs = [51,52,53]
# liste_msg_pas_interessants = ["ATTITUDE",
# "SIMSTATE",
# "TERRAIN_REPORT",
# "SCALED_IMU3",
# "RANGEFINDER",
# "GIMBAL_MANAGER_STATUS",
# "DISTANCE_SENSOR",
# "GPS_RAW_INT",
# "HEARTBEAT",
# "SCALED_PRESSURE",
# "EXTENDED_SYS_STATE",
# "HOME_POSITION",
# "NAV_CONTROLLER_OUTPUT",
# "RC_CHANNELS",
# "MISSION_CURRENT",
# "SERVO_OUTPUT_RAW",
# "GPS_RTCM_DATA",
# "GPS2_RAW",
# "RAW_IMU",
# "TIMESYNC",
# "GLOBAL_POSITION_INT",
# "RC_CHANNELS_SCALED",
# "SYSTEM_TIME",
# "SYS_STATUS",
# "MEMINFO",
# "POWER_STATUS",
# "EKF_STATUS_REPORT",
# "LOCAL_POSITION_NED",
# "VIBRATION",
# "POSITION_TARGET_GLOBAL_INT",
# "BATTERY_STATUS",
# "AHRS2",
# "VFR_HUD",
# "AHRS",
# "GPS_GLOBAL_ORIGIN",
# "NAMED_VALUE_FLOAT",
# "SCALED_PRESSURE2",
# "GIMBAL_DEVICE_ATTITUDE_STATUS",
# "SCALED_IMU2",
# "SCALED_PRESSURE3",
# "",
# "PARAM_VALUE"]
while True:
#msg = vehicle.recv_match(type='COMMAND_LONG', blocking=True, timeout=1)
msg = vehicle.recv_match(blocking=True)
# if msg.get_type() not in liste_msg_pas_interessants:
print(msg)
if msg.get_type() == "COMMAND_LONG":
if msg.command == 183 :
servo_number = int(msg.Instance)
servo_pwm = int(msg.param2)
print(f"DO_SET_SERVO reçu → Servo {servo_number} = {servo_pwm} µs")
if not msg:
continue
target = getattr(msg, 'target', None) or getattr(msg, 'target_system', None)
if target not in liste_id_auvs:
continue