movementsensor

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: AGPL-3.0 Imports: 20 Imported by: 14

Documentation

Overview

Package movementsensor defines the interfaces of a MovementSensor

Index

Constants

View Source
const SubtypeName = "movement_sensor"

SubtypeName is a constant that identifies the component resource API string "movement_sensor".

Variables

View Source
var (
	// ErrMethodUnimplementedAccuracy returns error if the Accuracy method is unimplemented.
	ErrMethodUnimplementedAccuracy = errors.New("Accuracy Unimplemented")
	// ErrMethodUnimplementedPosition returns error if the Position method is unimplemented.
	ErrMethodUnimplementedPosition = errors.New("Position Unimplemented")
	// ErrMethodUnimplementedOrientation returns error if the Orientation method is unimplemented.
	ErrMethodUnimplementedOrientation = errors.New("Orientation Unimplemented")
	// ErrMethodUnimplementedLinearVelocity returns error if the LinearVelocity method is unimplemented.
	ErrMethodUnimplementedLinearVelocity = errors.New("LinearVelocity Unimplemented")
	// ErrMethodUnimplementedAngularVelocity returns error if the AngularVelocity method is unimplemented.
	ErrMethodUnimplementedAngularVelocity = errors.New("AngularVelocity Unimplemented")
	// ErrMethodUnimplementedCompassHeading returns error if the CompassHeading method is unimplemented.
	ErrMethodUnimplementedCompassHeading = errors.New("CompassHeading Unimplemented")
	// ErrMethodUnimplementedReadings returns error if the Readings method is unimplemented.
	ErrMethodUnimplementedReadings = errors.New("Readings Unimplemented")
	// ErrMethodUnimplementedProperties returns error if the Properties method is unimplemented.
	ErrMethodUnimplementedProperties = errors.New("Properties Unimplemented")
	// ErrMethodUnimplementedLinearAcceleration returns error if Linear Acceleration is unimplemented.
	ErrMethodUnimplementedLinearAcceleration = errors.New("linear acceleration unimplemented")
)
View Source
var API = resource.APINamespaceRDK.WithComponentType(SubtypeName)

API is a variable that identifies the component resource API.

Functions

func AddressReadError added in v0.2.49

func AddressReadError(err error, address byte, bus string) error

AddressReadError returns a standard error for when we cannot read from an I2C bus.

func DefaultAPIReadings added in v0.12.0

func DefaultAPIReadings(ctx context.Context, g MovementSensor, extra map[string]interface{}) (map[string]interface{}, error)

DefaultAPIReadings is a helper for getting all readings from a MovementSensor.

func Named

func Named(name string) resource.Name

Named is a helper for getting the named MovementSensor's typed resource name.

func NamesFromRobot

func NamesFromRobot(r robot.Robot) []string

NamesFromRobot is a helper for getting all MovementSensor names from the given Robot.

func NewRPCServiceServer added in v0.2.36

func NewRPCServiceServer(coll resource.APIResourceCollection[MovementSensor]) interface{}

NewRPCServiceServer constructs an MovementSensor gRPC service serviceServer.

func PMTKAddChk added in v0.5.0

func PMTKAddChk(data []byte) []byte

PMTKAddChk adds PMTK checksums to commands by XORing the bytes together.

func PMTKChecksum added in v0.5.0

func PMTKChecksum(data []byte) byte

PMTKChecksum calculates the checksum of a byte array by performing an XOR operation on each byte.

func PropertiesToProtoResponse added in v0.3.0

func PropertiesToProtoResponse(
	features *Properties,
) (*pb.GetPropertiesResponse, error)

PropertiesToProtoResponse takes a properties struct and converts it to a GetPropertiesResponse.

func UnexpectedDeviceError added in v0.2.49

func UnexpectedDeviceError(address, response byte, deviceName string) error

UnexpectedDeviceError returns a standard error for we cannot find the expected device at the given address.

Types

type LastCompassHeading added in v0.7.3

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

LastCompassHeading store the last valid compass heading seen by the movement sensor. This is really just an atomic float64, analogous to the atomic ints provided in the "sync/atomic" package.

func NewLastCompassHeading added in v0.7.3

func NewLastCompassHeading() LastCompassHeading

NewLastCompassHeading create a new LastCompassHeading.

func (*LastCompassHeading) GetLastCompassHeading added in v0.7.3

func (lch *LastCompassHeading) GetLastCompassHeading() float64

GetLastCompassHeading returns the last compass heading stored.

func (*LastCompassHeading) SetLastCompassHeading added in v0.7.3

func (lch *LastCompassHeading) SetLastCompassHeading(compassheading float64)

SetLastCompassHeading sets lastcompassheading to the value given in the function.

type LastError added in v0.2.19

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

LastError is an object that stores recent errors. If there have been sufficiently many recent errors, you can retrieve the most recent one.

func NewLastError added in v0.2.32

func NewLastError(size, threshold int) LastError

NewLastError creates a LastError object which will let you retrieve the most recent error if at least `threshold` of the most recent `size` items put into it are non-nil.

func (*LastError) Get added in v0.2.19

func (le *LastError) Get() error

Get returns the most-recently-stored non-nil error if we've had enough recent errors. If we're going to return a non-nil error, we also wipe out all other data so we don't return the same error again next time.

func (*LastError) Set added in v0.2.19

func (le *LastError) Set(err error)

Set stores an error to be retrieved later.

type LastPosition added in v0.3.0

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

LastPosition stores the last position seen by the movement sensor.

func NewLastPosition added in v0.3.0

func NewLastPosition() LastPosition

NewLastPosition creates a new point that's (NaN, NaN) go-staticcheck.

func (*LastPosition) ArePointsEqual added in v0.3.0

func (lp *LastPosition) ArePointsEqual(p1, p2 *geo.Point) bool

ArePointsEqual checks if two geo.Point instances are equal.

func (*LastPosition) GetLastPosition added in v0.3.0

func (lp *LastPosition) GetLastPosition() *geo.Point

GetLastPosition returns the last known position.

func (*LastPosition) IsPositionNaN added in v0.3.0

func (lp *LastPosition) IsPositionNaN(p *geo.Point) bool

IsPositionNaN checks if a geo.Point in math.NaN().

func (*LastPosition) IsZeroPosition added in v0.3.0

func (lp *LastPosition) IsZeroPosition(p *geo.Point) bool

IsZeroPosition checks if a geo.Point represents the zero position (0, 0).

func (*LastPosition) SetLastPosition added in v0.3.0

func (lp *LastPosition) SetLastPosition(position *geo.Point)

SetLastPosition updates the last known position.

type MovementSensor

type MovementSensor interface {
	resource.Sensor
	resource.Resource
	Position(ctx context.Context, extra map[string]interface{}) (*geo.Point, float64, error)                // (lat, long), altitude (m)
	LinearVelocity(ctx context.Context, extra map[string]interface{}) (r3.Vector, error)                    // m / sec
	AngularVelocity(ctx context.Context, extra map[string]interface{}) (spatialmath.AngularVelocity, error) // deg / sec
	LinearAcceleration(ctx context.Context, extra map[string]interface{}) (r3.Vector, error)
	CompassHeading(ctx context.Context, extra map[string]interface{}) (float64, error) // [0->360)
	Orientation(ctx context.Context, extra map[string]interface{}) (spatialmath.Orientation, error)
	Properties(ctx context.Context, extra map[string]interface{}) (*Properties, error)
	Accuracy(ctx context.Context, extra map[string]interface{}) (map[string]float32, error)
}

A MovementSensor reports information about the robot's direction, position and speed.

func FromDependencies

func FromDependencies(deps resource.Dependencies, name string) (MovementSensor, error)

FromDependencies is a helper for getting the named movementsensor from a collection of dependencies.

func FromRobot

func FromRobot(r robot.Robot, name string) (MovementSensor, error)

FromRobot is a helper for getting the named MovementSensor from the given Robot.

func NewClientFromConn

func NewClientFromConn(
	ctx context.Context,
	conn rpc.ClientConn,
	remoteName string,
	name resource.Name,
	logger logging.Logger,
) (MovementSensor, error)

NewClientFromConn constructs a new Client from connection passed in.

type Properties

type Properties struct {
	PositionSupported           bool
	OrientationSupported        bool
	CompassHeadingSupported     bool
	LinearVelocitySupported     bool
	AngularVelocitySupported    bool
	LinearAccelerationSupported bool
}

Properties is a structure representing features of a movementsensor. The order is in terms of order of derivatives in time with position, orientation, compassheading at the top (zeroth derivative) linear and angular velocities next (first derivative) linear acceleration last (second derivative).

func ProtoFeaturesToProperties added in v0.3.0

func ProtoFeaturesToProperties(resp *pb.GetPropertiesResponse) *Properties

ProtoFeaturesToProperties takes a GetPropertiesResponse and returns an equivalent Properties struct.

Directories

Path Synopsis
Package adxl345 implements the MovementSensor interface for the ADXL345 accelerometer.
Package adxl345 implements the MovementSensor interface for the ADXL345 accelerometer.
Package dualgps implements a movement sensor that calculates compass heading from two gps movement sensors
Package dualgps implements a movement sensor that calculates compass heading from two gps movement sensors
Package fake is a fake MovementSensor for testing
Package fake is a fake MovementSensor for testing
Package gpsnmea implements an NMEA serial gps.
Package gpsnmea implements an NMEA serial gps.
Package gpsrtkpmtk implements a gps using serial connection
Package gpsrtkpmtk implements a gps using serial connection
Package gpsrtkserial implements a gps using serial connection
Package gpsrtkserial implements a gps using serial connection
Package imuvectornav implements a component for a vectornav IMU.
Package imuvectornav implements a component for a vectornav IMU.
Package imuwit implements wit imus.
Package imuwit implements wit imus.
Package merged implements a movementsensor combining movement data from other sensors
Package merged implements a movementsensor combining movement data from other sensors
Package mpu6050 implements the movementsensor interface for an MPU-6050 6-axis accelerometer.
Package mpu6050 implements the movementsensor interface for an MPU-6050 6-axis accelerometer.
Package register registers all relevant MovementSensors
Package register registers all relevant MovementSensors
Package replay implements a replay movement sensor that can return motion data.
Package replay implements a replay movement sensor that can return motion data.
Package rtkutils implements necessary functions to set and return NTRIP information here.
Package rtkutils implements necessary functions to set and return NTRIP information here.
Package wheeledodometry implements an odometery estimate from an encoder wheeled base.
Package wheeledodometry implements an odometery estimate from an encoder wheeled base.

Jump to

Keyboard shortcuts

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