go lint and documentation tweaks for the ardrone package
This commit is contained in:
parent
ebc0d5e479
commit
c80a77e4a9
|
@ -22,6 +22,7 @@ type drone interface {
|
|||
Hover()
|
||||
}
|
||||
|
||||
// ArdroneAdaptor is gobot.Adaptor representation for the Ardrone
|
||||
type ArdroneAdaptor struct {
|
||||
name string
|
||||
drone drone
|
||||
|
@ -29,7 +30,10 @@ type ArdroneAdaptor struct {
|
|||
connect func(*ArdroneAdaptor) (drone, error)
|
||||
}
|
||||
|
||||
// NewArdroneAdaptor creates a new ardrone and connects with default configuration
|
||||
// NewArdroneAdaptor returns a new ArdroneAdaptor and optionally accepts:
|
||||
//
|
||||
// string: The ardrones IP Address
|
||||
//
|
||||
func NewArdroneAdaptor(name string, v ...string) *ArdroneAdaptor {
|
||||
a := &ArdroneAdaptor{
|
||||
name: name,
|
||||
|
@ -46,17 +50,18 @@ func NewArdroneAdaptor(name string, v ...string) *ArdroneAdaptor {
|
|||
return a
|
||||
}
|
||||
|
||||
// Name returns the ArdroneAdaptors Name
|
||||
func (a *ArdroneAdaptor) Name() string { return a.name }
|
||||
|
||||
// Connect returns true when connection to ardrone is established correclty
|
||||
// Connect establishes a connection to the ardrone
|
||||
func (a *ArdroneAdaptor) Connect() (errs []error) {
|
||||
if d, err := a.connect(a); err != nil {
|
||||
d, err := a.connect(a)
|
||||
if err != nil {
|
||||
return []error{err}
|
||||
} else {
|
||||
a.drone = d
|
||||
}
|
||||
a.drone = d
|
||||
return
|
||||
}
|
||||
|
||||
// Finalize returns true when connection is finalized correctly
|
||||
// Finalize terminates the connection to the ardrone
|
||||
func (a *ArdroneAdaptor) Finalize() (errs []error) { return }
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
var _ gobot.Driver = (*ArdroneDriver)(nil)
|
||||
|
||||
// ArdroneDriver is gobot.Driver representation for the Ardrone
|
||||
type ArdroneDriver struct {
|
||||
name string
|
||||
connection gobot.Connection
|
||||
|
@ -26,7 +27,10 @@ func NewArdroneDriver(connection *ArdroneAdaptor, name string) *ArdroneDriver {
|
|||
return d
|
||||
}
|
||||
|
||||
func (a *ArdroneDriver) Name() string { return a.name }
|
||||
// Name returns the ArdroneDrivers Name
|
||||
func (a *ArdroneDriver) Name() string { return a.name }
|
||||
|
||||
// Connection returns the ArdroneDrivers Connection
|
||||
func (a *ArdroneDriver) Connection() gobot.Connection { return a.connection }
|
||||
|
||||
// adaptor returns ardrone adaptor
|
||||
|
@ -34,23 +38,22 @@ func (a *ArdroneDriver) adaptor() *ArdroneAdaptor {
|
|||
return a.Connection().(*ArdroneAdaptor)
|
||||
}
|
||||
|
||||
// Start returns true if driver is started succesfully
|
||||
// Start starts the ArdroneDriver
|
||||
func (a *ArdroneDriver) Start() (errs []error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Halt returns true if driver is halted succesfully
|
||||
// Halt halts the ArdroneDriver
|
||||
func (a *ArdroneDriver) Halt() (errs []error) {
|
||||
return
|
||||
}
|
||||
|
||||
// TakeOff makes the drone start flying
|
||||
// and publishes `flying` event
|
||||
// TakeOff makes the drone start flying, and publishes `flying` event
|
||||
func (a *ArdroneDriver) TakeOff() {
|
||||
gobot.Publish(a.Event("flying"), a.adaptor().drone.Takeoff())
|
||||
}
|
||||
|
||||
// Land makes the drone stop flying
|
||||
// Land causes the drone to land
|
||||
func (a *ArdroneDriver) Land() {
|
||||
a.adaptor().drone.Land()
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ Package ardrone provides the Gobot adaptor and driver for the Parrot Ardrone.
|
|||
|
||||
Installing:
|
||||
|
||||
go get github.com/hybridgroup/gobot/platforms/ardrone
|
||||
go get -d -u github.com/hybridgroup/gobot/... && go install github.com/hybridgroup/gobot/platforms/ardrone
|
||||
|
||||
Example:
|
||||
|
||||
|
|
Loading…
Reference in New Issue