mirror of
https://github.com/Team4388/2023WayOfTheRobot.git
synced 2026-06-08 16:28:00 -06:00
Merge branch 'vision-april-lime' into odometry
This commit is contained in:
+53
@@ -3,5 +3,58 @@
|
||||
"types": {
|
||||
"/FMSInfo": "FMSInfo"
|
||||
}
|
||||
},
|
||||
"NetworkTables": {
|
||||
"retained": {
|
||||
"apriltag": {
|
||||
"open": true
|
||||
}
|
||||
},
|
||||
"transitory": {
|
||||
"LiveWindow": {
|
||||
".status": {
|
||||
"open": true
|
||||
}
|
||||
},
|
||||
"Shuffleboard": {
|
||||
".recording": {
|
||||
"open": true
|
||||
},
|
||||
"open": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"NetworkTables Info": {
|
||||
"Clients": {
|
||||
"open": true
|
||||
},
|
||||
"NT3@192.168.1.132:40708": {
|
||||
"Publishers": {
|
||||
"open": true
|
||||
},
|
||||
"Subscribers": {
|
||||
"open": true
|
||||
},
|
||||
"open": true
|
||||
},
|
||||
"NT3@192.168.1.132:49546": {
|
||||
"Publishers": {
|
||||
"open": true
|
||||
},
|
||||
"Subscribers": {
|
||||
"open": true
|
||||
},
|
||||
"open": true
|
||||
},
|
||||
"NT3@192.168.1.132:52724": {
|
||||
"Publishers": {
|
||||
"open": true
|
||||
},
|
||||
"Subscribers": {
|
||||
"open": true
|
||||
},
|
||||
"open": true
|
||||
},
|
||||
"visible": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
|
||||
package frc4388.robot;
|
||||
|
||||
|
||||
import frc4388.robot.subsystems.Vision;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.CommandScheduler;
|
||||
@@ -24,7 +29,7 @@ public class Robot extends TimedRobot {
|
||||
|
||||
private RobotTime m_robotTime = RobotTime.getInstance();
|
||||
private RobotContainer m_robotContainer;
|
||||
|
||||
private Vision Vision = new Vision();
|
||||
|
||||
/**
|
||||
* This function is run when the robot is first started up and should be
|
||||
@@ -35,6 +40,7 @@ public class Robot extends TimedRobot {
|
||||
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
|
||||
// autonomous chooser on the dashboard.
|
||||
m_robotContainer = new RobotContainer();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,6 +59,7 @@ public class Robot extends TimedRobot {
|
||||
// and running subsystem periodic() methods. This must be called from the robot's periodic
|
||||
// block in order for anything in the Command-based framework to work.
|
||||
CommandScheduler.getInstance().run();
|
||||
System.out.println(Arrays.toString(Vision.getAprilTags()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package frc4388.robot.subsystems;
|
||||
|
||||
import edu.wpi.first.apriltag.AprilTag;
|
||||
import edu.wpi.first.math.geometry.Pose3d;
|
||||
import edu.wpi.first.math.geometry.Rotation3d;
|
||||
import edu.wpi.first.networktables.NetworkTable;
|
||||
import edu.wpi.first.networktables.NetworkTableEntry;
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
|
||||
public class Vision {
|
||||
private final NetworkTableEntry m_isTags;
|
||||
private final NetworkTableEntry m_xPoses;
|
||||
private final NetworkTableEntry m_yPoses;
|
||||
private final NetworkTableEntry m_zPoses;
|
||||
|
||||
public Vision() {
|
||||
final var tagTable = NetworkTableInstance.getDefault().getTable("apriltag");
|
||||
|
||||
m_isTags = tagTable.getEntry("IsTag");
|
||||
m_xPoses = tagTable.getEntry("TagPosX");
|
||||
m_yPoses = tagTable.getEntry("TagPosY");
|
||||
m_zPoses = tagTable.getEntry("TagPosZ");
|
||||
}
|
||||
|
||||
public AprilTag[] getAprilTags() {
|
||||
if (!m_isTags.getBoolean(false)) return new AprilTag[0];
|
||||
|
||||
double xarr[] = m_xPoses.getDoubleArray(new double[] {});
|
||||
double yarr[] = m_yPoses.getDoubleArray(new double[] {});
|
||||
double zarr[] = m_zPoses.getDoubleArray(new double[] {});
|
||||
|
||||
AprilTag tags[] = new AprilTag[xarr.length];
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
tags[i] = new AprilTag(0, new Pose3d(xarr[i], yarr[i], zarr[i], new Rotation3d()));
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user