CTRE Phoenix 6 C++ 25.3.1
Loading...
Searching...
No Matches
ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread Class Reference

Performs swerve module updates in a separate thread to minimize latency. More...

#include <ctre/phoenix6/swerve/impl/SwerveDrivetrainImpl.hpp>

Public Member Functions

 OdometryThread (SwerveDrivetrainImpl &drivetrain)
 
 ~OdometryThread ()
 
void Start ()
 Starts the odometry thread.
 
void Stop ()
 Stops the odometry thread.
 
bool IsOdometryValid () const
 Check if the odometry is currently valid.
 
void SetThreadPriority (int priority)
 Sets the odometry thread priority to a real time priority under the specified priority level.
 

Protected Member Functions

void Run ()
 

Protected Attributes

SwerveDrivetrainImpl_drivetrain
 
std::thread _thread
 
std::mutex _threadMtx
 
std::atomic< bool > _isRunning = false
 
std::vector< BaseStatusSignal * > _allSignals
 
LinearFilter< units::second_t > _lowPass = LinearFilter<units::second_t>::MovingAverage(kLowPassTaps)
 
bool _lastTimeValid = false
 
units::second_t _lastTime {}
 
units::second_t _averageLoopTime {}
 
std::atomic< int32_t > _successfulDaqs {}
 
std::atomic< int32_t > _failedDaqs {}
 
std::atomic< int > _threadPriorityToSet = START_THREAD_PRIORITY
 
int _lastThreadPriority = START_THREAD_PRIORITY
 

Static Protected Attributes

static constexpr int START_THREAD_PRIORITY = 1
 
static constexpr int kLowPassTaps = 50
 

Detailed Description

Performs swerve module updates in a separate thread to minimize latency.

Constructor & Destructor Documentation

◆ OdometryThread()

ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::OdometryThread ( SwerveDrivetrainImpl & drivetrain)

◆ ~OdometryThread()

ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::~OdometryThread ( )
inline

Member Function Documentation

◆ IsOdometryValid()

bool ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::IsOdometryValid ( ) const
inline

Check if the odometry is currently valid.

Returns
True if odometry is valid

◆ Run()

void ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::Run ( )
protected

◆ SetThreadPriority()

void ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::SetThreadPriority ( int priority)
inline

Sets the odometry thread priority to a real time priority under the specified priority level.

Parameters
priorityPriority level to set the odometry thread to. This is a value between 0 and 99, with 99 indicating higher priority and 0 indicating lower priority.

◆ Start()

void ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::Start ( )
inline

Starts the odometry thread.

◆ Stop()

void ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::Stop ( )
inline

Stops the odometry thread.

Member Data Documentation

◆ _allSignals

std::vector<BaseStatusSignal *> ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_allSignals
protected

◆ _averageLoopTime

units::second_t ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_averageLoopTime {}
protected

◆ _drivetrain

SwerveDrivetrainImpl* ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_drivetrain
protected

◆ _failedDaqs

std::atomic<int32_t> ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_failedDaqs {}
protected

◆ _isRunning

std::atomic<bool> ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_isRunning = false
protected

◆ _lastThreadPriority

int ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_lastThreadPriority = START_THREAD_PRIORITY
protected

◆ _lastTime

units::second_t ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_lastTime {}
protected

◆ _lastTimeValid

bool ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_lastTimeValid = false
protected

◆ _lowPass

LinearFilter<units::second_t> ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_lowPass = LinearFilter<units::second_t>::MovingAverage(kLowPassTaps)
protected

◆ _successfulDaqs

std::atomic<int32_t> ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_successfulDaqs {}
protected

◆ _thread

std::thread ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_thread
protected

◆ _threadMtx

std::mutex ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_threadMtx
protected

◆ _threadPriorityToSet

std::atomic<int> ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::_threadPriorityToSet = START_THREAD_PRIORITY
protected

◆ kLowPassTaps

int ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::kLowPassTaps = 50
staticconstexprprotected

◆ START_THREAD_PRIORITY

int ctre::phoenix6::swerve::impl::SwerveDrivetrainImpl::OdometryThread::START_THREAD_PRIORITY = 1
staticconstexprprotected

The documentation for this class was generated from the following file: