Skip to content

Commit

Permalink
camera class
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyBrar committed Oct 20, 2024
1 parent dd3958e commit a455a94
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/main/cpp/Camera.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <string>
#include <photon/PhotonCamera.h>
#include <Camera.h>


int Camera::id()
{
return target.GetFiducialId();
}
double Camera::yaw()
{
return target.GetYaw();
}
double Camera::pitch()
{
return target.GetPitch();
}
Camera::Camera(std::string name)
{
camera = photon::PhotonCamera {name};
result = camera.GetLatestResult();
target = result.GetBestTarget();
}
1 change: 0 additions & 1 deletion src/main/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void Robot::updateDashBoardValues() {
frc::SmartDashboard::PutNumber("Measured Launcher Angle", _robot_control_data.launcherOutput.launcherAngle);

};

void Robot::RobotInit() {
// m_chooser.SetDefaultOption(kAutoNameDefault, kAutoNameDefault);
// m_chooser.AddOption(kAutoNameCustom, kAutoNameCustom);
Expand Down
23 changes: 23 additions & 0 deletions src/main/include/Camera.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <string>
#include <photon/PhotonCamera.h>

class Camera
{
private:
/*
double yaw = target.GetYaw();
double pitch = target.GetPitch();
int targetID = target.GetFiducialId();
double poseAmbiguity = target.GetPoseAmbiguity();
*/
photon::PhotonCamera camera;
photon::PhotonPipelineResult result;
photon::PhotonTrackedTarget target;

public:
int id();
//double ambiguity();
double yaw();
double pitch();
Camera(std::string name);
};
2 changes: 1 addition & 1 deletion src/main/include/ControllerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ class ControllerInterface

frc::XboxController m_pilot{0};
frc::XboxController m_copilot{1};
double m_slowmodefactor = 0.5;
double m_slowmodefactor = 0.25;
};
57 changes: 57 additions & 0 deletions vendordeps/photonlib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"fileName": "photonlib.json",
"name": "photonlib",
"version": "v2024.3.1",
"uuid": "515fe07e-bfc6-11fa-b3de-0242ac130004",
"frcYear": "2024",
"mavenUrls": [
"https://maven.photonvision.org/repository/internal",
"https://maven.photonvision.org/repository/snapshots"
],
"jsonUrl": "https://maven.photonvision.org/repository/internal/org/photonvision/photonlib-json/1.0/photonlib-json-1.0.json",
"jniDependencies": [],
"cppDependencies": [
{
"groupId": "org.photonvision",
"artifactId": "photonlib-cpp",
"version": "v2024.3.1",
"libName": "photonlib",
"headerClassifier": "headers",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxathena",
"linuxx86-64",
"osxuniversal"
]
},
{
"groupId": "org.photonvision",
"artifactId": "photontargeting-cpp",
"version": "v2024.3.1",
"libName": "photontargeting",
"headerClassifier": "headers",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxathena",
"linuxx86-64",
"osxuniversal"
]
}
],
"javaDependencies": [
{
"groupId": "org.photonvision",
"artifactId": "photonlib-java",
"version": "v2024.3.1"
},
{
"groupId": "org.photonvision",
"artifactId": "photontargeting-java",
"version": "v2024.3.1"
}
]
}

0 comments on commit a455a94

Please sign in to comment.