From c80a77e4a9881cc623034a35431654752e171c86 Mon Sep 17 00:00:00 2001 From: Adrian Zankich Date: Wed, 31 Dec 2014 06:34:36 -0800 Subject: [PATCH] go lint and documentation tweaks for the ardrone package --- platforms/ardrone/ardrone_adaptor.go | 17 +++++++++++------ platforms/ardrone/ardrone_driver.go | 15 +++++++++------ platforms/ardrone/doc.go | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/platforms/ardrone/ardrone_adaptor.go b/platforms/ardrone/ardrone_adaptor.go index 407306e8..c052541c 100644 --- a/platforms/ardrone/ardrone_adaptor.go +++ b/platforms/ardrone/ardrone_adaptor.go @@ -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 } diff --git a/platforms/ardrone/ardrone_driver.go b/platforms/ardrone/ardrone_driver.go index 40abbc81..12fb1b4a 100644 --- a/platforms/ardrone/ardrone_driver.go +++ b/platforms/ardrone/ardrone_driver.go @@ -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() } diff --git a/platforms/ardrone/doc.go b/platforms/ardrone/doc.go index 34410826..771a4ab6 100644 --- a/platforms/ardrone/doc.go +++ b/platforms/ardrone/doc.go @@ -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: