2025-Robot
Robot code for 2025 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
VisionSubsystem Class Reference

#include <vision_subsystem.h>

Inheritance diagram for VisionSubsystem:

Public Types

enum class  InterpolationMode { LinearInterpolation , Polynomial , Trig }
 

Public Member Functions

 VisionSubsystem (const argos_lib::RobotInstance instance, SwerveDriveSubsystem *pDriveSubsystem)
 
LimelightTarget::tValues GetLeftCameraTargetValues ()
 Get the robot poses and latencies from left camera.
 
LimelightTarget::tValues GetRightCameraTargetValues ()
 Get the robot poses and latencies from right camera.
 
void SetPipeline (uint16_t tag)
 
void RequestFilterReset ()
 
void SetAimWhileMove (bool val)
 
bool IsAimWhileMoveActive ()
 
void SetOdometryAiming (bool val)
 
bool IsOdometryAimingActive ()
 
void SetEnableStaticRotation (bool val)
 
bool IsStaticRotationEnabled ()
 
void Periodic () override
 
void Disable ()
 it disables (duh)
 
std::optional< LimelightTarget::tValuesGetSeeingCamera (bool resample=false)
 
std::optional< ActiveVisionTargetgetWhichCamera (bool resample=true)
 
std::optional< whichCameragetLatestReefSide ()
 
std::optional< frc::Pose2d > GetClosestReefTagPoseInCamSpace (bool resample=false)
 
std::optional< frc::Translation2d > GetFieldCentricReefAlignmentError (bool resample=false)
 
std::optional< frc::Translation2d > GetRobotSpaceReefAlignmentError (bool resample=false)
 
std::optional< units::degree_t > GetOrientationCorrection (bool resample=false)
 
void SetLeftAlign (bool val)
 
void SetRightAlign (bool val)
 
void SetAlgaeAlign (bool val)
 
bool LeftAlignmentRequested ()
 
bool RightAlignmentRequested ()
 
bool AlgaeAlignmentRequested ()
 
void SetL1Active (bool val)
 
bool isL1Active ()
 
void SetAlgaeModeActive (bool val)
 
bool isAlgaeModeActive ()
 
bool robotAligned (bool resample=true)
 
std::optional< unitlessChassisSpeedsgetVisionAlignmentSpeeds (double scalingFactor=1.0)
 

Private Member Functions

void UpdateYaw (std::stop_token stopToken)
 

Private Attributes

const std::string leftCameraTableName = "/limelight-left"
 
const std::string rightCameraTableName = "/limelight-right"
 
CameraInterface m_cameraInterface
 Interface to limelight camera.
 
std::shared_ptr< nt::NetworkTable > m_leftCameraTable
 Cached NetworkTable pointer for left camera.
 
std::shared_ptr< nt::NetworkTable > m_rightCameraTable
 Cached NetworkTable pointer for right camera.
 
argos_lib::RobotInstance m_instance
 Contains either the competition bot or practice bot. Differentiates between the two.
 
SwerveDriveSubsystemm_pDriveSubsystem
 Pointer to drivetrain for reading some odometry.
 
LimelightTarget::tValues m_oldTargetValues
 The old robot poses and latencies.
 
bool m_usePolynomial
 specifies whether to use the polynomial to obtain shooter angle
 
bool m_useTrigonometry
 specifies whether to use the trigonometry to obtain shooter angle
 
bool m_isAimWhileMoveActive
 true if aiming trigger is pressed and locked
 
bool m_enableStaticRotation
 true if you want to rotate in the absence of translation input
 
bool m_isOdometryAimingActive
 true if we want to aim without vision
 
bool m_isLeftAlignActive
 true if left alignment is requested
 
bool m_isRightAlignActive
 true if right alignment is requested
 
bool m_isAlgaeAlignActive
 true if algae alignment is requested
 
bool m_isL1Active
 true if L1 is active
 
bool m_isAlgaeModeActive
 true if algae mode is active
 
bool m_isRotationGoodEnough
 true if robot rotation is good per alignment
 
int m_latestLeftHeartbeat
 
int m_latestRightHeartbeat
 
ActiveVisionTarget m_activeVisionTarget
 
argos_lib::Debouncer m_leftFresh
 
argos_lib::Debouncer m_rightFresh
 
std::optional< whichCameram_latestReefSide
 Side of robot that most recently saw the reef.
 
std::chrono::steady_clock::time_point m_latestReefSpotTime
 Time when reef was last seen by a camera.
 
argos_lib::NTSubscriber m_leftCameraFrameUpdateSubscriber
 Subscriber to manage all updates from left camera.
 
argos_lib::NTSubscriber m_rightCameraFrameUpdateSubscriber
 Subscriber to manage all updates from right camera.
 
std::jthread m_yawUpdateThread
 
wpi::log::StructLogEntry< frc::Pose2d > m_leftCameraMegaTag2PoseLogger
 
wpi::log::StructLogEntry< frc::Pose2d > m_rightCameraMegaTag2PoseLogger
 

Member Enumeration Documentation

◆ InterpolationMode

Enumerator
LinearInterpolation 
Polynomial 
Trig 

Constructor & Destructor Documentation

◆ VisionSubsystem()

VisionSubsystem::VisionSubsystem ( const argos_lib::RobotInstance instance,
SwerveDriveSubsystem * pDriveSubsystem )
Todo
Get good odometry from vision
Todo
Get good odometry from vision

Member Function Documentation

◆ AlgaeAlignmentRequested()

bool VisionSubsystem::AlgaeAlignmentRequested ( )
nodiscard

◆ Disable()

void VisionSubsystem::Disable ( )

it disables (duh)

◆ GetClosestReefTagPoseInCamSpace()

std::optional< frc::Pose2d > VisionSubsystem::GetClosestReefTagPoseInCamSpace ( bool resample = false)

◆ GetFieldCentricReefAlignmentError()

std::optional< frc::Translation2d > VisionSubsystem::GetFieldCentricReefAlignmentError ( bool resample = false)

◆ getLatestReefSide()

std::optional< whichCamera > VisionSubsystem::getLatestReefSide ( )

◆ GetLeftCameraTargetValues()

LimelightTarget::tValues VisionSubsystem::GetLeftCameraTargetValues ( )
nodiscard

Get the robot poses and latencies from left camera.

Returns
LimelightTarget::tValues

◆ GetOrientationCorrection()

std::optional< units::degree_t > VisionSubsystem::GetOrientationCorrection ( bool resample = false)

◆ GetRightCameraTargetValues()

LimelightTarget::tValues VisionSubsystem::GetRightCameraTargetValues ( )
nodiscard

Get the robot poses and latencies from right camera.

Returns
LimelightTarget::tValues

◆ GetRobotSpaceReefAlignmentError()

std::optional< frc::Translation2d > VisionSubsystem::GetRobotSpaceReefAlignmentError ( bool resample = false)

◆ GetSeeingCamera()

std::optional< LimelightTarget::tValues > VisionSubsystem::GetSeeingCamera ( bool resample = false)

◆ getVisionAlignmentSpeeds()

std::optional< unitlessChassisSpeeds > VisionSubsystem::getVisionAlignmentSpeeds ( double scalingFactor = 1.0)
nodiscard

◆ getWhichCamera()

std::optional< ActiveVisionTarget > VisionSubsystem::getWhichCamera ( bool resample = true)

◆ IsAimWhileMoveActive()

bool VisionSubsystem::IsAimWhileMoveActive ( )
nodiscard

◆ isAlgaeModeActive()

bool VisionSubsystem::isAlgaeModeActive ( )
nodiscard

◆ isL1Active()

bool VisionSubsystem::isL1Active ( )
nodiscard

◆ IsOdometryAimingActive()

bool VisionSubsystem::IsOdometryAimingActive ( )
nodiscard

◆ IsStaticRotationEnabled()

bool VisionSubsystem::IsStaticRotationEnabled ( )
nodiscard

◆ LeftAlignmentRequested()

bool VisionSubsystem::LeftAlignmentRequested ( )
nodiscard

◆ Periodic()

void VisionSubsystem::Periodic ( )
override

Will be called periodically whenever the CommandScheduler runs.

◆ RequestFilterReset()

void VisionSubsystem::RequestFilterReset ( )

◆ RightAlignmentRequested()

bool VisionSubsystem::RightAlignmentRequested ( )
nodiscard

◆ robotAligned()

bool VisionSubsystem::robotAligned ( bool resample = true)
nodiscard

◆ SetAimWhileMove()

void VisionSubsystem::SetAimWhileMove ( bool val)

◆ SetAlgaeAlign()

void VisionSubsystem::SetAlgaeAlign ( bool val)

◆ SetAlgaeModeActive()

void VisionSubsystem::SetAlgaeModeActive ( bool val)

◆ SetEnableStaticRotation()

void VisionSubsystem::SetEnableStaticRotation ( bool val)

◆ SetL1Active()

void VisionSubsystem::SetL1Active ( bool val)

◆ SetLeftAlign()

void VisionSubsystem::SetLeftAlign ( bool val)

◆ SetOdometryAiming()

void VisionSubsystem::SetOdometryAiming ( bool val)

◆ SetPipeline()

void VisionSubsystem::SetPipeline ( uint16_t tag)

◆ SetRightAlign()

void VisionSubsystem::SetRightAlign ( bool val)

◆ UpdateYaw()

void VisionSubsystem::UpdateYaw ( std::stop_token stopToken)
private

Member Data Documentation

◆ leftCameraTableName

const std::string VisionSubsystem::leftCameraTableName = "/limelight-left"
private

◆ m_activeVisionTarget

ActiveVisionTarget VisionSubsystem::m_activeVisionTarget
private

◆ m_cameraInterface

CameraInterface VisionSubsystem::m_cameraInterface
private

Interface to limelight camera.

◆ m_enableStaticRotation

bool VisionSubsystem::m_enableStaticRotation
private

true if you want to rotate in the absence of translation input

◆ m_instance

argos_lib::RobotInstance VisionSubsystem::m_instance
private

Contains either the competition bot or practice bot. Differentiates between the two.

◆ m_isAimWhileMoveActive

bool VisionSubsystem::m_isAimWhileMoveActive
private

true if aiming trigger is pressed and locked

◆ m_isAlgaeAlignActive

bool VisionSubsystem::m_isAlgaeAlignActive
private

true if algae alignment is requested

◆ m_isAlgaeModeActive

bool VisionSubsystem::m_isAlgaeModeActive
private

true if algae mode is active

◆ m_isL1Active

bool VisionSubsystem::m_isL1Active
private

true if L1 is active

◆ m_isLeftAlignActive

bool VisionSubsystem::m_isLeftAlignActive
private

true if left alignment is requested

◆ m_isOdometryAimingActive

bool VisionSubsystem::m_isOdometryAimingActive
private

true if we want to aim without vision

◆ m_isRightAlignActive

bool VisionSubsystem::m_isRightAlignActive
private

true if right alignment is requested

◆ m_isRotationGoodEnough

bool VisionSubsystem::m_isRotationGoodEnough
private

true if robot rotation is good per alignment

◆ m_latestLeftHeartbeat

int VisionSubsystem::m_latestLeftHeartbeat
private

◆ m_latestReefSide

std::optional<whichCamera> VisionSubsystem::m_latestReefSide
private

Side of robot that most recently saw the reef.

◆ m_latestReefSpotTime

std::chrono::steady_clock::time_point VisionSubsystem::m_latestReefSpotTime
private

Time when reef was last seen by a camera.

◆ m_latestRightHeartbeat

int VisionSubsystem::m_latestRightHeartbeat
private

◆ m_leftCameraFrameUpdateSubscriber

argos_lib::NTSubscriber VisionSubsystem::m_leftCameraFrameUpdateSubscriber
private

Subscriber to manage all updates from left camera.

◆ m_leftCameraMegaTag2PoseLogger

wpi::log::StructLogEntry<frc::Pose2d> VisionSubsystem::m_leftCameraMegaTag2PoseLogger
private

◆ m_leftCameraTable

std::shared_ptr<nt::NetworkTable> VisionSubsystem::m_leftCameraTable
private

Cached NetworkTable pointer for left camera.

◆ m_leftFresh

argos_lib::Debouncer VisionSubsystem::m_leftFresh
private

◆ m_oldTargetValues

LimelightTarget::tValues VisionSubsystem::m_oldTargetValues
private

The old robot poses and latencies.

◆ m_pDriveSubsystem

SwerveDriveSubsystem* VisionSubsystem::m_pDriveSubsystem
private

Pointer to drivetrain for reading some odometry.

◆ m_rightCameraFrameUpdateSubscriber

argos_lib::NTSubscriber VisionSubsystem::m_rightCameraFrameUpdateSubscriber
private

Subscriber to manage all updates from right camera.

◆ m_rightCameraMegaTag2PoseLogger

wpi::log::StructLogEntry<frc::Pose2d> VisionSubsystem::m_rightCameraMegaTag2PoseLogger
private

◆ m_rightCameraTable

std::shared_ptr<nt::NetworkTable> VisionSubsystem::m_rightCameraTable
private

Cached NetworkTable pointer for right camera.

◆ m_rightFresh

argos_lib::Debouncer VisionSubsystem::m_rightFresh
private

◆ m_usePolynomial

bool VisionSubsystem::m_usePolynomial
private

specifies whether to use the polynomial to obtain shooter angle

◆ m_useTrigonometry

bool VisionSubsystem::m_useTrigonometry
private

specifies whether to use the trigonometry to obtain shooter angle

◆ m_yawUpdateThread

std::jthread VisionSubsystem::m_yawUpdateThread
private

◆ rightCameraTableName

const std::string VisionSubsystem::rightCameraTableName = "/limelight-right"
private

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