How to make Mission resume after changing the battery using raspberry pi and drone kit code?

Hello everyone!

1.Is it possible to make drone automatically Arm, Take off and Resume to the last waypoint and continue the mission after every time the battery swapping? using drone kit running on raspberry pi.
2. Or I have to go for Lua script only to do this?

Please let me know.

Thanks.

@Drone,

I’m afraid we don’t have a feature to support this although it has been requested a few times.

Hi @Drone,

If you are willing to do a bit of programming you can get DroneKit or another API to help you out.
For dronekit, the mission upload/download and progress tracking should let you do what you want.

https://dronekit-python.readthedocs.io/en/latest/guide/auto_mode.html

You didn’t specify how you are currently loading missions, but if you are already loading them via DroneKit, then you can monitor next waypoint (vehicle.commands.next, see last function in the link about how to calculate the distance, the waypoint is important, less so the distance), you should save this somewhere persistent whenever it changes.

At boot/reconnect your code can see if it thought it was already meant to be flying a mission, load that mission into the AP, and then perform the ARM, Take-off actions, then switch to Auto mode and jump to the target waypoint.

I highly recommend you have some external way of triggering this process to start (or at minimum, disable or delay it) to avoid accidentally arming/taking-off when someone is in close proximity to your drone.

Edit: Btw, if you consider ‘reconnect’ as reboot, then you can use SITL to test this out and stop/start the SITL to simulate replacing the battery.

1 Like

Hello Parlene,
Thank your guidance.

I am loading a Mission directly to a flight controller from mission planner. It can be a normal waypoint or some time it can be gridline waypoints.

After changing the battery it should Arm, take off and go to last waypoint where failsafe got triggered.

Hi,

I think you can do this by watching for mode changes.

When the mode changes to AUTO (or GUIDED), you can use the example code to capture and record the mission.
When the mode changes to RTL, you can capture the current position.
Make sure to record the last ‘next waypoint’ value.

Then, when the program starts, you can look to see if you have recorded a mission, if you do, you can use simple_goto() to return to the place that the failsafe occurred, and then reload the mission and jump to the waypoint you recorded as being the ‘next waypoint’.

Simple goto documentation: https://dronekit-python.readthedocs.io/en/latest/automodule.html#dronekit.Vehicle.simple_goto
On the same page, you can find the arm() function, and simple_takeoff()
You can set the mode to GUIDED by doing vehicle.mode = VehicleMode(‘GUIDED’)