From 051f54c7a01bcb130dbce6a54c9c843f729beee1 Mon Sep 17 00:00:00 2001 From: Cathal Garvey Date: Fri, 6 Nov 2015 20:32:00 -0800 Subject: [PATCH] Fixed event race condition If this is anything like the Bebop, then taking off immediately fires the "flying" event, but these events aren't buffered so attaching an event handler afterwards achieves nothing. When I ran the same code for the Bebop (as suggested on the site) it never landed, prompting an emergency connect-with-phone-hammer-buttons scramble. Swapping the event registration with the takeoff method call fixed the problem immediately. --- examples/ardrone.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ardrone.go b/examples/ardrone.go index dec41f97..3bab24dc 100644 --- a/examples/ardrone.go +++ b/examples/ardrone.go @@ -14,12 +14,12 @@ func main() { drone := ardrone.NewArdroneDriver(ardroneAdaptor, "Drone") work := func() { - drone.TakeOff() gobot.On(drone.Event("flying"), func(data interface{}) { gobot.After(3*time.Second, func() { drone.Land() }) }) + drone.TakeOff() } robot := gobot.NewRobot("drone",