libstp
Robotics library for Botball
Loading...
Searching...
No Matches
libstp::foundation::SpeedModeContext Class Reference

#include <speed_mode_context.hpp>

Public Member Functions

bool isSpeedModeEnabled () const noexcept
 True when SpeedMode is active (BEMF disabled, no cm precision).
void setSpeedModeEnabled (bool enabled) noexcept
void assertBemfAvailable (const char *context) const
 SpeedModeContext (const SpeedModeContext &)=delete
SpeedModeContext & operator= (const SpeedModeContext &)=delete
 SpeedModeContext (SpeedModeContext &&)=delete
SpeedModeContext & operator= (SpeedModeContext &&)=delete

Static Public Member Functions

static SpeedModeContext & instance ()
 Access the process-wide instance.

Detailed Description

Process-wide flag indicating whether SpeedMode is active.

SpeedMode disables the firmware-side BEMF closed-loop control: the STM32 stops sampling BEMF (gaining ~10% top speed) but in exchange gives up encoder-velocity feedback and therefore cm-accurate distance / angle termination. While SpeedMode is on the motion primitives must not be used with a distance- or angle-based goal; the program is expected to terminate motions via explicit until-conditions (sensors, timeouts, ...).

The flag lives in libstp-foundation so both the drive layer (MotorAdapter, which switches between BEMF-velocity and open-loop PWM) and the motion layer (which validates that motions with a positional goal are not started while SpeedMode is active) can query it without introducing a cross-module dependency.

Reads and writes use atomic operations so the Python step that flips SpeedMode (in response to an LCM ACK from the firmware) does not need to synchronize against the motion control loop with an extra mutex.

Definition at line 29 of file speed_mode_context.hpp.

Constructor & Destructor Documentation

◆ SpeedModeContext() [1/2]

libstp::foundation::SpeedModeContext::SpeedModeContext ( const SpeedModeContext & )
delete

◆ SpeedModeContext() [2/2]

libstp::foundation::SpeedModeContext::SpeedModeContext ( SpeedModeContext && )
delete

Member Function Documentation

◆ assertBemfAvailable()

void libstp::foundation::SpeedModeContext::assertBemfAvailable ( const char * context) const

Throws std::logic_error if SpeedMode is currently active.

context is included in the error message so the user knows which call site triggered the failure.

◆ instance()

SpeedModeContext & libstp::foundation::SpeedModeContext::instance ( )
static

Access the process-wide instance.

◆ isSpeedModeEnabled()

bool libstp::foundation::SpeedModeContext::isSpeedModeEnabled ( ) const
nodiscardnoexcept

True when SpeedMode is active (BEMF disabled, no cm precision).

◆ operator=() [1/2]

SpeedModeContext & libstp::foundation::SpeedModeContext::operator= ( const SpeedModeContext & )
delete

◆ operator=() [2/2]

SpeedModeContext & libstp::foundation::SpeedModeContext::operator= ( SpeedModeContext && )
delete

◆ setSpeedModeEnabled()

void libstp::foundation::SpeedModeContext::setSpeedModeEnabled ( bool enabled)
noexcept

Flip the SpeedMode flag. Intended to be called from the SetSpeedMode Python step after the firmware ACK arrived.


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