Skip to content

Commit

Permalink
holystone: Update example for correctness, and README as well
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Oct 19, 2017
1 parent cad982e commit a3f086c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 28 deletions.
38 changes: 38 additions & 0 deletions examples/holystone_hs200.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// +build example
//
// Do not build by default.

/*
How to run
go run examples/holystone_hs200.go
*/

package main

import (
"time"

"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/holystone/hs200"
)

func main() {
drone := hs200.NewDriver("172.16.10.1:8888", "172.16.10.1:8080")

work := func() {
drone.TakeOff()

gobot.After(5*time.Second, func() {
drone.Land()
})
}

robot := gobot.NewRobot("hs200",
[]gobot.Connection{},
[]gobot.Device{drone},
work,
)

robot.Start()
}
49 changes: 22 additions & 27 deletions platforms/holystone/hs200/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Holystone HS200

This package contains the Gobot driver for the Holystone HS200 drone.

For more information on this drone, go to:
http://www.holystone.com/product/Holy_Stone_HS200W_FPV_Drone_with_720P_HD_Live_Video_Wifi_Camera_2_4GHz_4CH_6_Axis_Gyro_RC_Quadcopter_with_Altitude_Hold,_Gravity_Sensor_and_Headless_Mode_Function_RTF,_Color_Red-39.html

## How to Install

```
Expand All @@ -17,40 +22,30 @@ Here is a sample of how you initialize and use the driver:
package main

import (
"log"
"time"

"fmt"

"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/holystone/hs200"
)

func main() {
drone, err := hs200.NewDriver("172.16.10.1:8888", "172.16.10.1:8080")
if err != nil {
log.Fatal(err)
drone := hs200.NewDriver("172.16.10.1:8888", "172.16.10.1:8080")

work := func() {
drone.TakeOff()

gobot.After(5*time.Second, func() {
drone.Land()
})
}
fmt.Println("Enable!")
drone.Enable()
time.Sleep(5 * time.Second)
fmt.Println("Take off!")
drone.TakeOff()
time.Sleep(5 * time.Second)
fmt.Println("Full steam ahead!")
drone.Forward(1.0)
time.Sleep(3 * time.Second)
fmt.Println("Full steam back!")
drone.Forward(-1.0)
time.Sleep(3 * time.Second)
fmt.Println("Hover!")
drone.Forward(0)
time.Sleep(3 * time.Second)
fmt.Println("Land!")
drone.Land()
time.Sleep(5 * time.Second)
fmt.Println("Disable!")
drone.Disable()
time.Sleep(5 * time.Second)

robot := gobot.NewRobot("hs200",
[]gobot.Connection{},
[]gobot.Device{drone},
work,
)

robot.Start()
}
```

Expand Down
2 changes: 1 addition & 1 deletion platforms/holystone/hs200/hs200_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"gobot.io/x/gobot"
)

// Driver reperesents the control information for the hs200 drone
// Driver represents the control information for the hs200 drone
type Driver struct {
name string
mutex *sync.RWMutex // Protect the command from concurrent access
Expand Down

0 comments on commit a3f086c

Please sign in to comment.