[solved] emergency landing - using NRF IO pin

Firmware/software/electronics/mechanics
Post Reply
wydmynd
Member
Posts: 87
Joined: Thu Dec 06, 2018 9:25 am

[solved] emergency landing - using NRF IO pin

Post by wydmynd »

I have an application where I want to send an "emergency land" command to an autonomous crazyflie.
It should work even if the CF is ACTIVELY connected to another computer via radio or USB.
Currently I use another computer (and crazyradioPA) to send "set power" packet to the CF to put it to sleep and this kills it mid-flight.
My new idea is to use the handleRadioCmd function to send a "emergency land" packet which bypasses the syslink completely (to provide redundancy in case there is an existing connection). This will be done by setting the nrf_io_1 pin high (per this reference), and the FW will be polling this pin using a GPIO pin.

I have never touched the nrf firmware, would love to get your feedback on this method before I start. I could not find much reference about the 2 NRF IO pins , in what applications are they used. Any reference or code will be greatly appreciated, and I will be happy to share the result for anyone interested.

Thanks
Last edited by wydmynd on Mon Nov 08, 2021 1:44 pm, edited 1 time in total.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: emergency landing - using NRF IO pin

Post by arnaud »

Hi,

If I understand you plan well, what you want to do is:
- Send a standalone radio packet to the Crazyflie (outside of the current link connection) that tells the Crazyflie to land
- Set the nrf_io_1 pin in the packer handler when this packet is received
- Connect the nrf_io_1 physically to an STM GPIO on the expansion port
- Start the landing sequence when this pin is detected as set by the STM32

This sounds like it will work to me, I do not see any obvious blockers.

There does not seem to be any code handling the GPIOs in the current nRF code, but there is some example on how to handle a GPIO, for example in the PM: https://github.com/bitcraze/crazyflie2- ... /pm.c#L155. All you should need to do is to add support for a new packet and set the GPIO in the function handling this packet.

Note that the radio cmd packet wire format is "0xff 0x03 <CMD> <DATA..>." and that the data cannot be empty (the packet should be 4 bytes or more). The packet dispatching appears there: https://github.com/bitcraze/crazyflie2- ... #L207-L214. There is currently 2 classes of packets that bypass the connection: radioCommand and bootloaderCmd. You can either hook into one of those as you suggested or you could create a new class since what you want to implement is not a radio neither a bootloader command. This is more an architectural question though, functionally it will all work the same.
wydmynd
Member
Posts: 87
Joined: Thu Dec 06, 2018 9:25 am

Re: emergency landing - using NRF IO pin

Post by wydmynd »

update - it works!

project includes -
1. additions to NRF firmware to add "emergency land packet"
2. additional "virtual deck" in STM firmware to monitor the NRF IO pin using an IO pin in the STM
3. python test code
4. description of the hardware "hack" required (some wire and a pull-down resistor)

git repo - https://github.com/M-R-VulcaN/crazyflie-emergency-land

hope this can also be a useful to anyone. for example, it can be used to trigger an action in the STM from a second computer in case the main computer controlling the CF has crashed or some other error occurred.
Post Reply