Autonomous arming of UGV

I’m making a UGV using arduino and pixhawk. I want it to arm with the help of a range finder’s readings. I’m actually going to air drop the UGV to a particular point and then as soon as it hits the ground, the rangefinder will give a particular reading, using which I want the UGV to get armed and then execute the mission according to the planned path.
It’d be really helpful if I can get a code for the same.

why dont you enabled and disabled the motor lockout so it is armed when you deploy it but the motors are not enabled until its on the ground.

in a lua script you would want to do something like this with rangefinder25 (downwards facing)

if rrangefinder 25 > 50cm
then motorlockout =1
else if rangefinder 25 <50
then motorlockout =0

1 Like

Will try this . Thanks!:+1:

can this be done with python instead of lua?

or else it’d be really helpful if you can give the exact code for the same in lua script, as I’m completely clueless about lua…cuz my niche is python.

if (rangefinder:distance_cm_orient(25) <1) then
rc:run_aux_function(32, 0)
if (rangefinder:distance_cm_orient(25) >1) then
rc:run_aux_function(32, 1)

that would be something close to what you need
you should be able to get what you need out the example scripts

1 Like

The lua script will be running on the flightcontroller. This does not work with python. Lua is not that complicated and there are plenty of ardupilot lua examples here:

1 Like