Documentation
¶
Overview ¶
Package sensors defines interfaces for sensors used by viam cartographer
Index ¶
- Constants
- Variables
- func SetupDeps(lidarName, movementSensorName TestSensor) resource.Dependencies
- type Lidar
- type MovementSensor
- type MovementSensorProperties
- type TestSensor
- type TimedIMUReadingResponse
- type TimedLidar
- type TimedLidarReadingResponse
- type TimedMovementSensor
- type TimedMovementSensorReadingResponse
- type TimedOdometerReadingResponse
Constants ¶
const BadTime = "NOT A TIME"
BadTime can be used to represent something that should cause an error while parsing it as a time.
Variables ¶
var ( // ErrMovementSensorNeitherIMUNorOdometer denotes that the provided movement sensor does neither support // an IMU nor a movement sensor. ErrMovementSensorNeitherIMUNorOdometer = errors.New("'movement_sensor' must either support both LinearAcceleration and " + "AngularVelocity, or both Position and Orientation") // ErrNoValidReadingObtained denotes that the attempt to obtain a valid IMU or odometer reading failed. ErrNoValidReadingObtained = errors.New("could not obtain a reading that satisfies the time tolerance requirement") )
var ( // TestTimestamp can be used to test specific timestamps provided by a replay sensor. TestTimestamp = time.Now().UTC().Format("2006-01-02T15:04:05.999999Z") // TestLinAcc is the successful mock linear acceleration result used for testing. TestLinAcc = r3.Vector{X: 1, Y: 2, Z: 3} // TestAngVel is the successful mock angular velocity result used for testing. TestAngVel = spatialmath.AngularVelocity{X: 1.1, Y: .5, Z: 0} // TestPosition is the successful mock position result used for testing. TestPosition = geo.NewPoint(5, 4) // TestOrientation is the successful mock orientation result used for testing. TestOrientation = &spatialmath.Quaternion{Real: 0.1, Imag: -0.2, Jmag: 2.5, Kmag: -9.1} )
Functions ¶
func SetupDeps ¶
func SetupDeps(lidarName, movementSensorName TestSensor) resource.Dependencies
SetupDeps returns the dependencies based on the lidar and movement sensor names passed as arguments.
Types ¶
type Lidar ¶
Lidar represents a LIDAR sensor.
func (Lidar) DataFrequencyHz ¶
DataFrequencyHz returns the data rate in ms of the lidar.
func (Lidar) TimedLidarReading ¶
func (lidar Lidar) TimedLidarReading(ctx context.Context) (TimedLidarReadingResponse, error)
TimedLidarReading returns data from the lidar and the time the reading is from & whether it was a replay sensor or not.
type MovementSensor ¶
type MovementSensor struct {
// contains filtered or unexported fields
}
MovementSensor represents a movement sensor.
func (*MovementSensor) DataFrequencyHz ¶
func (ms *MovementSensor) DataFrequencyHz() int
DataFrequencyHz returns the data rate in ms of the movement sensor.
func (*MovementSensor) Name ¶
func (ms *MovementSensor) Name() string
Name returns the name of the movement sensor.
func (*MovementSensor) Properties ¶
func (ms *MovementSensor) Properties() MovementSensorProperties
Properties returns MovementSensorProperties, which holds information about whether or not an IMU and/or odometer are supported.
func (*MovementSensor) TimedMovementSensorReading ¶
func (ms *MovementSensor) TimedMovementSensorReading(ctx context.Context) (TimedMovementSensorReadingResponse, error)
TimedMovementSensorReading returns data from the movement sensor and the time the reading is from & whether it was a replay sensor or not.
type MovementSensorProperties ¶
MovementSensorProperties contains information whether or not an IMU and/or odometer are supported.
type TestSensor ¶
type TestSensor string
TestSensor represents sensors used for testing.
const ( // InvalidSensorTestErrMsg represents an error message that indicates that the sensor is invalid. InvalidSensorTestErrMsg = "invalid test sensor" // GoodLidar is a lidar that works as expected and returns a pointcloud. GoodLidar TestSensor = "good_lidar" // WarmingUpLidar is a lidar whose NextPointCloud function returns a "warming up" error. WarmingUpLidar TestSensor = "warming_up_lidar" // LidarWithErroringFunctions is a lidar whose functions return errors. LidarWithErroringFunctions TestSensor = "lidar_with_erroring_functions" // LidarWithInvalidProperties is a lidar whose properties are invalid. LidarWithInvalidProperties TestSensor = "lidar_with_invalid_properties" // GibberishLidar is a lidar that can't be found in the dependencies. GibberishLidar TestSensor = "gibberish_lidar" // NoLidar is a lidar that represents that no lidar is set up or added. NoLidar TestSensor = "" // ReplayLidar is a lidar that works as expected and returns a pointcloud. ReplayLidar TestSensor = "replay_lidar" // InvalidReplayLidar is a lidar whose meta timestamp is invalid. InvalidReplayLidar TestSensor = "invalid_replay_lidar" // FinishedReplayLidar is a lidar whose NextPointCloud function returns an end of dataset error. FinishedReplayLidar TestSensor = "finished_replay_lidar" // GoodIMU is an IMU that works as expected and returns linear acceleration and angular velocity values. GoodIMU TestSensor = "good_imu" // IMUWithErroringFunctions is an IMU whose functions return errors. IMUWithErroringFunctions TestSensor = "imu_with_erroring_functions" // ReplayIMU is an IMU that works as expected and returns linear acceleration and angular velocity values. ReplayIMU TestSensor = "replay_imu" // InvalidReplayIMU is an IMU whose meta timestamp is invalid. InvalidReplayIMU TestSensor = "invalid_replay_imu" // FinishedReplayIMU is an IMU whose LinearAcceleration and AngularVelocity functions return an end of // dataset error. FinishedReplayIMU TestSensor = "finished_replay_imu" // GoodOdometer is an odometer that works as expected and returns position and orientation values. GoodOdometer TestSensor = "good_odometer" // OdometerWithErroringFunctions is an Odometer whose functions return errors. OdometerWithErroringFunctions TestSensor = "odometer_with_erroring_functions" // ReplayOdometer is an odometer that works as expected and returns position and orientation values. ReplayOdometer TestSensor = "replay_odometer" // InvalidReplayOdometer is an odometer whose meta timestamp is invalid. InvalidReplayOdometer TestSensor = "invalid_replay_odometer" // FinishedReplayOdometer is an odometer whose Position and Orientation functions return an end of // dataset error. FinishedReplayOdometer TestSensor = "finished_replay_odometer" // MovementSensorNotIMUNotOdometer is a movement sensor that does neither support an IMU nor an odometer. MovementSensorNotIMUNotOdometer TestSensor = "movement_sensor_not_imu_not_odometer" // GoodMovementSensorBothIMUAndOdometer is a movement sensor that supports both an IMU nor an odometer. GoodMovementSensorBothIMUAndOdometer TestSensor = "good_movement_sensor_imu_and_odometer" // MovementSensorBothIMUAndOdometerWithErroringFunctions is a movement sensor whose functions return errors. MovementSensorBothIMUAndOdometerWithErroringFunctions TestSensor = "movement_sensor_imu_and_odometer_with_erroring_functions" // MovementSensorWithErroringPropertiesFunc is a movement sensor whose Properties function returns an error. MovementSensorWithErroringPropertiesFunc TestSensor = "movement_sensor_with_erroring_properties_function" // MovementSensorWithInvalidProperties is a movement sensor whose properties are invalid. MovementSensorWithInvalidProperties TestSensor = "movement_sensor_with_invalid_properties" // GibberishMovementSensor is a movement sensor that can't be found in the dependencies. GibberishMovementSensor TestSensor = "gibberish_movement_sensor" // NoMovementSensor is a movement sensor that represents that no movement sensor is set up or added. NoMovementSensor TestSensor = "" // ReplayMovementSensorBothIMUAndOdometer is a replay movement sensor that supports both an IMU nor an odometer. ReplayMovementSensorBothIMUAndOdometer TestSensor = "replay_movement_sensor_imu_and_odometer" // InvalidReplayMovementSensorBothIMUAndOdometer is a replay movement sensor that supports both an IMU nor an odometer. InvalidReplayMovementSensorBothIMUAndOdometer TestSensor = "invalid_replay_movement_sensor_imu_and_odometer" // FinishedReplayMovementSensor is a movement sensor whose LinearAcceleration, AngularVelocity, Position, and Orientation // functions return an end of dataset error. FinishedReplayMovementSensor TestSensor = "finished_replay_movement_sensor" )
type TimedIMUReadingResponse ¶
type TimedIMUReadingResponse struct { AngularVelocity spatialmath.AngularVelocity // We set the values in radians/s instead of deg/s LinearAcceleration r3.Vector ReadingTime time.Time }
TimedIMUReadingResponse represents an IMU sensor reading with a time.
type TimedLidar ¶
type TimedLidar interface { Name() string DataFrequencyHz() int TimedLidarReading(ctx context.Context) (TimedLidarReadingResponse, error) }
TimedLidar describes a sensor that reports the time the reading is from & whether or not it is rom a replay sensor.
type TimedLidarReadingResponse ¶
type TimedLidarReadingResponse struct { Reading []byte ReadingTime time.Time TestIsReplaySensor bool }
TimedLidarReadingResponse represents a lidar reading with a time & allows the caller to know if the reading is from a replay camera.
type TimedMovementSensor ¶
type TimedMovementSensor interface { Name() string DataFrequencyHz() int TimedMovementSensorReading(ctx context.Context) (TimedMovementSensorReadingResponse, error) Properties() MovementSensorProperties }
TimedMovementSensor describes a sensor that reports the time the reading is from & whether or not it is from a replay sensor.
func NewMovementSensor ¶
func NewMovementSensor( ctx context.Context, deps resource.Dependencies, movementSensorName string, dataFrequencyHz int, logger logging.Logger, ) (TimedMovementSensor, error)
NewMovementSensor returns a new movement sensor.
type TimedMovementSensorReadingResponse ¶
type TimedMovementSensorReadingResponse struct { TimedIMUResponse *TimedIMUReadingResponse TimedOdometerResponse *TimedOdometerReadingResponse TestIsReplaySensor bool }
TimedMovementSensorReadingResponse contains IMU and odometer sensor reading responses as well as information about whether or not the readings are from a replay movement sensor.
type TimedOdometerReadingResponse ¶
type TimedOdometerReadingResponse struct { Position *geo.Point Orientation spatialmath.Orientation ReadingTime time.Time }
TimedOdometerReadingResponse represents an odometer sensor reading with a time.