Valor 6800 1.0
Loading...
Searching...
No Matches
VisionSensor.h
1
2#pragma once
3
4#include <memory>
5#include <string>
6
7#include <frc/geometry/Pose3d.h>
8#include <networktables/NetworkTable.h>
9#include <networktables/NetworkTableInstance.h>
10#include <units/temperature.h>
11#include <units/time.h>
12#include <units/velocity.h>
13
14#include "valkyrie/sensors/BaseSensor.h"
15
16namespace valor {
17
18#define KLIMELIGHT -29.8f // degrees; TODO: Make Modular
19
26class VisionSensor : public valor::BaseSensor<frc::Pose3d> {
27 public:
35 VisionSensor(frc::TimedRobot& robot, std::string name, frc::Pose3d _cameraPose);
36
40 enum PipeLines {
41 PIPELINE_0,
42 PIPELINE_1,
43 PIPELINE_2,
44 PIPELINE_3,
45 PIPELINE_4,
46 PIPELINE_5,
47 };
48
52 void reset() override;
53
59 void setCameraPose(frc::Pose3d camPose);
60
67
73 bool hasTarget();
74
75 void setThrottle(int skippedFrames);
76
82 void captureVideo(units::second_t captureTime);
83
91 units::velocity::meters_per_second_t getError(int pipe, double kPLimeLight = 0.7);
92
93 protected:
99 units::millisecond_t getTotalLatency();
100
109 virtual frc::Pose3d getGlobalPose() = 0;
110
117 void calculate() override;
118
119 double tx, ty, tv, fps, ramUsage, ta;
120 int pipe;
121 units::celsius_t cpuTemp, temp;
122
123 frc::Pose3d cameraPose;
124 std::shared_ptr<nt::NetworkTable> limeTable;
125};
126
127} // namespace valor
Abstract class that all Valor sensors should implement.
Definition BaseSensor.h:27
T ReadLog(std::string_view field, const T &defaultValue={})
Read a value from NetworkTables for the given field.
Definition Loggable.h:343
Base class for vision sensors, such as Limelight.
Definition VisionSensor.h:26
units::millisecond_t getTotalLatency()
Get the total latency of the vision sensor.
virtual frc::Pose3d getGlobalPose()=0
Get the global pose of the vision sensor.
units::velocity::meters_per_second_t getError(int pipe, double kPLimeLight=0.7)
Calculate the error for a specific pipeline.
void calculate() override
Perform vision sensor-specific calculations.
bool hasTarget()
Check if the vision sensor has a valid target.
VisionSensor(frc::TimedRobot &robot, std::string name, frc::Pose3d _cameraPose)
Construct a new VisionSensor object.
void setPipe(PipeLines _pipe)
Set the active pipeline for the vision sensor.
void reset() override
Reset the vision sensor state.
void setCameraPose(frc::Pose3d camPose)
Set the camera's pose in 3D space.
frc::Pose3d cameraPose
Physical 3D position of the camera's lens.
Definition VisionSensor.h:123
PipeLines
Enum representing available pipelines for the vision sensor.
Definition VisionSensor.h:40
std::shared_ptr< nt::NetworkTable > limeTable
NetworkTable for vision data.
Definition VisionSensor.h:124
units::celsius_t temp
Temperature readings.
Definition VisionSensor.h:121
void captureVideo(units::second_t captureTime)
Capture video data on the Limelight using Rewind.
double ta
Vision sensor telemetry data.
Definition VisionSensor.h:119
int pipe
Active pipeline index.
Definition VisionSensor.h:120