dronekit / dronekit-python

DroneKit-Python library for communicating with Drones via MAVLink.
https://readthedocs.org/projects/dronekit-python/
Apache License 2.0
1.5k stars 1.42k forks source link

Get RAW values of the servo outputs #1198

Open TongBingda opened 11 months ago

TongBingda commented 11 months ago

@morzack Thank you for replying to my email, I would love to be a maintainer of this program!

The RAW value of the servo output can be acquired based on the SERVO_OUTPUT_RAW information.

An object of this type is returned by :py:attr:Vehicle.servos.

:param port: Servo output port (set of 8 outputs = 1 port). Flight stacks running on Pixhawk should use: 0 = MAIN, 1 = AUX. :param servo_raw['1'] ~ servo_raw['16']: Servo output 1 ~ 16 value.

morzack commented 11 months ago

Sorry for the delay in taking a look at this. Overall, it looks good to me. Did you do any testing on actual hardware for this change? @TongBingda

TongBingda commented 11 months ago

Sorry for the delay in taking a look at this. Overall, it looks good to me. Did you do any testing on actual hardware for this change? @TongBingda

Yes, I recently tested this new feature using a Cube Orange and a CUAV X7+. I found some problems with the previous code. When running ardupilot firmware using the sitl method, SERVO_OUTPUT_RAW usually uses mavlink 2.0, whereas this message usually uses mavlink 1.0 when I run ardupilot firmware using Cube Orange, which makes it impossible to get the servo9_raw to servo16 _raw values. So in the latest code I used len(m.lengths) to get the actual number of servo_outputs to prevent errors.