motorutil

package
v0.0.0-...-ac0bd47 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package motorutil provides utilities for motor handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetAll

func ResetAll() error

ResetAll resets all the connected motors in the classes tacho-motor, servo-motor and dc-motor. Each motor class uses a different reset or stop command. ResetAll sends "reset" to tacho-motors, "float" to servo-motors and "stop" to dc-motors.

Types

type Errors

type Errors []error

Errors is a collection of errors.

func (Errors) Error

func (e Errors) Error() string

type Steering

type Steering struct {
	// Left and Right are the left and right motors to be
	// used by the steering module.
	Left, Right *ev3dev.TachoMotor

	// Timeout is the timeout for waiting for motors to
	// return to a non-driving state.
	//
	// See ev3dev.Wait documentation for timeout behaviour.
	Timeout time.Duration
	// contains filtered or unexported fields
}

Steering implements a paired-motor steering unit similar to an EV3-G steering block.

Errors ocurring during steering operations are sticky. They are returned either by a call to Err or Wait.

func (*Steering) Err

func (s *Steering) Err() error

Err returns the error state of the Steering and clears it.

func (*Steering) SetStopAction

func (s *Steering) SetStopAction(action string) *Steering

SetStopAction sets the stop action to be used when a stop command is issued to the TachoMotor. SetStopAction returns on the first error encountered.

func (*Steering) SteerCounts

func (s *Steering) SteerCounts(speed, turn, counts int) *Steering

SteerCounts steers in the given turn for the given tacho counts and at the specified speed. The valid range of turn is -100 (hard left) to +100 (hard right). If the product of counts and speed is negative, the turn will be made in reverse.

See the ev3dev.SetSpeedSetPoint and ev3dev.SetPositionSetPoint documentation for speed and count behaviour.

func (*Steering) SteerDuration

func (s *Steering) SteerDuration(speed, turn int, d time.Duration) *Steering

SteerDuration steers in the given turn for the given duration, d, and at the specified speed. The valid range of turn is -100 (hard left) to +100 (hard right). If speed is negative, the turn will be made in reverse.

See the ev3dev.SetSpeedSetpoint and ev3dev.SetTimeSetpoint documentation for speed and duration behaviour.

func (*Steering) StopAction

func (s *Steering) StopAction() (string, error)

StopAction returns the stop action used when a stop command is issued to the TachoMotor devices held by the Steering. StopAction returns an error if the two motors do not agree on the stop action.

func (*Steering) StopActions

func (s *Steering) StopActions() ([]string, error)

StopActions returns the available stop actions for the TachoMotor. StopAction returns an error and the intersection of available actions if the two motors do not agree on the available stop actions.

func (*Steering) Wait

func (s *Steering) Wait() error

Wait waits for the last steering operation to complete. A non-nil error will either implement the Cause method, which may be used to determine the underlying cause, or be an Errors holding errors that implement the Cause method.

Jump to

Keyboard shortcuts

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