goev3

package module
v0.0.0-...-4172328 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2019 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

goev3

A go wrapper around the LEGO EV3 api.

Documentation

Index

Constants

View Source
const (
	OutA = "outA"
	OutB = "outB"
	OutC = "outC"
	OutD = "outD"
)

All out Addresses

View Source
const (
	In1 = "in1"
	In2 = "in2"
	In3 = "in3"
	In4 = "in4"
)

All in Addresses

View Source
const (
	NoColor ColorValue = 0
	Black              = 1
	Blue               = 2
	Green              = 3
	Yellow             = 4
	Red                = 5
	White              = 6
	Brown              = 7
)
View Source
const (
	IRRCNone            IRRemoteCode = 0
	IRRCRedUp                        = 1
	IRRCRedDown                      = 2
	IRRCBlueUp                       = 3
	IRRCBlueDown                     = 4
	IRRCRedUpBlueUp                  = 5
	IRRCRedUpBlueDown                = 6
	IRRCRedDownBlueUp                = 7
	IRRCRedDownBlueDown              = 8
	IRRCBeaconOn                     = 9
	IRRCRedUpRedDown                 = 10
	IRRCBlueUpBlueDown               = 11
)

possible values for remote code

View Source
const (
	StopActionCoast = "coast"
	StopActionBrake = "brake"
	StopActionHold  = "hold"
)

List of all stop actions

View Source
const (
	PolarityNormal   = "normal"
	PolarityInversed = "inversed"
)

List of all polarities actions

Variables

StatesMoving contains all moving states

StatesNotMoving contains all non-moving states

Functions

func RunLua

func RunLua(script string, ctrl *Controller) error

Types

type Battery

type Battery struct {
	CurrentMA  float64
	Voltage    float64
	VoltageMin float64
	VoltageMax float64
}

func (Battery) String

func (b Battery) String() string

type Color

type Color struct {
	// contains filtered or unexported fields
}

func (*Color) Read

func (cr *Color) Read() ColorData

type ColorAmbient

type ColorAmbient struct {
	// contains filtered or unexported fields
}

func (*ColorAmbient) Read

func (cr *ColorAmbient) Read() int

type ColorData

type ColorData struct {
	Value ColorValue
}

func (ColorData) String

func (cd ColorData) String() string

type ColorReflect

type ColorReflect struct {
	// contains filtered or unexported fields
}

func (*ColorReflect) Read

func (cr *ColorReflect) Read() int

type ColorValue

type ColorValue int

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(options ...ControllerOption) (*Controller, error)

func (*Controller) Battery

func (ctrl *Controller) Battery() (*Battery, error)

func (*Controller) NewColor

func (ctrl *Controller) NewColor(inAddr string) (*Color, error)

func (*Controller) NewColorAmbient

func (ctrl *Controller) NewColorAmbient(inAddr string) (*ColorAmbient, error)

func (*Controller) NewColorReflect

func (ctrl *Controller) NewColorReflect(inAddr string) (*ColorReflect, error)

color sensors

func (*Controller) NewIRProxy

func (ctrl *Controller) NewIRProxy(inAddr string) (*IRProxy, error)

func (*Controller) NewIRRemote

func (ctrl *Controller) NewIRRemote(inAddr string) (*IRRemote, error)

func (*Controller) NewIRSeek

func (ctrl *Controller) NewIRSeek(inAddr string) (*IRSeek, error)

func (*Controller) NewMotor

func (ctrl *Controller) NewMotor(outAddr string) (*Motor, error)

func (*Controller) NewTouch

func (ctrl *Controller) NewTouch(inAddr string) (*Touch, error)

type ControllerOption

type ControllerOption func(ctrl *Controller) error

func WithBatteryFS

func WithBatteryFS(fs string) ControllerOption

func WithMotorFS

func WithMotorFS(fs string) ControllerOption

func WithSensorFS

func WithSensorFS(fs string) ControllerOption

type IRProxy

type IRProxy struct {
	// contains filtered or unexported fields
}

func (*IRProxy) Distance

func (irp *IRProxy) Distance() int

type IRRemote

type IRRemote struct {
	// contains filtered or unexported fields
}

func (*IRRemote) Read

func (irr *IRRemote) Read() IRRemoteData

type IRRemoteCode

type IRRemoteCode int

IRRemoteCode is the returning chanel mode for ir remote mode

func (IRRemoteCode) String

func (irrc IRRemoteCode) String() string

type IRRemoteData

type IRRemoteData struct {
	Channels [4]IRRemoteCode
}

IRRemoteData is the returning data structure for ir remote mode

func (IRRemoteData) String

func (irrd IRRemoteData) String() string

type IRSeek

type IRSeek struct {
	// contains filtered or unexported fields
}

func (*IRSeek) Seek

func (irs *IRSeek) Seek() IRSeekData

ReadData reads the channel data from the seek; for distance 100% is approximately 200cm, heading is -25 far left, 25 far right

type IRSeekChannel

type IRSeekChannel struct {
	Heading  int //-25...25
	Distance int //0...100
}

type IRSeekData

type IRSeekData struct {
	Channels [4]IRSeekChannel
}

func (IRSeekData) String

func (irsd IRSeekData) String() string

type Motor

type Motor struct {
	Descriptor MotorDescriptor
}

Motor is the base struct to control motors

func (*Motor) ChangePolarity

func (tm *Motor) ChangePolarity(p string) error

ChangePolarity changes the polarity to the specified value

func (*Motor) ChangePositionSP

func (tm *Motor) ChangePositionSP(val int) error

ChangePositionSP changes the position_sp to the specified value

func (*Motor) ChangeRampDownSP

func (tm *Motor) ChangeRampDownSP(d time.Duration) error

ChangeRampDownSP changes the ramp_down_sp to the specified value

func (*Motor) ChangeRampUpSP

func (tm *Motor) ChangeRampUpSP(d time.Duration) error

ChangeRampUpSP changes the ramp_up_sp to the specified value

func (*Motor) ChangeSpeedSP

func (tm *Motor) ChangeSpeedSP(val int) error

ChangeSpeedSP changes the speed_sp to the specified value

func (*Motor) ChangeStopAction

func (tm *Motor) ChangeStopAction(sa string) error

ChangeStopAction changes the stop action to the specified value

func (*Motor) ChangeTimeSP

func (tm *Motor) ChangeTimeSP(d time.Duration) error

ChangeTimeSP changes the time_sp to the specified value

func (*Motor) Move

func (m *Motor) Move() *Move

func (*Motor) Polarity

func (tm *Motor) Polarity() (string, error)

Polarity returns the polarity

func (*Motor) Position

func (tm *Motor) Position() (int, error)

Position returns position

func (*Motor) PositionSP

func (tm *Motor) PositionSP() (int, error)

PositionSP returns position_sp

func (*Motor) RampDownSP

func (tm *Motor) RampDownSP() (time.Duration, error)

RampDownSP returns ramp_down_sp

func (*Motor) RampUpSP

func (tm *Motor) RampUpSP() (time.Duration, error)

RampUpSP returns ramp_up_sp

func (*Motor) Reset

func (tm *Motor) Reset() error

Reset executes the reset command

func (*Motor) RunDirect

func (tm *Motor) RunDirect() error

RunDirect executes the run-direct command

func (*Motor) RunForever

func (tm *Motor) RunForever() error

RunForever executes the run-forever command

func (*Motor) RunTimed

func (tm *Motor) RunTimed() error

RunTimed executes the run-timed command

func (*Motor) RunToAbsPos

func (tm *Motor) RunToAbsPos() error

RunToAbsPos executes the run-to-abs-pos command

func (*Motor) RunToRelPos

func (tm *Motor) RunToRelPos() error

RunToRelPos executes the run-to-rel-pos command

func (*Motor) Speed

func (tm *Motor) Speed() (int, error)

Speed return speed

func (*Motor) SpeedSP

func (tm *Motor) SpeedSP() (int, error)

SpeedSP return speed_sp

func (*Motor) State

func (tm *Motor) State() (States, error)

State returns state

func (*Motor) Stop

func (tm *Motor) Stop() error

Stop executes the stop command

func (*Motor) StopAction

func (tm *Motor) StopAction() (string, error)

StopAction returns stop_action

func (*Motor) TimeSP

func (tm *Motor) TimeSP() (time.Duration, error)

TimeSP returns time_sp

type MotorDescriptor

type MotorDescriptor struct {
	Name        string
	Path        string
	Address     string
	DriverName  string
	Commands    []string
	CountPerRot int
	MaxSpeed    int
}

type Move

type Move struct {
	// contains filtered or unexported fields
}

Move collects several moves and actions of one motor

func NewMove

func NewMove(motor *Motor) *Move

NewMove creates a new mover instance

func (*Move) Error

func (m *Move) Error() error

func (*Move) ToRelPos

func (m *Move) ToRelPos(timeoutMSec int, pos int) error

ToRelPos moves to rel pos

func (*Move) WithSpeed

func (m *Move) WithSpeed(speed int) *Move

WithSpeed sets the speed for the next move

func (*Move) WithStopAction

func (m *Move) WithStopAction(sa string) *Move

WithStopAction sets the stop-action

type SensorDescriptor

type SensorDescriptor struct {
	Name       string
	Path       string
	Address    string
	DriverName string
	Modes      []string
	Mode       string
	NumValues  int
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(bind string) (*Server, error)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

type State

type State string

State wraps the state

const (
	StateIdle       State = ""
	StateRunning    State = "running"
	StateRamping    State = "ramping"
	StateHolding    State = "holding"
	StateOverloaded State = "overloaded"
	StateStalled    State = "stalled"
)

Possible values for state

func (State) String

func (s State) String() string

type States

type States []State

States wraps the state list

func (States) ContainsOneOf

func (ts States) ContainsOneOf(s ...State) bool

ContainsOneOf return if states contains one of the specified ones

type Touch

type Touch struct {
	// contains filtered or unexported fields
}

func (*Touch) Touched

func (t *Touch) Touched() bool

Directories

Path Synopsis
cmd
_lua command
_luar command
ev3lua command
ev3server command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址