Asynchronous control of the Crazyflie 2.0

Firmware/software/electronics
Post Reply
RSOCAS
Beginner
Posts: 6
Joined: Wed Nov 29, 2017 3:09 pm

Asynchronous control of the Crazyflie 2.0

Post by RSOCAS » Thu May 03, 2018 8:50 pm

Dear all,
using the crazyflie python library API (cflib) I can control the copter very easy. I use the logging functionality to read the sensors information and I send the control signals to the copter by commands like send_setpoint(roll, pitch, yaw, thrust). In this case, the control system works in a periodic way.

Now I'm interested in checking event-based controllers in the Crazyflie 2.0 plataform. To do this, I need that the copter send the sensors information to the computer asynchronously. It means that the sensors information is received only when a certain condition is fulfilled (e.g. when the real altitude of the copter minus the reference altitude is greater than a certain threshold). On the other hand, when a command is sent to the copter (e.g. send_setpoint) this order has to be act in the copter indefinitely until a new command is sent again.

Does somebody know how to implement it in the crazyflie 2.0 platform?, Is it possible?

Best regards,
Rafael Socas

arnaud
Bitcraze
Posts: 1746
Joined: Tue Feb 06, 2007 12:36 pm

Re: Asynchronous control of the Crazyflie 2.0

Post by arnaud » Fri May 04, 2018 6:36 am

Hi,

Crazyflie 2.0 is open source and I see no technical blocker there so yes it is possible. The functionality does not exist in the Crazyflie yet.

The way to implement it depends of what your goal is: do you want a one-off very specific solution or do you want something generic that can be used in a lot of situation?

For a one-off solution, you can send custom packet within your code and add handling functions for it in the lib. Sending a packet from Crazyflie requires only one function call (crtpSendPacket). For a simple example of how to connect code on firmware and python side you can look at the implementation of the localization service: https://github.com/bitcraze/crazyflie-f ... _service.c and https://github.com/bitcraze/crazyflie-l ... ization.py


For a generic solution, we have been thinking about event-based log before and this is one generic architecture I came up with:
- Adding an event subsystem that looks very much like the log and param subsystem: modules can create and register an event, the event table of content can be read from the ground associating a group.name with and event_id the same way log and param TOC is read. The event is triggered by the module that created it, for example the sensors module can trigger the event "sensors.imu_read" just after reading the IMU.
- Log block can be setup to be sent on event instead of rate by passing an event_id when the block is started (this requires adding a new packet to start log blocks). The log subsystem will then register a callback function as a receiver of the event and send a log packet each time the event is triggered.

This was though as a solution to log IMU data synchronously with the IMU readings but it seems that it would fit your use-case too: your code can create events for different things and then from the client side you can setup log blocks that are being sent on these events.

RSOCAS
Beginner
Posts: 6
Joined: Wed Nov 29, 2017 3:09 pm

Re: Asynchronous control of the Crazyflie 2.0

Post by RSOCAS » Fri May 04, 2018 10:27 am

Dear Arnaud,
thank you very much for your valuable information.

In my opinion is more interesting to develop the generic solution because it can cover a lot of uses cases.

I am going to try to develop these new ideas in the platform. Please let me know if similar ideas are implemented by your team.

Thank you so much, you are very kind.

Best regards,
Rafael Socas

Post Reply