2022-Robot
Robot code for 2022 FRC Season by Argos, FRC team #1756
Loading...
Searching...
No Matches
argos_lib::NTMotorPIDTuner Class Reference

Allows user to set PID parameters from network tables and update the motor configurations on updates. Also monitors status information from motors to aid tuning. More...

#include <nt_motor_pid_tuner.h>

Public Member Functions

 NTMotorPIDTuner (const std::string &tableName, std::initializer_list< ctre::phoenix::motorcontrol::can::BaseTalon * > motors, uint pidSlot, ClosedLoopSensorConversions sensorConversions={})
 Construct a new NTMotorPIDTuner object. More...
 
 ~NTMotorPIDTuner ()
 Destroy the NTMotorPIDTuner object. More...
 

Private Member Functions

void UpdateClosedLoopMonitoringThread ()
 Update statuses from all motors. More...
 

Private Attributes

argos_lib::NTSubscriber m_updateSubscriber
 Subscriber to manage all updates from user inputs through network tables. More...
 
const std::vector< ctre::phoenix::motorcontrol::can::BaseTalon * > m_pMotors
 Motors being configured and monitored. More...
 
const uint m_pidSlot
 PID slot index actively used on motors. More...
 
std::shared_ptr< nt::NetworkTable > m_pntTable
 Network table containing status and tuning keys. More...
 
ClosedLoopSensorConversions m_sensorConversions
 Sensor conversion factors used to translate raw sensor readings. More...
 
std::mutex m_threadMutex
 Lock to aid notifying thread of stop. More...
 
std::condition_variable m_threadStopCv
 Used to notify thread to stop at shutdown. More...
 
std::thread m_statusUpdateThread
 Thread monitoring motors. More...
 

Detailed Description

Allows user to set PID parameters from network tables and update the motor configurations on updates. Also monitors status information from motors to aid tuning.

Note
This runs a background thread to read statuses of motors without calling repeatedly

Constructor & Destructor Documentation

◆ NTMotorPIDTuner()

NTMotorPIDTuner::NTMotorPIDTuner ( const std::string &  tableName,
std::initializer_list< ctre::phoenix::motorcontrol::can::BaseTalon * >  motors,
uint  pidSlot,
ClosedLoopSensorConversions  sensorConversions = {} 
)

Construct a new NTMotorPIDTuner object.

Parameters
tableNameRoot table in which to make tuning and status keys
motorsPointers to motors that should be monitored and configured. Can be one motor if only one motor uses the control loop parameters
pidSlotPID slot to save tunes into
sensorConversionsSensor conversion factors to make status values human readable

◆ ~NTMotorPIDTuner()

NTMotorPIDTuner::~NTMotorPIDTuner ( )

Destroy the NTMotorPIDTuner object.

Member Function Documentation

◆ UpdateClosedLoopMonitoringThread()

void NTMotorPIDTuner::UpdateClosedLoopMonitoringThread ( )
private

Update statuses from all motors.

Member Data Documentation

◆ m_pidSlot

const uint argos_lib::NTMotorPIDTuner::m_pidSlot
private

PID slot index actively used on motors.

◆ m_pMotors

const std::vector<ctre::phoenix::motorcontrol::can::BaseTalon*> argos_lib::NTMotorPIDTuner::m_pMotors
private

Motors being configured and monitored.

◆ m_pntTable

std::shared_ptr<nt::NetworkTable> argos_lib::NTMotorPIDTuner::m_pntTable
private

Network table containing status and tuning keys.

◆ m_sensorConversions

ClosedLoopSensorConversions argos_lib::NTMotorPIDTuner::m_sensorConversions
private

Sensor conversion factors used to translate raw sensor readings.

◆ m_statusUpdateThread

std::thread argos_lib::NTMotorPIDTuner::m_statusUpdateThread
private

Thread monitoring motors.

◆ m_threadMutex

std::mutex argos_lib::NTMotorPIDTuner::m_threadMutex
private

Lock to aid notifying thread of stop.

◆ m_threadStopCv

std::condition_variable argos_lib::NTMotorPIDTuner::m_threadStopCv
private

Used to notify thread to stop at shutdown.

◆ m_updateSubscriber

argos_lib::NTSubscriber argos_lib::NTMotorPIDTuner::m_updateSubscriber
private

Subscriber to manage all updates from user inputs through network tables.


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