Documentation ¶
Overview ¶
Package movementsensor defines the interfaces of a MovementSensor
Index ¶
- Constants
- Variables
- func AddressReadError(err error, address byte, bus string) error
- func ArePointsEqual(p1, p2 *geo.Point) bool
- func DefaultAPIReadings(ctx context.Context, g MovementSensor, extra map[string]interface{}) (map[string]interface{}, error)
- func IsPositionNaN(p *geo.Point) bool
- func IsZeroPosition(p *geo.Point) bool
- func Named(name string) resource.Name
- func NamesFromRobot(r robot.Robot) []string
- func NewRPCServiceServer(coll resource.APIResourceCollection[MovementSensor]) interface{}
- func PMTKAddChk(data []byte) []byte
- func PMTKChecksum(data []byte) byte
- func PropertiesToProtoResponse(features *Properties) (*pb.GetPropertiesResponse, error)
- func UnexpectedDeviceError(address, response byte, deviceName string) error
- type Accuracy
- type LastCompassHeading
- type LastError
- type LastPosition
- type MovementSensor
- type Properties
Constants ¶
const SubtypeName = "movement_sensor"
SubtypeName is a constant that identifies the component resource API string "movement_sensor".
Variables ¶
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") )
var API = resource.APINamespaceRDK.WithComponentType(SubtypeName)
API is a variable that identifies the component resource API.
Functions ¶
func AddressReadError ¶ added in v0.2.49
AddressReadError returns a standard error for when we cannot read from an I2C bus.
func ArePointsEqual ¶ added in v0.20.0
ArePointsEqual checks if two geo.Point instances are equal.
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 IsPositionNaN ¶ added in v0.20.0
IsPositionNaN checks if a geo.Point in math.NaN().
func IsZeroPosition ¶ added in v0.20.0
IsZeroPosition checks if a geo.Point represents the zero position (0, 0).
func NamesFromRobot ¶
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
PMTKAddChk adds PMTK checksums to commands by XORing the bytes together.
func PMTKChecksum ¶ added in v0.5.0
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
UnexpectedDeviceError returns a standard error for we cannot find the expected device at the given address.
Types ¶
type Accuracy ¶ added in v0.20.0
type Accuracy struct { AccuracyMap map[string]float32 Hdop float32 Vdop float32 NmeaFix int32 CompassDegreeError float32 }
Accuracy defines the precision and reliability metrics of a movement sensor. It includes various parameters to assess the sensor's accuracy in different dimensions.
Fields:
AccuracyMap: A mapping of specific measurement parameters to their accuracy values. The keys are string identifiers for each measurement (e.g., "Hdop", "Vdop"), and the values are their corresponding accuracy levels as float32.
Hdop: Horizontal Dilution of Precision (HDOP) value. It indicates the level of accuracy of horizontal measurements. Lower values represent higher precision.
Vdop: Vertical Dilution of Precision (VDOP) value. Similar to HDOP, it denotes the accuracy level of vertical measurements. Lower VDOP values signify better precision.
NmeaFix: An integer value representing the quality of the NMEA fix. Higher values generally indicate a better quality fix, with specific meanings depending on the sensor and context. Generally a fix of 1 or 2 lends to large position errors, ideally we want a fix of 4-5. Other fixes are unsuitable for outdoor navigation. The meaning of each fix value is documented here https://docs.novatel.com/OEM7/Content/Logs/GPGGA.htm#GPSQualityIndicators
CompassDegreeError: The estimated error in compass readings, measured in degrees. It signifies the deviation or uncertainty in the sensor's compass measurements. A lower value implies a more accurate compass direction.
func UnimplementedAccuracies ¶ added in v0.21.0
UnimplementedAccuracies returns accuracy values that will not show up on movement sensor's RC card or be useable for a caller of the GetAccuracies method. The RC card currently continuously polls accuracies, so a nil error must be rturned from the GetAccuracies call. It contains NaN definitiions for accuracies returned in floats, an invalid integer value for the NMEAFix of a gps and an empty map of other accuracies.
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
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.
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) GetLastPosition ¶ added in v0.3.0
func (lp *LastPosition) GetLastPosition() *geo.Point
GetLastPosition returns the last known position.
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{}) (*Accuracy, 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.
Source Files ¶
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 gps.
|
Package gpsnmea implements an NMEA 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. |