Real-time OS
I wanted to send commands to my UAV during flight. Implementing this on my ground station was not hard at all. Doing the same on my autopilot software turned out not as easy: parsing (and validating data that could be gibberish) data coming from the serial interface could potentially disturb the strict timing needed for my kalman filtering. That strict timing also prevented my from doing some other telemetry and dataprocessing stuff.
It was time to port my code to a real-time operating system. Also a good excuse to start playing with it :-)
I’m not familiar with a lot of those “free” RTOS’s on the net, so I picked up the most common one: FreeRTOS
I had read the documentation a few times before, but never got to the coding part. It turned out pretty easy! Thanks to the modular approach i used in the autopilot software, porting it to FreeRTOS was finished in about an afternoon!
Now I can add various new functionalities without worrying how to fit it in the current code.
Another advantage is “Run time statistics”. Before I thought I used about 40% of the CPU, but it turns out that I’m only using 6% of it:
TickTask 267 <1%
IDLE 49058 94%
5DofTask 2098 4%
ControlTask 481 <1%
GpsTask 16 <1%
- TickTask: the task printing this statistic (once every 5 seconds)
- IDLE: the idle task, when nothing else is running
- 5DofTask: the task calculating the attitude (Kalman)
- ControlTalk: the task calculating the PID control algorithms (50Hz) and the navigation (5Hz)
- GpsTask: the task parsing the GPS strings (5Hz)
|