Skip to content

Commit

Permalink
go lint and documentation tweaks for the ardrone package
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Dec 31, 2014
1 parent ebc0d5e commit c80a77e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
17 changes: 11 additions & 6 deletions platforms/ardrone/ardrone_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ type drone interface {
Hover()
}

// ArdroneAdaptor is gobot.Adaptor representation for the Ardrone
type ArdroneAdaptor struct {
name string
drone drone
config client.Config
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,
Expand All @@ -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 }
15 changes: 9 additions & 6 deletions platforms/ardrone/ardrone_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,31 +27,33 @@ 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
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()
}
Expand Down
2 changes: 1 addition & 1 deletion platforms/ardrone/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c80a77e

Please sign in to comment.