I am trying to write some software using MAVSDK-Python where I am relying on being able to command a drone to new velocities very quickly - (approximately 10 Hz or greater) in offboard mode. I was able to meet my goals without MAVSDK-Python by sending the MAVLINK command for setting velocity directly:
def set_velocity(self, vx, vy, vz, yaw): time_boot_msec = int(time.time() * 1000) + self.time_offset_ms type_mask = 0b0000101111000111 # ignore everything by x, y, z velocities and set yaw self.connection.mav.set_position_target_local_ned_send(time_boot_msec, 1, 1, mavutil.mavlink.MAV_FRAME_LOCAL_NED, type_mask, 0, 0, 0, vx, vy, vz, 0, 0, 0, yaw, 0) return 0
This seems to work as expected (though it is mostly copy pasted from other parts of this forum - I don’t fully understand it all…). When this function is called, the drone immediately receives and takes action based off of the ordered velocity. If, for example, the previously ordered velocity was .5 m/s N and E, and the new ordered velocity was .6 m/s N and E, the drone would immediately increase speed to .6 m/s in either direction.
I would like to use MAVSDK-Python for this; unfortunately the offboard’s “set_velocity_…” commands appear to wait until the drone had ‘recentered’ itself before setting to the ordered velocity. If I were to order the drone in the same way as the example provided above, but using MAVSDK-Python, the drone appears to reset its attitude before coming to the new ordered velocity. This is, unfortunately, unacceptable for my use case - it sends the drone into an unstable state.
My first thought was to simply find where the behavior was defined that, when a new velocity was ordered, the drone would ‘reset’ itself. Unfortunately, upon diving into the repository, I simply couldn’t find where that behavior was defined.
I hope that you all will be able to help either by pointing me to where this behavior is defined such that I can redefine it or suggesting another way that might work for me.
Thank you for your patience and kindness in helping me solve this problem!