30#include <sfTk/sfToolkit.h>
33#include <sfTk/sfTkII2C.h>
182 sfTkError_t
begin(sfTkII2C *commBus =
nullptr);
205 sfTkError_t
calibrateImu(uint8_t numSamples = 255,
bool waitUntilDone =
true);
Class for the SparkFun Qwiic Optical Tracking Odometry Sensor (OTOS). Includes methods to communicate...
Definition: sfDevOTOS.h:174
static constexpr uint8_t kRegAccHH
Definition: sfDevOTOS.h:435
static constexpr float kMaxScalar
Maximum scalar value for the linear and angular scalars.
Definition: sfDevOTOS.h:368
static constexpr float kRadianToDegree
Definition: sfDevOTOS.h:461
static constexpr uint8_t kRegAccYH
Definition: sfDevOTOS.h:433
void setAngularUnit(sfe_otos_angular_unit_t unit)
Sets the angular unit used by all methods using a pose.
Definition: sfDevOTOS.cpp:196
static constexpr uint8_t kRegAccXL
Definition: sfDevOTOS.h:430
sfTkError_t getVelocity(sfe_otos_pose2d_t &pose)
Gets the velocity measured by the OTOS.
Definition: sfDevOTOS.cpp:308
static constexpr uint8_t kRegSelfTest
Definition: sfDevOTOS.h:410
static constexpr uint8_t kRegVelXH
Definition: sfDevOTOS.h:425
sfTkError_t setOffset(sfe_otos_pose2d_t &pose)
Sets the offset of the OTOS. This is useful if your sensor is mounted off-center from a robot....
Definition: sfDevOTOS.cpp:293
static constexpr float kRpsToInt16
Definition: sfDevOTOS.h:491
sfTkError_t getAcceleration(sfe_otos_pose2d_t &pose)
Gets the acceleration measured by the OTOS.
Definition: sfDevOTOS.cpp:313
static constexpr uint8_t kRegPosHL
Definition: sfDevOTOS.h:422
static constexpr uint8_t kRegVelHH
Definition: sfDevOTOS.h:429
static constexpr uint8_t kRegAccStdXH
Definition: sfDevOTOS.h:449
float _meterToUnit
Definition: sfDevOTOS.h:398
sfTkError_t begin(sfTkII2C *commBus=nullptr)
Begins the Qwiic OTOS and verifies it is connected.
Definition: sfDevOTOS.cpp:38
static constexpr uint8_t kRegOffHH
Definition: sfDevOTOS.h:416
static constexpr uint8_t kRegPosYL
Definition: sfDevOTOS.h:420
static constexpr float kInt16ToMpss
Definition: sfDevOTOS.h:480
static constexpr uint8_t kRegAccStdXL
Definition: sfDevOTOS.h:448
static constexpr float kRadToInt16
Definition: sfDevOTOS.h:485
sfTkError_t getStatus(sfe_otos_status_t &status)
Gets the status register from the OTOS, which includes warnings and errors reported by the sensor.
Definition: sfDevOTOS.cpp:283
sfTkError_t getAccelerationStdDev(sfe_otos_pose2d_t &pose)
Gets the standard deviation of the measured acceleration.
Definition: sfDevOTOS.cpp:328
sfTkError_t getPosition(sfe_otos_pose2d_t &pose)
Gets the position measured by the OTOS.
Definition: sfDevOTOS.cpp:298
static constexpr uint8_t kRegAccStdYH
Definition: sfDevOTOS.h:451
void setLinearUnit(sfe_otos_linear_unit_t unit)
Sets the linear unit used by all methods using a pose.
Definition: sfDevOTOS.cpp:178
static constexpr uint8_t kRegPosYH
Definition: sfDevOTOS.h:421
static constexpr uint8_t kRegPosHH
Definition: sfDevOTOS.h:423
sfTkError_t getAngularScalar(float &scalar)
Gets the angular scalar used by the OTOS.
Definition: sfDevOTOS.cpp:237
static constexpr uint8_t kRegVelYH
Definition: sfDevOTOS.h:427
static constexpr uint8_t kRegImuCalib
Definition: sfDevOTOS.h:407
float _radToUnit
Definition: sfDevOTOS.h:399
static constexpr float kMpssToInt16
Definition: sfDevOTOS.h:479
static constexpr uint8_t kRegScalarLinear
Definition: sfDevOTOS.h:405
sfTkError_t writePoseRegs(uint8_t reg, sfe_otos_pose2d_t &pose, float xyToRaw, float hToRaw)
Definition: sfDevOTOS.cpp:424
static constexpr uint8_t kRegVelHL
Definition: sfDevOTOS.h:428
static constexpr uint8_t kRegOffYL
Definition: sfDevOTOS.h:413
sfTkError_t getVelocityStdDev(sfe_otos_pose2d_t &pose)
Gets the standard deviation of the measured velocity.
Definition: sfDevOTOS.cpp:323
static constexpr uint8_t kRegStatus
Definition: sfDevOTOS.h:417
sfTkError_t getImuCalibrationProgress(uint8_t &numSamples)
Gets the progress of the IMU calibration. Used for asynchronous calibration with calibrateImu()
Definition: sfDevOTOS.cpp:167
static constexpr float kInt16ToRpss
Definition: sfDevOTOS.h:498
sfTkError_t getVersionInfo(sfe_otos_version_t &hwVersion, sfe_otos_version_t &fwVersion)
Gets the hardware and firmware version numbers from the OTOS.
Definition: sfDevOTOS.cpp:76
static constexpr uint8_t kRegVelStdYL
Definition: sfDevOTOS.h:444
static constexpr float kRpssToInt16
Definition: sfDevOTOS.h:497
sfe_otos_linear_unit_t _linearUnit
Definition: sfDevOTOS.h:393
void regsToPose(uint8_t *rawData, sfe_otos_pose2d_t &pose, float rawToXY, float rawToH)
Definition: sfDevOTOS.cpp:434
static constexpr float kInt16ToRad
Definition: sfDevOTOS.h:486
static constexpr uint8_t kRegProductId
Definition: sfDevOTOS.h:402
sfTkError_t readPoseRegs(uint8_t reg, sfe_otos_pose2d_t &pose, float rawToXY, float rawToH)
Definition: sfDevOTOS.cpp:404
sfTkError_t setPosition(sfe_otos_pose2d_t &pose)
Sets the position measured by the OTOS. This is useful if your robot does not start at the origin,...
Definition: sfDevOTOS.cpp:303
static constexpr uint8_t kRegPosStdHH
Definition: sfDevOTOS.h:441
static constexpr float kMeterToInt16
Definition: sfDevOTOS.h:467
sfTkError_t isConnected()
Checks if the device is connected.
Definition: sfDevOTOS.cpp:55
static constexpr uint8_t kRegPosXH
Definition: sfDevOTOS.h:419
static constexpr uint8_t kRegVelYL
Definition: sfDevOTOS.h:426
static constexpr uint8_t kRegScalarAngular
Definition: sfDevOTOS.h:406
static constexpr uint8_t kRegAccStdHL
Definition: sfDevOTOS.h:452
static constexpr uint8_t kRegAccStdHH
Definition: sfDevOTOS.h:453
static constexpr uint8_t kRegPosStdXL
Definition: sfDevOTOS.h:436
sfTkError_t getPosVelAccStdDev(sfe_otos_pose2d_t &pos, sfe_otos_pose2d_t &vel, sfe_otos_pose2d_t &acc)
Gets the standard deviation of the measured position, velocity, and acceleration in a single burst re...
Definition: sfDevOTOS.cpp:355
sfTkError_t getSignalProcessConfig(sfe_otos_signal_process_config_t &config)
Gets the signal processing configuration from the OTOS.
Definition: sfDevOTOS.cpp:271
static constexpr float kMpsToInt16
Definition: sfDevOTOS.h:473
static constexpr uint8_t kRegReset
Definition: sfDevOTOS.h:408
sfTkError_t setLinearScalar(float scalar)
Sets the linear scalar used by the OTOS. Can be used to compensate for scaling issues with the sensor...
Definition: sfDevOTOS.cpp:224
static constexpr float kDegreeToRadian
Definition: sfDevOTOS.h:462
static constexpr uint8_t kRegFwVersion
Definition: sfDevOTOS.h:404
static constexpr uint8_t kRegAccHL
Definition: sfDevOTOS.h:434
sfTkError_t selfTest()
Performs a self test of the OTOS.
Definition: sfDevOTOS.cpp:97
static constexpr uint8_t kRegVelXL
Definition: sfDevOTOS.h:424
sfTkError_t getPosVelAcc(sfe_otos_pose2d_t &pos, sfe_otos_pose2d_t &vel, sfe_otos_pose2d_t &acc)
Gets the position, velocity, and acceleration measured by the OTOS in a single burst read.
Definition: sfDevOTOS.cpp:333
sfTkError_t getLinearScalar(float &scalar)
Gets the linear scalar used by the OTOS.
Definition: sfDevOTOS.cpp:209
sfTkError_t getPositionStdDev(sfe_otos_pose2d_t &pose)
Gets the standard deviation of the measured position.
Definition: sfDevOTOS.cpp:318
static constexpr uint8_t kRegOffXL
Definition: sfDevOTOS.h:411
sfTkError_t setSignalProcessConfig(sfe_otos_signal_process_config_t &config)
Sets the signal processing configuration on the OTOS. This is primarily useful for creating and testi...
Definition: sfDevOTOS.cpp:277
sfe_otos_angular_unit_t _angularUnit
Definition: sfDevOTOS.h:394
sfTkError_t getOffset(sfe_otos_pose2d_t &pose)
Gets the offset of the OTOS.
Definition: sfDevOTOS.cpp:288
sfe_otos_linear_unit_t getLinearUnit()
Gets the linear unit used by all methods using a pose.
Definition: sfDevOTOS.cpp:173
static constexpr uint8_t kRegAccStdYL
Definition: sfDevOTOS.h:450
sfTkII2C * _commBus
Definition: sfDevOTOS.h:388
sfTkError_t resetTracking()
Resets the tracking algorithm, which resets the position to the origin, but can also be used to recov...
Definition: sfDevOTOS.cpp:265
static constexpr uint8_t kRegAccXH
Definition: sfDevOTOS.h:431
static constexpr uint8_t kRegAccYL
Definition: sfDevOTOS.h:432
static constexpr uint8_t kRegVelStdYH
Definition: sfDevOTOS.h:445
static constexpr uint8_t kRegPosStdYH
Definition: sfDevOTOS.h:439
sfTkError_t setAngularScalar(float scalar)
Sets the angular scalar used by the OTOS. Can be used to compensate for scaling issues with the senso...
Definition: sfDevOTOS.cpp:252
sfTkError_t getPosVelAccAndStdDev(sfe_otos_pose2d_t &pos, sfe_otos_pose2d_t &vel, sfe_otos_pose2d_t &acc, sfe_otos_pose2d_t &posStdDev, sfe_otos_pose2d_t &velStdDev, sfe_otos_pose2d_t &accStdDev)
Gets the position, velocity, acceleration, and standard deviation of each in a single burst read.
Definition: sfDevOTOS.cpp:377
static constexpr float kInt16ToMeter
Definition: sfDevOTOS.h:468
static constexpr float kInt16ToRps
Definition: sfDevOTOS.h:492
static constexpr uint8_t kRegOffHL
Definition: sfDevOTOS.h:415
void poseToRegs(uint8_t *rawData, sfe_otos_pose2d_t &pose, float xyToRaw, float hToRaw)
Definition: sfDevOTOS.cpp:447
static constexpr uint8_t kRegSignalProcess
Definition: sfDevOTOS.h:409
static constexpr uint8_t kRegOffXH
Definition: sfDevOTOS.h:412
static constexpr uint8_t kRegVelStdXH
Definition: sfDevOTOS.h:443
static constexpr float kInchToMeter
Definition: sfDevOTOS.h:460
sfTkError_t calibrateImu(uint8_t numSamples=255, bool waitUntilDone=true)
Calibrates the IMU on the OTOS, which removes the accelerometer and gyroscope offsets.
Definition: sfDevOTOS.cpp:128
static constexpr float kInt16ToMps
Definition: sfDevOTOS.h:474
static constexpr float kMinScalar
Minimum scalar value for the linear and angular scalars.
Definition: sfDevOTOS.h:365
static constexpr uint8_t kRegVelStdXL
Definition: sfDevOTOS.h:442
static constexpr uint8_t kRegPosStdHL
Definition: sfDevOTOS.h:440
static constexpr float kMeterToInch
Definition: sfDevOTOS.h:459
sfe_otos_angular_unit_t getAngularUnit()
Gets the angular unit used by all methods using a pose.
Definition: sfDevOTOS.cpp:191
static constexpr uint8_t kRegOffYH
Definition: sfDevOTOS.h:414
static constexpr uint8_t kProductId
Definition: sfDevOTOS.h:456
static constexpr uint8_t kRegHwVersion
Definition: sfDevOTOS.h:403
static constexpr uint8_t kRegVelStdHL
Definition: sfDevOTOS.h:446
static constexpr uint8_t kDefaultAddress
Default I2C addresses of the Qwiic OTOS.
Definition: sfDevOTOS.h:362
sfDevOTOS()
Default constructor, only initializes member variables.
Definition: sfDevOTOS.cpp:31
static constexpr uint8_t kRegPosXL
Definition: sfDevOTOS.h:418
static constexpr uint8_t kRegPosStdXH
Definition: sfDevOTOS.h:437
virtual void delayMs(uint32_t ms)=0
static constexpr uint8_t kRegVelStdHH
Definition: sfDevOTOS.h:447
static constexpr uint8_t kRegPosStdYL
Definition: sfDevOTOS.h:438
sfe_otos_linear_unit_t
Enumerations for linear units used by the OTOS driver.
Definition: sfDevOTOS.h:54
@ kSfeOtosLinearUnitMeters
Meters.
Definition: sfDevOTOS.h:56
@ kSfeOtosLinearUnitInches
Inches (default)
Definition: sfDevOTOS.h:59
sfe_otos_angular_unit_t
Enumerations for angular units used by the OTOS driver.
Definition: sfDevOTOS.h:65
@ kSfeOtosAngularUnitRadians
Radians.
Definition: sfDevOTOS.h:67
@ kSfeOtosAngularUnitDegrees
Degrees (default)
Definition: sfDevOTOS.h:70
2D pose structure, including x and y coordinates and heading angle
Definition: sfDevOTOS.h:40
float y
Y value.
Definition: sfDevOTOS.h:45
float x
X value.
Definition: sfDevOTOS.h:42
float h
Heading value.
Definition: sfDevOTOS.h:48
Self test register bit fields.
Definition: sfDevOTOS.h:119
uint8_t inProgress
Returns 1 while the self test is in progress.
Definition: sfDevOTOS.h:126
uint8_t fail
Returns 1 if the self test failed.
Definition: sfDevOTOS.h:132
uint8_t start
Write 1 to start the self test.
Definition: sfDevOTOS.h:123
uint8_t value
Raw register value.
Definition: sfDevOTOS.h:139
uint8_t reserved
Reserved bits, do not use.
Definition: sfDevOTOS.h:135
uint8_t pass
Returns 1 if the self test passed.
Definition: sfDevOTOS.h:129
Signal process config register bit fields.
Definition: sfDevOTOS.h:91
uint8_t reserved
Reserved bits, do not use.
Definition: sfDevOTOS.h:110
uint8_t enAcc
Whether to feed the accelerometer data to the Kalman filters.
Definition: sfDevOTOS.h:99
uint8_t enRot
Whether to rotate the IMU and optical sensor data by the heading angle.
Definition: sfDevOTOS.h:103
uint8_t value
Raw register value.
Definition: sfDevOTOS.h:114
uint8_t enLut
Whether to use the internal lookup table calibration for the optical sensor.
Definition: sfDevOTOS.h:96
uint8_t enVar
Whether to use the correct sensor variance in the Kalman filters, or use 0 varaince to effectively di...
Definition: sfDevOTOS.h:107
Status register bit fields.
Definition: sfDevOTOS.h:144
uint8_t value
Raw register value.
Definition: sfDevOTOS.h:166
uint8_t warnTiltAngle
Returns 1 if the tilt angle threshold has been exceeded. While set, the accelerometer data is ignored...
Definition: sfDevOTOS.h:149
uint8_t errorLsm
Returns 1 if the IMU has a fatal error.
Definition: sfDevOTOS.h:162
uint8_t warnOpticalTracking
Returns 1 if the optical tracking is unreliable. While set, only the IMU data is used for tracking un...
Definition: sfDevOTOS.h:153
uint8_t errorPaa
Returns 1 if the optical sensor has a fatal error.
Definition: sfDevOTOS.h:159
uint8_t reserved
Reserved bits, do not use.
Definition: sfDevOTOS.h:156
Version register bit fields.
Definition: sfDevOTOS.h:75
uint8_t major
Major version number.
Definition: sfDevOTOS.h:82
uint8_t minor
Minor version number.
Definition: sfDevOTOS.h:79
uint8_t value
Raw register value.
Definition: sfDevOTOS.h:86