dimensionengineering

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package dimensionengineering contains implementations of the dimensionengineering motor controls

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMotor

func NewMotor(ctx context.Context, c *Config, logger golog.Logger) (motor.LocalMotor, error)

NewMotor returns a Sabertooth driven motor.

Types

type Config

type Config struct {
	SerialDevice string `json:"serial_device"` // path to /dev/ttyXXXX file
	Channel      int    `json:"channel"`       // 1/2
	// TestChan is a fake "serial" path for test use only
	TestChan chan []byte `json:"-,omitempty"`
	Address  int         `json:"address"` // 128-135
}

Config adds DimensionEngineering-specific config options.

func (*Config) Validate

func (cfg *Config) Validate(path string) error

Validate ensures all parts of the config are valid.

type Motor

type Motor struct {
	Channel int
	// contains filtered or unexported fields
}

Motor is a single axis/motor/component instance.

func (*Motor) Close

func (m *Motor) Close()

Close stops the motor and marks the axis inactive.

func (*Motor) DoCommand

func (m *Motor) DoCommand(ctx context.Context, cmd map[string]interface{}) (map[string]interface{}, error)

DoCommand executes additional commands beyond the Motor{} interface.

func (*Motor) GoFor

func (m *Motor) GoFor(ctx context.Context, rpm, revolutions float64, extra map[string]interface{}) error

GoFor Not supported.

func (*Motor) GoTillStop

func (m *Motor) GoTillStop(ctx context.Context, rpm float64, stopFunc func(ctx context.Context) bool) error

GoTillStop moves a motor until stopped by the controller (due to switch or function) or stopFunc.

func (*Motor) GoTo

func (m *Motor) GoTo(ctx context.Context, rpm, position float64, extra map[string]interface{}) error

GoTo instructs the motor to go to a specific position (provided in revolutions from home/zero), at a specific speed. Regardless of the directionality of the RPM this function will move the motor towards the specified target/position.

func (*Motor) IsMoving

func (m *Motor) IsMoving(ctx context.Context) (bool, error)

IsMoving returns whether the motor is currently moving.

func (*Motor) IsPowered

func (m *Motor) IsPowered(ctx context.Context, extra map[string]interface{}) (bool, error)

IsPowered returns if the motor is currently on or off.

func (*Motor) Position

func (m *Motor) Position(ctx context.Context, extra map[string]interface{}) (float64, error)

Position reports the position in revolutions.

func (*Motor) Properties

func (m *Motor) Properties(ctx context.Context, extra map[string]interface{}) (map[motor.Feature]bool, error)

Properties returns the additional features supported by this motor.

func (*Motor) ResetZeroPosition

func (m *Motor) ResetZeroPosition(ctx context.Context, offset float64, extra map[string]interface{}) error

ResetZeroPosition defines the current position to be zero (+/- offset).

func (*Motor) SetPower

func (m *Motor) SetPower(ctx context.Context, powerPct float64, extra map[string]interface{}) error

SetPower instructs the motor to go in a specific direction at a percentage of power between -1 and 1. Scaled to MaxRPM.

func (*Motor) Stop

func (m *Motor) Stop(ctx context.Context, extra map[string]interface{}) error

Stop turns the power to the motor off immediately, without any gradual step down.

Jump to

Keyboard shortcuts

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