2024-Robot
Robot code for 2024 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, ShooterSubsystem *pShooterSubsytem)
 
std::optional< units::inch_t > GetDistanceToSpeaker ()
 Get the distance to the tag.
 
std::optional< units::degree_t > GetOrientationToSpeaker ()
 Get the distance to the tag.
 
std::optional< units::inch_t > GetCalculatedDistanceToSpeaker ()
 Get the distance to the tag calculated with the Ty (vertical offset)
 
LimelightTarget::tValues GetPrimaryCameraTargetValues ()
 Get the robot poses and latencies.
 
LimelightTarget::tValues GetSecondaryCameraTargetValues ()
 Get the robot poses and latencies from secondary camera.
 
std::optional< units::degree_t > GetHorizontalOffsetToTarget ()
 Get the current offset to the retroreflective tape.
 
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)
 
units::degree_t getShooterAngle (units::inch_t distance, const InterpolationMode mode)
 
std::optional< units::degree_t > getShooterAngle ()
 
std::optional< units::degree_t > getShooterOffset ()
 
units::degree_t getFeederAngle ()
 
std::optional< units::degree_t > getFeederOffset ()
 
std::optional< units::degree_t > getShooterAngleWithInertia (double medialSpeedPct)
 
std::optional< double > getRotationSpeedWithInertia (double lateralSpeedPct)
 
std::optional< units::degree_t > getFeederAngleWithInertia (double medialSpeedPct)
 
std::optional< double > getFeedOffsetWithInertia (double lateralSpeedPct)
 
units::angular_velocity::revolutions_per_minute_t getShooterSpeed (const units::inch_t distance, const InterpolationMode mode) const
 
std::optional< units::angular_velocity::revolutions_per_minute_t > getShooterSpeed ()
 
std::optional< units::inch_t > GetDistanceToTrap ()
 
std::optional< units::inch_t > GetDistanceToStageCenter ()
 
std::optional< units::degree_t > GetHorizontalOffsetToTrap ()
 
std::optional< units::degree_t > GetOrientationToTrap ()
 
std::optional< whichCameragetWhichCamera (bool forFeeder=false)
 
std::optional< LimelightTarget::tValuesGetSeeingCamera (bool forFeeder=false)
 

Private Member Functions

void UpdateYaw (std::stop_token stopToken)
 

Private Attributes

CameraInterface m_cameraInterface
 Interface to limelight 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.
 
ShooterSubsystemm_pShooterSubsystem
 Pointer to shooter subsystem for reading aiming mode.
 
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
 
argos_lib::InterpolationMap< decltype(shooterRange::shooterAngle.front().inVal), shooterRange::shooterAngle.size(), decltype(shooterRange::shooterAngle.front().outVal)> m_shooterAngleMap
 Maps a distance to a shooter pitch angle.
 
argos_lib::InterpolationMap< decltype(shooterRange::shooterSpeed.front().inVal), shooterRange::shooterSpeed.size(), decltype(shooterRange::shooterSpeed.front().outVal)> m_shooterSpeedMap
 Maps a distance to a shooter speed.
 
argos_lib::InterpolationMap< decltype(shooterRange::feederAngle.front().inVal), shooterRange::feederAngle.size(), decltype(shooterRange::feederAngle.front().outVal)> m_feederAngleMap
 Maps a distance to a feeder pitch angle.
 
argos_lib::NTSubscriber m_primaryCameraFrameUpdateSubscriber
 Subscriber to manage all updates from primary camera.
 
argos_lib::NTSubscriber m_secondaryCameraFrameUpdateSubscriber
 Subscriber to manage all updates from secondary camera.
 
std::jthread m_yawUpdateThread
 
wpi::log::StructLogEntry< frc::Pose2d > m_frontCameraMegaTag2PoseLogger
 
wpi::log::StructLogEntry< frc::Pose2d > m_rearCameraMegaTag2PoseLogger
 

Static Private Attributes

static constexpr char primaryCameraTableName [12] {"/limelight"}
 
static constexpr char secondaryCameraTableName [18] {"/limelight-front"}
 

Member Enumeration Documentation

◆ InterpolationMode

Enumerator
LinearInterpolation 
Polynomial 
Trig 

Constructor & Destructor Documentation

◆ VisionSubsystem()

VisionSubsystem::VisionSubsystem ( const argos_lib::RobotInstance  instance,
SwerveDriveSubsystem pDriveSubsystem,
ShooterSubsystem pShooterSubsytem 
)

Member Function Documentation

◆ Disable()

void VisionSubsystem::Disable ( )

it disables (duh)

◆ GetCalculatedDistanceToSpeaker()

std::optional< units::inch_t > VisionSubsystem::GetCalculatedDistanceToSpeaker ( )

Get the distance to the tag calculated with the Ty (vertical offset)

Returns
Desired distance in inches.

◆ GetDistanceToSpeaker()

std::optional< units::inch_t > VisionSubsystem::GetDistanceToSpeaker ( )

Get the distance to the tag.

Returns
Desired distance in inches.

◆ GetDistanceToStageCenter()

std::optional< units::inch_t > VisionSubsystem::GetDistanceToStageCenter ( )

◆ GetDistanceToTrap()

std::optional< units::inch_t > VisionSubsystem::GetDistanceToTrap ( )

◆ getFeederAngle()

units::degree_t VisionSubsystem::getFeederAngle ( )

◆ getFeederAngleWithInertia()

std::optional< units::degree_t > VisionSubsystem::getFeederAngleWithInertia ( double  medialSpeedPct)

◆ getFeederOffset()

std::optional< units::degree_t > VisionSubsystem::getFeederOffset ( )

◆ getFeedOffsetWithInertia()

std::optional< double > VisionSubsystem::getFeedOffsetWithInertia ( double  lateralSpeedPct)

◆ GetHorizontalOffsetToTarget()

std::optional< units::degree_t > VisionSubsystem::GetHorizontalOffsetToTarget ( )

Get the current offset to the retroreflective tape.

Returns
units::degree_t

◆ GetHorizontalOffsetToTrap()

std::optional< units::degree_t > VisionSubsystem::GetHorizontalOffsetToTrap ( )

◆ GetOrientationToSpeaker()

std::optional< units::degree_t > VisionSubsystem::GetOrientationToSpeaker ( )

Get the distance to the tag.

Returns
Desired distance in inches.

◆ GetOrientationToTrap()

std::optional< units::degree_t > VisionSubsystem::GetOrientationToTrap ( )

◆ GetPrimaryCameraTargetValues()

LimelightTarget::tValues VisionSubsystem::GetPrimaryCameraTargetValues ( )

Get the robot poses and latencies.

Returns
LimelightTarget::tValues

◆ getRotationSpeedWithInertia()

std::optional< double > VisionSubsystem::getRotationSpeedWithInertia ( double  lateralSpeedPct)

◆ GetSecondaryCameraTargetValues()

LimelightTarget::tValues VisionSubsystem::GetSecondaryCameraTargetValues ( )

Get the robot poses and latencies from secondary camera.

Returns
LimelightTarget::tValues

◆ GetSeeingCamera()

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

◆ getShooterAngle() [1/2]

std::optional< units::degree_t > VisionSubsystem::getShooterAngle ( )

◆ getShooterAngle() [2/2]

units::degree_t VisionSubsystem::getShooterAngle ( units::inch_t  distance,
const InterpolationMode  mode 
)

◆ getShooterAngleWithInertia()

std::optional< units::degree_t > VisionSubsystem::getShooterAngleWithInertia ( double  medialSpeedPct)

◆ getShooterOffset()

std::optional< units::degree_t > VisionSubsystem::getShooterOffset ( )

◆ getShooterSpeed() [1/2]

std::optional< units::angular_velocity::revolutions_per_minute_t > VisionSubsystem::getShooterSpeed ( )

◆ getShooterSpeed() [2/2]

units::angular_velocity::revolutions_per_minute_t VisionSubsystem::getShooterSpeed ( const units::inch_t  distance,
const InterpolationMode  mode 
) const

◆ getWhichCamera()

std::optional< whichCamera > VisionSubsystem::getWhichCamera ( bool  forFeeder = false)

◆ IsAimWhileMoveActive()

bool VisionSubsystem::IsAimWhileMoveActive ( )

◆ IsOdometryAimingActive()

bool VisionSubsystem::IsOdometryAimingActive ( )

◆ IsStaticRotationEnabled()

bool VisionSubsystem::IsStaticRotationEnabled ( )

◆ Periodic()

void VisionSubsystem::Periodic ( )
override

Will be called periodically whenever the CommandScheduler runs.

◆ RequestFilterReset()

void VisionSubsystem::RequestFilterReset ( )

◆ SetAimWhileMove()

void VisionSubsystem::SetAimWhileMove ( bool  val)

◆ SetEnableStaticRotation()

void VisionSubsystem::SetEnableStaticRotation ( bool  val)

◆ SetOdometryAiming()

void VisionSubsystem::SetOdometryAiming ( bool  val)

◆ SetPipeline()

void VisionSubsystem::SetPipeline ( uint16_t  tag)

◆ UpdateYaw()

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

Member Data Documentation

◆ 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_feederAngleMap

argos_lib::InterpolationMap<decltype(shooterRange::feederAngle.front().inVal), shooterRange::feederAngle.size(), decltype(shooterRange::feederAngle.front().outVal)> VisionSubsystem::m_feederAngleMap
private

Maps a distance to a feeder pitch angle.

◆ m_frontCameraMegaTag2PoseLogger

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

◆ 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_isOdometryAimingActive

bool VisionSubsystem::m_isOdometryAimingActive
private

true if we want to aim without vision

◆ 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_primaryCameraFrameUpdateSubscriber

argos_lib::NTSubscriber VisionSubsystem::m_primaryCameraFrameUpdateSubscriber
private

Subscriber to manage all updates from primary camera.

◆ m_pShooterSubsystem

ShooterSubsystem* VisionSubsystem::m_pShooterSubsystem
private

Pointer to shooter subsystem for reading aiming mode.

◆ m_rearCameraMegaTag2PoseLogger

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

◆ m_secondaryCameraFrameUpdateSubscriber

argos_lib::NTSubscriber VisionSubsystem::m_secondaryCameraFrameUpdateSubscriber
private

Subscriber to manage all updates from secondary camera.

◆ m_shooterAngleMap

argos_lib::InterpolationMap<decltype(shooterRange::shooterAngle.front().inVal), shooterRange::shooterAngle.size(), decltype(shooterRange::shooterAngle.front().outVal)> VisionSubsystem::m_shooterAngleMap
private

Maps a distance to a shooter pitch angle.

◆ m_shooterSpeedMap

argos_lib::InterpolationMap<decltype(shooterRange::shooterSpeed.front().inVal), shooterRange::shooterSpeed.size(), decltype(shooterRange::shooterSpeed.front().outVal)> VisionSubsystem::m_shooterSpeedMap
private

Maps a distance to a shooter speed.

◆ 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

◆ primaryCameraTableName

constexpr char VisionSubsystem::primaryCameraTableName[12] {"/limelight"}
staticconstexprprivate

◆ secondaryCameraTableName

constexpr char VisionSubsystem::secondaryCameraTableName[18] {"/limelight-front"}
staticconstexprprivate

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