Skip to content

Commit

Permalink
Fixed event race condition
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Cathal Garvey authored and deadprogram committed Feb 17, 2016
1 parent cee08c8 commit 79fad6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/ardrone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 79fad6b

Please sign in to comment.