Hi everyone,
I’m trying to control a servo(for payload drop) connected to MAIN OUT 1(for testing purpose i have connected to that port) on a Cube Orange+ using MAVSDK C++.
i am using px4 v1.15.4.
I’ve tried the following methods, but none of them seem to move the servo:
-
Action::set_actuator() -
Sending
MAV_CMD_DO_SET_ACTUATOR(command 187) viaMavlinkPassthrough -
Sending
MAV_CMD_DO_SET_SERVO(command 183) viaMavlinkPassthrougheven MAV_CMD_DO_MOTOR_TEST is also not working.
mavlink_message_t msg;
mavlink_msg_command_long_pack(
passthrough->get_our_sysid(),
passthrough->get_our_compid(),
&msg,
passthrough->get_target_sysid(),
passthrough->get_target_compid(),
MAV_CMD_DO_SET_ACTUATOR,
0, // Confirmation
-1, // param1 = servo number
NAN, // param2 = PWM value
NAN, NAN, NAN, NAN, 0 // unused params
);
passthrough->send_message(msg);
mavlink_command_long_t cmd{};
cmd.target_system = passthrough->get_target_sysid();
cmd.target_component = passthrough->get_target_compid();
cmd.command = MAV_CMD_DO_SET_SERVO;
cmd.confirmation = 0;
// actuator 9 (AUX OUT 1)
cmd.param1 = 0;
cmd.param2 = 1;
// cmd.param3 = NAN; // your desired position
// cmd.param4 = NAN;
// cmd.param5 = NAN;
// cmd.param6 = NAN;
// cmd.param7 = 0; // block index
mavlink_message_t msg{};
mavlink_msg_command_long_encode(
passthrough->get_our_sysid(),
passthrough->get_our_compid(),
&msg,
&cmd
);
passthrough->send_message(msg);
action.set_Actuator(1,1.0);
above codes are not working.
PX4 console also shows warnings like:
[Warn] Received ack for not-existing command: 187! Ignoring...
I can confirm that the hardware and servo output work fine — the servo moves when using QGroundControl → Actuator Test.
Am i missing or doing anything wrong about it? Has anyone successfully controlled servos through MAVSDK on PX4?
Thanks in advance.