Modifying the control loop for educational purposes

Firmware/software/electronics/mechanics
Post Reply
tnecniv
Beginner
Posts: 5
Joined: Fri Jun 07, 2019 3:18 pm

Modifying the control loop for educational purposes

Post by tnecniv »

I'm currently evaluating a few different robotics platforms for use in an introductory robotics course. The Crazyflie is very appealing since the API seems nice and it sits at a good price point.

My main concern is that, as part of the course, we would like the students to implement their own controller for stabilizing the quadrotor in a hover state. From searching through the API / Google, it seems that this can be done, but the controller would need to be implemented at the firmware level. Ideally, we would like to stay away from modifying the firmware since the rest of the class will be conducted in Python.

Is it possible to implement a controller via the Python API without significant firmware modification?

Thanks!
hos
Beginner
Posts: 2
Joined: Sun Jun 09, 2019 12:11 pm

Re: Modifying the control loop for educational purposes

Post by hos »

To get lower level access to the motors you can have a look at this paper. On page 80+ he creates his own crtp packets to control each motor separately. I'v never tried it though.
EDIT: on second thought, he's probably using a custom firmware to decode those packets. you can use these parameters to set the power for each motor
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Modifying the control loop for educational purposes

Post by arnaud »

Just a note: you should test the idea first. There will likely be too much latency to control down to the motors PWM via the radio, I think it has been done once (someone on the forum implemented an LQR controller completely off-board a while ago), but it most likely requires to be very careful about how the communication is implemented.

Going up in control would make things better: making an off-board position controller works quite well. You might also be able to leave the rotation rate controller loop in the firmware and implement attitude controller outside, it would relax a little bit the latency requirement.

On a side note, I have been thinking of playing with Micropython. Micropython would allow to run python scripts in the Crazyflie and it seems that it would be light enough to run things like controller at real-time. Though since it is running in the Crazyflie CPU, things like running a debugger would still not be possible. Is that something that would be useful for your use-case?
tnecniv
Beginner
Posts: 5
Joined: Fri Jun 07, 2019 3:18 pm

Re: Modifying the control loop for educational purposes

Post by tnecniv »

hos wrote: Sun Jun 09, 2019 12:21 pm To get lower level access to the motors you can have a look at this paper. On page 80+ he creates his own crtp packets to control each motor separately. I'v never tried it though.
EDIT: on second thought, he's probably using a custom firmware to decode those packets. you can use these parameters to set the power for each motor
Thanks! I'll take a look at these.
arnaud wrote: Wed Jun 12, 2019 7:38 am Just a note: you should test the idea first. There will likely be too much latency to control down to the motors PWM via the radio, I think it has been done once (someone on the forum implemented an LQR controller completely off-board a while ago), but it most likely requires to be very careful about how the communication is implemented.

Going up in control would make things better: making an off-board position controller works quite well. You might also be able to leave the rotation rate controller loop in the firmware and implement attitude controller outside, it would relax a little bit the latency requirement.

On a side note, I have been thinking of playing with Micropython. Micropython would allow to run python scripts in the Crazyflie and it seems that it would be light enough to run things like controller at real-time. Though since it is running in the Crazyflie CPU, things like running a debugger would still not be possible. Is that something that would be useful for your use-case?
Yeah I was planning on purchasing a Crazyflie to test this stuff before ordering all the ones for the class. I am a little worried about the radio latency, so those are some good ideas. Do you have any suggestions for scripts / resources to take a look at to see how to implement those in Python? I haven't used the Crazyflie API before.

Regarding Micropython, that definitely sounds appealing --- both for the purposes of this class and my research. I work with a lot of controls that do heavy optimization offline, but are very efficient to run online. Something like you described sounds pretty handy for a potential research platform.
Post Reply