Skip to content

Commit

Permalink
Javadocs
Browse files Browse the repository at this point in the history
- Added javadocs to functions in  CameraSubsystem, Aimcommand, and DriveSubsystem
- Fixed javadocs for other subsystems
  • Loading branch information
Iooob committed Jan 19, 2025
1 parent 120642c commit befe6de
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 36 deletions.
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/commands/AimCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public AimCommand(DriveSubsystem d_subsystem, CameraSubsystem c_subsystem) {
@Override
public void initialize() {}

/**
* Takes pipeline result from camera, follows path based on those results.
*
* @param result Camera pipeline result
*/
private void processResult(PhotonPipelineResult result) {
SmartDashboard.putBoolean("CameraTargetDetected", true);
// find target we want, we can change later
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/frc/robot/subsystems/ArmSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ public Command sysIdDynamic(SysIdRoutine.Direction direction) {
return m_sysIdRoutine.dynamic(direction);
}

/*
/**
* Move Arm to a specific angle
*
* @param radians Angle in radians to move the arm to
*/
public void SetAngle(double radians) {
m_ArmMainPIDController.setReference(
Expand All @@ -175,9 +177,7 @@ public void SetAngle(double radians) {
m_ArmFeedforward.calculate(radians, m_ArmEncoder.getVelocity()));
}

/*
* Lower the Arm
*/
/** Lower the Arm */
public void LowerArm() {
SetAngle(kStartingAngleRads);
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/frc/robot/subsystems/CameraSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public CameraSubsystem(DriveSubsystem d_subsystem) {
visionSim.addCamera(targetingCamera1Sim, Constants.TargetingCamera1.location);
}

/**
* Gets the last procesesd frame captured by camera
*
* @param camera Desired camera to get result from
* @return Targets in the frame.
*/
private Optional<PhotonPipelineResult> getPipelineResults(PhotonCamera camera) {
var results = camera.getAllUnreadResults();
if (!results.isEmpty()) {
Expand All @@ -126,6 +132,12 @@ private Optional<PhotonPipelineResult> getPipelineResults(PhotonCamera camera) {
return Optional.empty();
}

/**
* Update estaimated robot pose based on given pipeline result.
*
* @param result Camera pipeline result
* @param poseEstimator Pose estimator
*/
private void updateGlobalPose(
Optional<PhotonPipelineResult> result, PhotonPoseEstimator poseEstimator) {
if (result.isPresent()) {
Expand Down
47 changes: 34 additions & 13 deletions src/main/java/frc/robot/subsystems/DriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,14 @@ public void tankDrive(double leftSpeed, double rightSpeed) {
m_ddrive.tankDrive(leftSpeed, rightSpeed);
}

/**
* When this function is activated, the robot is in "drive straight" mode. Whatever direction the
* robot was heading when "drive straight" mode was entered will be maintained. We use the current
* pose of the robot to determine the direction. The robot will continue to move in this direction
* until the function is canceled.
*/
public Command driveStraight() {
/*
* WWhen this function is activated, the robot is in "drive straight" mode.
* Whatever direction the robot was heading when "drive straight" mode was
* entered will be maintained. We use the current pose of the robot to determine the direction.
* The robot will continue to move in this direction until the function is canceled.
*/

// get current pose
Pose2d currentPose = getPose();
// get current angle
Expand All @@ -370,47 +371,67 @@ public Command driveStraight() {
return GenerateOnTheFlyCommand(wantedPoses);
}

/**
* Builds a command to follow a path based on a given list of desired poses
*
* @param desiredPoses A list of poses for the robot to move to
* @return The command to follow created path
*/
public Command GenerateOnTheFlyCommand(List<Pose2d> desiredPoses) {
// Creates the path to follow
PathPlannerPath path = generateOnTheFlyPath(desiredPoses);
// Returns built command following the path
return AutoBuilder.followPath(path);
}

/**
* Creates a path based on a given list of desired poses
*
* @param desiredPoses A list of poses for the robot to move to. Requires atleast 2 poses.
* @return The path with the poses to go to.
*/
private PathPlannerPath generateOnTheFlyPath(List<Pose2d> desiredPoses) {
// Turn poses into waypoints
List<Waypoint> waypoints = PathPlannerPath.waypointsFromPoses(desiredPoses);
// Create path with waypoints
PathPlannerPath path =
new PathPlannerPath(
waypoints,
DriveConstants.OnTheFly.kPathConstraints,
new IdealStartingState(0, desiredPoses.get(0).getRotation()),
new GoalEndState(0, desiredPoses.get(desiredPoses.size() - 1).getRotation()));
// Disables the path being mirrored based on which alliance we are on
path.preventFlipping = true;
return path;
}

/*
* This function can return our robots DiffernentialDriveWheelSpeeds, which is the speed of each side of the robot.
/**
* This function can return our robots DiffernentialDriveWheelSpeeds, which is the speed of each
* side of the robot.
*/
public DifferentialDriveWheelSpeeds getWheelSpeeds() {
return new DifferentialDriveWheelSpeeds(getVelocityLeft(), getVelocityRight());
}

/*
* This function can return our robots ChassisSpeeds, which is vx (m/s), vy (m/s), and omega (rad/s).
/**
* This function can return our robots ChassisSpeeds, which is vx (m/s), vy (m/s), and omega
* (rad/s).
*/
public ChassisSpeeds getSpeeds() {
return DriveConstants.kDriveKinematics.toChassisSpeeds(getWheelSpeeds());
}

/*
/**
* This function can set our robots ChassisSpeeds, which is vx (m/s), vy (m/s), and omega (rad/s).
* vy is always 0 as we are not strafing.
*/
public void setSpeeds(ChassisSpeeds speeds) {
setWheelVelocities(DriveConstants.kDriveKinematics.toWheelSpeeds(speeds));
}

/*
* This function can set our robots DifferentialDriveWheelSpeeds, which is the speed of each side of the robot.
/**
* This function can set our robots DifferentialDriveWheelSpeeds, which is the speed of each side
* of the robot.
*/
public void setWheelVelocities(DifferentialDriveWheelSpeeds speeds) {
// get left and right speeds in m/s, and run through feedforward to get feedforward voltage
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/frc/robot/subsystems/ElevatorSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ public Command sysIdDynamic(SysIdRoutine.Direction direction) {
return m_sysIdRoutine.dynamic(direction);
}

/*
* Move elevator to a specific height
*/
/** Move elevator to a specific height */
public void SetHeight(double meters) {
m_ElevatorMainPIDController.setReference(
meters,
Expand All @@ -172,9 +170,7 @@ public void SetHeight(double meters) {
m_ElevatorFeedforward.calculate(meters));
}

/*
* Retract the elevator
*/
/** Retract the elevator */
public void LowerElevator() {
SetHeight(0);
}
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/frc/robot/subsystems/FlywheelSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ public Command sysIdDynamic(SysIdRoutine.Direction direction) {
return m_sysIdRoutine.dynamic(direction);
}

/*
* Spin shooter at a given Speed (M/S)
*/
/** Spin shooter at a given Speed (M/S) */
public void SpinShooter(double speed) {
m_ShooterMainPIDController.setReference(
speed,
Expand All @@ -159,16 +157,12 @@ public void SpinAtFull() {
SpinShooter(1);
}

/*
* Stop the shooter
*/
/** Stop the shooter */
public void StopShooter() {
SpinShooter(0);
}

/*
* Check if shooter is at a given Speed
*/
/** Check if shooter is at a given Speed */
public Boolean isAtSpeedTolerance(double speed) {
return (m_ShooterMainEncoder.getVelocity() > speed - 0.1
&& m_ShooterMainEncoder.getVelocity() < speed + 0.1);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/frc/robot/subsystems/TurntableSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ public Command sysIdDynamic(SysIdRoutine.Direction direction) {
return m_sysIdRoutine.dynamic(direction);
}

/*
/**
* Move Turntable to a specific angle
*
* @param radians Angle in radians which we want to move the turntable to
*/
public void SetAngle(double radians) {
m_TurntableMainPIDController.setReference(
Expand All @@ -161,9 +163,7 @@ public void SetAngle(double radians) {
m_TurntableFeedforward.calculate(radians, m_TurntableEncoder.getVelocity()));
}

/*
* Reset the Turntable
*/
/** Reset the Turntable */
public void ResetTurntable() {
SetAngle(kStartingAngleRads);
}
Expand Down

0 comments on commit befe6de

Please sign in to comment.