How to control Servo motor attached to pixhawk 4 using Dronecode SDK?


I am new to px4, so please bear with me. I am using Quad Airframe using pixhawk 4. I have connected a Servo motor to AUX1 port of pixhawk. I am trying to give pwm signals on the AUX1 port using Dronecode SDK C++ libraries. I want to move the servo motor after a particular waypoint in the mission. (I tried doing it in Qgroundcontrol and it works but I want to do it using C++ script). I also tried to import the mission plan from Qgroundcontrol and then upload it to the vehicle using C++ script but got an error of UNSUPPORTED mission item command.
I couldn’t find any plugins which i can use. does that mean I have to create my own plugin for the servo motor?
Can anyone please help me out?

1 Like

You get the UNSUPPORTED error because the SDK only supports some of the mission functionality for now.

I see these possibilities:

  1. You wait for the mission_raw plugin which will enable all sorts of commands, basically it will be pass-through any mavlink mission items. It’s something that is planned. (Or instead of waiting you could start with this plugin but it’s probably a bigger task).
  2. You make a change to the existing mission plugin and add the functionality there.

Thanks for the reply @JulianOes
Can I use mavros to control the servo motor or to trigger a relay which is connected to AUX port 1 of the pixhawk?


I don’t know about MAVROS.

I found this: Sending command to MAVLINK MAV_CMD_DO_SET_SERVO via MAVROS

but not much of DO_SET_SERVO in the MAVROS source: