control

package
v0.15.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package control package for feedback loop controls This is an Experimental package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block added in v0.0.8

type Block interface {
	// Reset will reset the control block to initial state. Returns an error on failure
	Reset(ctx context.Context) error

	// Next calculate the next output. Takes an array of float64 , a delta time returns True and the output value on success false otherwise
	Next(ctx context.Context, x []*Signal, dt time.Duration) ([]*Signal, bool)

	// UpdateConfig update the configuration of a pre-existing control block returns an error on failure
	UpdateConfig(ctx context.Context, config BlockConfig) error

	// Output returns the most recent valid value, useful for block aggregating signals
	Output(ctx context.Context) []*Signal

	// Config returns the underlying config for a Block
	Config(ctx context.Context) BlockConfig
}

Block interface for a control block.

type BlockConfig added in v0.0.8

type BlockConfig struct {
	Name      string             `json:"name"`       // Control Block name
	Type      controlBlockType   `json:"type"`       // Control Block type
	Attribute utils.AttributeMap `json:"attributes"` // Internal block configuration
	DependsOn []string           `json:"depends_on"` // List of blocks needed for calling Next
}

BlockConfig configuration of a given block.

type Config added in v0.0.8

type Config struct {
	Blocks    []BlockConfig `json:"blocks"`    // Blocks Control Block Config
	Frequency float64       `json:"frequency"` // Frequency loop Frequency
}

Config configuration of the control loop.

type Control

type Control interface {
	// OutputAt returns the Signal at the block name, error when the block doesn't exist
	OutputAt(ctx context.Context, name string) ([]*Signal, error)
	// ConfigAt returns the Configl at the block name, error when the block doesn't exist
	ConfigAt(ctx context.Context, name string) (BlockConfig, error)
	// BlockList returns the list of blocks in a control loop error when the list is empty
	BlockList(ctx context.Context) ([]string, error)
	// Frequency returns the loop's frequency
	Frequency(ctx context.Context) (float64, error)
	// Start starts the loop
	Start() error
	// Stop stops the loop
	Stop()
}

Control control interface can be used to interfact with a control loop to query signals, change config, start/stop the loop etc...

type Controllable

type Controllable interface {
	// SetState set the power and direction of the motor
	SetState(ctx context.Context, state []*Signal) error
	// Position returns the current encoder count value
	State(ctx context.Context) ([]float64, error)
}

Controllable controllable type for a DC motor.

type Loop added in v0.0.8

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

Loop holds the loop config.

func NewLoop added in v0.0.8

func NewLoop(logger logging.Logger, cfg Config, m Controllable) (*Loop, error)

NewLoop construct a new control loop for a specific endpoint.

func (*Loop) BlockList added in v0.0.8

func (l *Loop) BlockList(ctx context.Context) ([]string, error)

BlockList returns the list of blocks in a control loop error when the list is empty.

func (*Loop) ConfigAt added in v0.0.8

func (l *Loop) ConfigAt(ctx context.Context, name string) (BlockConfig, error)

ConfigAt returns the Configl at the block name, error when the block doesn't exist.

func (*Loop) Frequency added in v0.0.8

func (l *Loop) Frequency(ctx context.Context) (float64, error)

Frequency returns the loop's frequency.

func (*Loop) GetConfig added in v0.0.8

func (l *Loop) GetConfig(ctx context.Context) Config

GetConfig return the control loop config.

func (*Loop) GetTuning added in v0.15.0

func (l *Loop) GetTuning(ctx context.Context) bool

GetTuning returns the current tuning value.

func (*Loop) OutputAt added in v0.0.8

func (l *Loop) OutputAt(ctx context.Context, name string) ([]*Signal, error)

OutputAt returns the Signal at the block name, error when the block doesn't exist.

func (*Loop) SetConfigAt added in v0.0.8

func (l *Loop) SetConfigAt(ctx context.Context, name string, config BlockConfig) error

SetConfigAt returns the Configl at the block name, error when the block doesn't exist.

func (*Loop) SetTuning added in v0.15.0

func (l *Loop) SetTuning(ctx context.Context, val bool)

SetTuning sets the tuning variable.

func (*Loop) Start added in v0.0.8

func (l *Loop) Start() error

Start starts the loop.

func (*Loop) Stop added in v0.0.8

func (l *Loop) Stop()

Stop stops then loop.

type Signal

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

Signal holds any data passed between blocks.

func (*Signal) GetSignalValueAt

func (s *Signal) GetSignalValueAt(i int) float64

GetSignalValueAt returns the value of the signal at an index, threadsafe.

func (*Signal) SetSignalValueAt

func (s *Signal) SetSignalValueAt(i int, val float64)

SetSignalValueAt set the value of a signal at an index, threadsafe.

Jump to

Keyboard shortcuts

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