hybridgroup / gobot-site

Website for Gobot - Golang framework/set of libraries for robotics and physical computing
http://gobot.io/
9 stars 18 forks source link

Fixing race conditions in documented examples for flying drones #38

Closed ghost closed 8 years ago

ghost commented 8 years ago

Lots of the docs included LiftOff prior to "flying" event handlers being attached, so I've fixed those I could find. One of them is more complex than the rest and I can't currently test, so I encourage sanity checking.

As an aside, am I wrong in thinking that the event handlers need not be defined in the work function? It seems to be the way most of the examples are written, but my instinct would be to attach events prior to defining the work function's behaviour.

Does the work function loop, or only run once?

Thanks for Gobot, it's amazing. It is, in fact, one of the strong motivating factors that just lead me to buy a Bebop. :)

deadprogram commented 8 years ago

Hi, @cathalgarvey thanks for the PR.

You are correct that Gobot does not strictly require that the event handlers be inside the work routine. The work routine is a goroutine that is called 1 time, and then any events handlers, or repeating goroutines (aka Every or After are executed.

The work routine normally contains these handlers simply for clarity of code organization. All robots basically only have 3 things: connections, devices, and work.

In any case, thanks again for the contributions!