Can I enter hold mode if current exceeds X amps?

Is there a way to have my truck go into hold mode if the current being drawn exceeds a limit that I set?

I had my truck doing a mission and it has been pretty rock solid lately. I had it do 120 laps yesterday without a hitch then today I had it out there and it was doing fine then work called and I had to get on a troubleshooting call. I wasn’t paying any attention to the truck and when the call was done, I noticed that it was stopped on the map. I look out and it ran into an 2" pole (the only obstacle even close :confused: ) and seemed to be stuck. I went out and the motor was letting the magic smoke out because the truck, try as it may, could not drive over a metal pole.

So I’m looking for a way to have it stop trying to reach a waypoint if a condition is met. In this case it would be excessive current draw or not reaching a waypoint in x amount of seconds.

I found MOT_BAT_CURR_MAX but that just limits the max current.

you would need to make a lua script to look at the current draw and if it exceeds a set amount change to hold mode.

Ok, that’s a bit over my head at this point. I’ve done some Arduino experimentation and some linux bash scripting but never touched lua. I guess I can look into that.

have a look at the example scripts, there is probably something there you can edit to make work, your not wanting anything that complicated.

sonmething like

 local max_current = 99
local current = current_amps

if (current>max_current) and (vehicle:get_mode() == 10) then    -- if mode is in auto 
	vehicle:set_mode(4) --set mode to Hold
    gcs:send_text(2, string.format("Battery warning:OVERCURRENT PROTECTION))
  return update, 1000

@Yuri_Rage is this correct?

The first part is simple enough :slight_smile: Does this part write a message to the log or messages section or something? And it looks like the last line sets a loop for 1000ms? This don’t look too bad, normal stuff. I just have to learn the syntax.

I looked at Yuri’s profile and it looks like he has a lua starter video on his youtube page. I’ll be watching that! Thanks guys.

1 Like

yes that will flash a warning on your ground control software

1 Like

FS_CRASH_CHECK enabled? It’s not fool proof but it’s put my Rover in Hold mode in some cases before the Spur gear strips out (sacrificial cheap part).


@mikez104 were you able to configure it and get flash warning messages?

I’m trying something similar where I want ardupilot to display a pop-up window or a warning message when the current draw of my drone is exceeding 100A.