Posted by automatik on February 13, 2009 at 2:42pm
Hi all,first of all - while I know enough 'C' to be "dangerous", I am not C++, C#, etc. junkie - so...I looked over ArduPilot code and at least to me it looks like 'linear execution' - i.e. i don't see anything happening in parallel. For example, while GPS data is being read, code does just that - there is no input being read from other sensors, or acting on any controls, etc. Another example is when PID loop is being updated, nothing else is going on (i.e it would be nice if GPS is acquiring next set of data, etc.).Is my assessment correct? In this environment, is it possible to do parallel execution (akin to multithread...)? Obviously code works as demonstrated by Chris and Jori...my question goes more into the realm of performance - is it really fast enough for real time performance?Does code 'works' as i described it (remember I am not 'C' guy and might be reading it wrong)?I am NOT trying to dis(spl?) the code -it's just a question ! In my day job, for system control purposes I use other environments where parallelism is almost 'given' for tasks....
You need to be a member of diydrones to add comments!
That's the big difference between microprocessor programming and programming on systems with an operating system. Here, like most embedded systems of this class, there is no OS, realtime or otherwise, to handle multithreading. We program "straight to the iron", which allows us to use cheap, low-power chips and have total control over timing.
No worry. One task is done at a time, serially, and all tasks run in loop. This is so fast that each task gets its time.
For example, GPS reading takes 2ms (if there're new data available). PID computations take ~1ms. So loop runs maybe 500 times/second,
Assuming that GPS sends update at 1Hz, processor needs to act just once each second. So its capacity is more that needed. It can safely do the navigation task in simple loop, one step after another.
Replies
For example, GPS reading takes 2ms (if there're new data available). PID computations take ~1ms. So loop runs maybe 500 times/second,
Assuming that GPS sends update at 1Hz, processor needs to act just once each second. So its capacity is more that needed. It can safely do the navigation task in simple loop, one step after another.