Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

Can anyone recommend an Arduino-based asynchronous scheduling library for controlling a small mobile robot?

I'm writing the control code for a small 2-wheeled Arduino-Uno based robot. It has a few bumper sensors, IR sensors, and ultrasonic sensors. I've written an initial pass from scratch, using loop() to read sensors and set motor values appropriately and then wait for the motor to have effect, but I'm finding this cluggy. Some of the sensors, like the ultrasonic range finders, require a small delay to operate, and the motors require a delay to have an effect. Blocking loop() is the simplest way to achieve this, but it wastes cycles, and can be difficult to time each action properly without throwing off other behaviors. Writing an asynchronous scheduler would be more efficient, but a lot more complicated, and I expect I would be reinventing the wheel.

I found this list, of existing scheduling libraries, but I'm not sure which, if any, would be appropriate.

share|improve this question
    
You may also want to take a look at cosa library on github. –  jfpoilpret Oct 28 '14 at 5:40
    
@jfpoilpret, Interesting. I'm not sure I want to throw out the default Arduino library just to use some scheduling componenets. And it's a shame Cosa's documentation is so bad. Why do so many developers think a class index with few comments and no examples is all they need for docs? Looking through that, it's not clear what I should use. It has a Timer, Alarm and Periodic class, as well as a few other classes that may be scheduling related as well. –  Cerin Oct 28 '14 at 13:38
    
you're a bit unfair about documentation, it is not bad at all (compared to the standard arduino lib at least). Regarding examples, there are more than 100 of them and they are even a very good way to learn Cosa. –  jfpoilpret Oct 28 '14 at 18:43
    
@jfpoilpret, I would agree that standard Arduino docs aren't great either, but the examples are better broken down by features set. I did see Cosa's examples directory, but other than the CosaAlarm example, I don't see anything else that uses the scheduling classes. –  Cerin Oct 28 '14 at 19:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.