libstp
Robotics library for Botball
Loading...
Searching...
No Matches
libstp::odometry::IOdometry Struct Referenceabstract

#include <odometry.hpp>

Public Member Functions

virtual ~IOdometry ()=default
virtual void update (double dt)=0
virtual foundation::Pose getPose () const =0
virtual DistanceFromOrigin getDistanceFromOrigin () const =0
virtual double getHeading () const =0
virtual double getHeadingError (double target_heading_rad) const =0
virtual double getAbsoluteHeading () const =0
virtual double getPathLength () const =0
virtual void reset ()=0
virtual void setPreferredSource (OdometrySource source)
virtual OdometrySource getPreferredSource () const
virtual OdometrySource getActiveSource () const
virtual foundation::Pose getPoseFromSource (OdometrySource source) const
virtual bool isSourceAvailable (OdometrySource source) const
virtual foundation::Pose getInternalPose () const
virtual double getInternalHeading () const
virtual DistanceFromOrigin getInternalDistanceFromOrigin () const

Detailed Description

Definition at line 56 of file odometry.hpp.

Constructor & Destructor Documentation

◆ ~IOdometry()

virtual libstp::odometry::IOdometry::~IOdometry ( )
virtualdefault

Member Function Documentation

◆ getAbsoluteHeading()

virtual double libstp::odometry::IOdometry::getAbsoluteHeading ( ) const
nodiscardpure virtual

Get the absolute IMU heading that is unaffected by reset().

Returns
Heading in radians (CCW-positive). Stable across odometry resets.

◆ getActiveSource()

virtual OdometrySource libstp::odometry::IOdometry::getActiveSource ( ) const
inlinenodiscardvirtual

Which source currently backs getPose()/getHeading()/etc.

Implementations that have no external reference (mock, sim) always report ::Internal. Implementations that support a secondary source may still report ::Internal here when that source is not preferred or not currently available.

Returns
Active odometry source.

Definition at line 163 of file odometry.hpp.

◆ getDistanceFromOrigin()

virtual DistanceFromOrigin libstp::odometry::IOdometry::getDistanceFromOrigin ( ) const
nodiscardpure virtual

Get distance measurements from the origin (set by last reset)

Returns
Forward, lateral, and straight-line distances from origin

◆ getHeading()

virtual double libstp::odometry::IOdometry::getHeading ( ) const
nodiscardpure virtual

Get current heading (yaw angle) in radians relative to origin orientation

Returns
Heading in radians, range [-π, π] 0 = facing initial forward direction positive = rotated CCW from initial negative = rotated CW from initial

◆ getHeadingError()

virtual double libstp::odometry::IOdometry::getHeadingError ( double target_heading_rad) const
nodiscardpure virtual

Get heading error to reach a target heading

Computes the shortest angular path from current heading to target. Properly handles angle wraparound (e.g., from 170° to -170°).

Parameters
target_heading_radTarget heading in radians
Returns
Signed angular error in radians, range [-π, π]
  • Positive: turn CCW to reach target
  • Negative: turn CW to reach target

Use this as input to heading PID controllers.

◆ getInternalDistanceFromOrigin()

virtual DistanceFromOrigin libstp::odometry::IOdometry::getInternalDistanceFromOrigin ( ) const
inlinenodiscardvirtual

Get distance-from-origin computed from the internal pose, regardless of which source is currently active.

Returns
Forward, lateral, and straight-line distances from origin (m).

Definition at line 239 of file odometry.hpp.

◆ getInternalHeading()

virtual double libstp::odometry::IOdometry::getInternalHeading ( ) const
inlinenodiscardvirtual

Get the internal (on-board dead-reckoning) heading in radians, regardless of which source is currently active.

Returns
Internal heading in radians, range [-π, π].

Definition at line 229 of file odometry.hpp.

◆ getInternalPose()

virtual foundation::Pose libstp::odometry::IOdometry::getInternalPose ( ) const
inlinenodiscardvirtual

Get the internal (on-board dead-reckoning) pose, regardless of which source is currently active.

When no external source exists this is identical to getPose(). On the wombat platform this always returns the cheap STM32 estimate even when the accurate calibration board is driving getPose() — letting callers read both side by side to tune the internal model against the external reference.

Returns
Internal planar pose in world coordinates (meters / radians).

Definition at line 219 of file odometry.hpp.

◆ getPathLength()

virtual double libstp::odometry::IOdometry::getPathLength ( ) const
nodiscardpure virtual

Get the cumulative path length (odometer) in meters.

Monotonically increasing — NOT affected by reset(). Accumulates the Euclidean distance traveled each update cycle, regardless of direction (forward, strafe, curved).

Returns
Total distance traveled in meters since construction

◆ getPose()

virtual foundation::Pose libstp::odometry::IOdometry::getPose ( ) const
nodiscardpure virtual

Get the current pose estimate

Returns
Current planar pose expressed in world coordinates

◆ getPoseFromSource()

virtual foundation::Pose libstp::odometry::IOdometry::getPoseFromSource ( OdometrySource source) const
inlinenodiscardvirtual

Read a specific source's pose directly, regardless of the preferred or active source.

This lets callers passively sample an alternate source (for example the external calibration board) to compare against the one currently driving the motion system, WITHOUT switching the preferred source — which would re-route the whole motion system and hard-reset the odometry frame. Use this for tuning/measurement; use setPreferredSource() only when the motion system should actually follow the other source.

Implementations with no external reference return getInternalPose() for any source.

Parameters
sourceSource to read.
Returns
Pose from that source in world coordinates (meters / radians).

Definition at line 186 of file odometry.hpp.

◆ getPreferredSource()

virtual OdometrySource libstp::odometry::IOdometry::getPreferredSource ( ) const
inlinenodiscardvirtual

Get the caller-selected preferred source.

Implementations that do not support source switching always report ::Internal here.

Returns
Preferred odometry source.

Definition at line 148 of file odometry.hpp.

◆ isSourceAvailable()

virtual bool libstp::odometry::IOdometry::isSourceAvailable ( OdometrySource source) const
inlinenodiscardvirtual

Whether a given source is currently connected and usable as a reference, independent of which source is preferred or active.

Implementations with no external reference report true only for ::Internal.

Parameters
sourceSource to query.
Returns
True if the source can currently be read.

Definition at line 202 of file odometry.hpp.

◆ reset()

virtual void libstp::odometry::IOdometry::reset ( )
pure virtual

Reset the odometry to origin (zero position, identity orientation)

◆ setPreferredSource()

virtual void libstp::odometry::IOdometry::setPreferredSource ( OdometrySource source)
inlinevirtual

Select which source should back getPose()/getHeading()/etc. when available.

Implementations may fall back to ::Internal when the requested source is unavailable (for example when the calibration board is not connected). Callers can inspect getActiveSource() to see which source is actually in use right now.

Parameters
sourcePreferred odometry source.

Definition at line 135 of file odometry.hpp.

◆ update()

virtual void libstp::odometry::IOdometry::update ( double dt)
pure virtual

Update the odometry estimate with the latest sensor data

Parameters
dtTime delta since last update in seconds

The documentation for this struct was generated from the following file:
  • /home/runner/work/raccoon-lib/raccoon-lib/modules/libstp-hal/include/hal/odometry.hpp