7#include <frc/filter/LinearFilter.h>
8#include <frc/geometry/Pose3d.h>
9#include <frc/geometry/Transform3d.h>
10#include <frc2/command/SubsystemBase.h>
11#include <units/angle.h>
12#include <units/angular_velocity.h>
13#include <units/length.h>
14#include <wpi/DataLog.h>
25#include "networktables/NetworkTable.h"
26#include "networktables/NetworkTableEntry.h"
27#include "networktables/NetworkTableInstance.h"
28#include "networktables/NetworkTableValue.h"
52 :
m_txFilter{frc::LinearFilter<
units::degree_t>::SinglePoleIIR(0.01, 0.02_s)}
53 ,
m_tyFilter{frc::LinearFilter<
units::degree_t>::SinglePoleIIR(0.01, 0.02_s)}
54 ,
m_zFilter{frc::LinearFilter<
units::meter_t>::SinglePoleIIR(0.01, 0.02_s)}
208 [[nodiscard]] units::angular_velocity::revolutions_per_minute_t
getShooterSpeed(
const units::inch_t distance,
210 [[nodiscard]] std::optional<units::angular_velocity::revolutions_per_minute_t>
getShooterSpeed();
220 [[nodiscard]] std::optional<whichCamera>
getWhichCamera(
bool forFeeder =
false);
222 [[nodiscard]] std::optional<LimelightTarget::tValues>
GetSeeingCamera(
bool forFeeder =
false);
263 void UpdateYaw(std::stop_token stopToken);
Provides methods for interacting with the camera on a high level.
Definition vision_subsystem.h:97
void SetDriverMode(bool mode)
Turns the camera's driver mode on and off.
std::optional< LimelightTarget > GetClosestTarget()
Get the closest target the camera can see CAN RETURN NONE.
void RequestTargetFilterReset()
Definition vision_subsytem.cpp:25
LimelightTarget m_target
object that holds the current target seen by the camera
Definition vision_subsystem.h:101
Definition vision_subsystem.h:34
bool HasTarget()
Does the camera see a target?
Definition vision_subsytem.cpp:661
units::degree_t m_pitch
Pitch of target relative to camera -24.85 to 24.85 degrees.
Definition vision_subsystem.h:40
units::millisecond_t m_totalLatency
Total latency.
Definition vision_subsystem.h:43
double m_area
Area of the target in percentage of total pixels.
Definition vision_subsystem.h:42
LimelightTarget()
Definition vision_subsystem.h:51
bool m_resetFilterFlag
Definition vision_subsystem.h:47
double m_tid
Tag ID.
Definition vision_subsystem.h:48
void ResetFilters(std::string cameraName)
Definition vision_subsytem.cpp:669
frc::Pose3d m_targetPose
3d pose of Target relative to camera (Z - Forward, X - right, Y - down)
Definition vision_subsystem.h:38
frc::Pose3d m_robotPose
3d pose of robot relative to field center
Definition vision_subsystem.h:36
frc::LinearFilter< units::meter_t > m_zFilter
Definition vision_subsystem.h:46
frc::LinearFilter< units::degree_t > m_tyFilter
Definition vision_subsystem.h:45
units::degree_t m_yaw
Yaw of target relative to camera -31.65 to 31.65 degrees.
Definition vision_subsystem.h:41
bool m_hasTargets
True if the camera has a target it can read.
Definition vision_subsystem.h:39
tValues GetTarget(bool filter, std::string cameraName)
Get the values of the camera's current target.
Definition vision_subsytem.cpp:596
frc::LinearFilter< units::degree_t > m_txFilter
Definition vision_subsystem.h:44
void ResetOnNextTarget()
Definition vision_subsytem.cpp:665
frc::Pose3d m_robotPoseWPI
3d pose of robot relative to WPI reference for active alliance
Definition vision_subsystem.h:37
Definition shooter_subsystem.h:13
Subsystem for controlling the swerve drivetrain of the robot.
Definition swerve_drive_subsystem.h:67
Definition vision_subsystem.h:120
void SetEnableStaticRotation(bool val)
Definition vision_subsytem.cpp:205
ShooterSubsystem * m_pShooterSubsystem
Pointer to shooter subsystem for reading aiming mode.
Definition vision_subsystem.h:235
std::optional< units::degree_t > getShooterOffset()
Definition vision_subsytem.cpp:331
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.
Definition vision_subsystem.h:245
LimelightTarget::tValues m_oldTargetValues
The old robot poses and latencies.
Definition vision_subsystem.h:236
bool m_usePolynomial
specifies whether to use the polynomial to obtain shooter angle
Definition vision_subsystem.h:237
bool IsOdometryAimingActive()
Definition vision_subsytem.cpp:189
static constexpr char primaryCameraTableName[12]
Definition vision_subsystem.h:225
bool IsAimWhileMoveActive()
Definition vision_subsytem.cpp:185
std::optional< units::degree_t > getShooterAngle()
Definition vision_subsytem.cpp:239
void SetOdometryAiming(bool val)
Definition vision_subsytem.cpp:193
void Disable()
it disables (duh)
Definition vision_subsytem.cpp:579
SwerveDriveSubsystem * m_pDriveSubsystem
Pointer to drivetrain for reading some odometry.
Definition vision_subsystem.h:234
units::degree_t getFeederAngle()
Definition vision_subsytem.cpp:255
InterpolationMode
Definition vision_subsystem.h:126
std::jthread m_yawUpdateThread
Definition vision_subsystem.h:258
std::optional< units::degree_t > getFeederOffset()
Definition vision_subsytem.cpp:167
std::optional< units::degree_t > GetOrientationToTrap()
Definition vision_subsytem.cpp:507
wpi::log::StructLogEntry< frc::Pose2d > m_rearCameraMegaTag2PoseLogger
Definition vision_subsystem.h:261
std::optional< units::inch_t > GetCalculatedDistanceToSpeaker()
Get the distance to the tag calculated with the Ty (vertical offset)
Definition vision_subsytem.cpp:452
bool m_useTrigonometry
specifies whether to use the trigonometry to obtain shooter angle
Definition vision_subsystem.h:238
bool m_isAimWhileMoveActive
true if aiming trigger is pressed and locked
Definition vision_subsystem.h:239
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.
Definition vision_subsystem.h:253
void RequestFilterReset()
Definition vision_subsytem.cpp:536
argos_lib::NTSubscriber m_secondaryCameraFrameUpdateSubscriber
Subscriber to manage all updates from secondary camera.
Definition vision_subsystem.h:257
void Periodic() override
Definition vision_subsytem.cpp:98
LimelightTarget::tValues GetSecondaryCameraTargetValues()
Get the robot poses and latencies from secondary camera.
Definition vision_subsytem.cpp:544
std::optional< LimelightTarget::tValues > GetSeeingCamera(bool forFeeder=false)
Definition vision_subsytem.cpp:568
LimelightTarget::tValues GetPrimaryCameraTargetValues()
Get the robot poses and latencies.
Definition vision_subsytem.cpp:540
void SetAimWhileMove(bool val)
Definition vision_subsytem.cpp:197
std::optional< double > getFeedOffsetWithInertia(double lateralSpeedPct)
Definition vision_subsytem.cpp:306
wpi::log::StructLogEntry< frc::Pose2d > m_frontCameraMegaTag2PoseLogger
Definition vision_subsystem.h:260
std::optional< units::degree_t > GetHorizontalOffsetToTrap()
Definition vision_subsytem.cpp:486
std::optional< units::inch_t > GetDistanceToStageCenter()
Definition vision_subsytem.cpp:428
std::optional< units::angular_velocity::revolutions_per_minute_t > getShooterSpeed()
Definition vision_subsytem.cpp:394
std::optional< units::degree_t > GetHorizontalOffsetToTarget()
Get the current offset to the retroreflective tape.
Definition vision_subsytem.cpp:140
std::optional< units::degree_t > getFeederAngleWithInertia(double medialSpeedPct)
Definition vision_subsytem.cpp:319
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.
Definition vision_subsystem.h:249
argos_lib::NTSubscriber m_primaryCameraFrameUpdateSubscriber
Subscriber to manage all updates from primary camera.
Definition vision_subsystem.h:255
CameraInterface m_cameraInterface
Interface to limelight camera.
Definition vision_subsystem.h:230
std::optional< whichCamera > getWhichCamera(bool forFeeder=false)
Definition vision_subsytem.cpp:548
std::optional< double > getRotationSpeedWithInertia(double lateralSpeedPct)
Definition vision_subsytem.cpp:291
argos_lib::RobotInstance m_instance
Contains either the competition bot or practice bot. Differentiates between the two.
Definition vision_subsystem.h:233
std::optional< units::degree_t > GetOrientationToSpeaker()
Get the distance to the tag.
Definition vision_subsytem.cpp:441
void UpdateYaw(std::stop_token stopToken)
Definition vision_subsytem.cpp:583
static constexpr char secondaryCameraTableName[18]
Definition vision_subsystem.h:226
bool m_isOdometryAimingActive
true if we want to aim without vision
Definition vision_subsystem.h:241
std::optional< units::inch_t > GetDistanceToSpeaker()
Get the distance to the tag.
Definition vision_subsytem.cpp:410
void SetPipeline(uint16_t tag)
Definition vision_subsytem.cpp:526
std::optional< units::inch_t > GetDistanceToTrap()
Definition vision_subsytem.cpp:467
bool m_enableStaticRotation
true if you want to rotate in the absence of translation input
Definition vision_subsystem.h:240
bool IsStaticRotationEnabled()
Definition vision_subsytem.cpp:201
std::optional< units::degree_t > getShooterAngleWithInertia(double medialSpeedPct)
Definition vision_subsytem.cpp:266
Performs linear interpolation of a value based on a set of input->output mapping points.
Definition interpolation.h:46
Subscribes to Network Tables entry updates and calls a specified callback to use the new value.
Definition nt_subscriber.h:17
RobotInstance
Differentiates between practice robot and competition robot.
Definition config_types.h:13
constexpr std::array shooterAngle
Definition interpolation_maps.h:44
constexpr std::array shooterSpeed
Definition interpolation_maps.h:37
constexpr std::array feederAngle
Definition interpolation_maps.h:52
Definition custom_units.h:11
Wraps members of LimelightTarget for use elsewhere.
Definition vision_subsystem.h:61
frc::Pose3d robotPoseWPI
3d pose of robot relative to WPI reference for active alliance
Definition vision_subsystem.h:63
units::degree_t m_yaw
Yaw of target relative to camera -31.65 to 31.65 degrees.
Definition vision_subsystem.h:67
frc::Pose3d tagPose
3d pose of Target relative to camera (Z - Forward, X - right, Y - down)
Definition vision_subsystem.h:64
bool hasTargets
True if the camera has a target it can read.
Definition vision_subsystem.h:65
units::degree_t m_pitch
Pitch of target relative to camera -24.85 to 24.85 degrees.
Definition vision_subsystem.h:66
double tagID
Tag ID.
Definition vision_subsystem.h:69
frc::Pose3d robotPose
3d pose of robot relative to field center
Definition vision_subsystem.h:62
units::millisecond_t totalLatency
Total latency.
Definition vision_subsystem.h:70
double m_area
Area of the target in percentage of total pixels.
Definition vision_subsystem.h:68
whichCamera
Definition vision_subsystem.h:32