Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wojtaszek - Autonomous and other stuff #6

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Wojtaszek - Autonomous and other stuff #6

wants to merge 18 commits into from

Conversation

wojtase1
Copy link

@wojtase1 wojtase1 commented Dec 8, 2024

I think that I have logic that should be in the subsystem in the command logic for the "DriveDistance". I will probably clean that up.

@wojtase1 wojtase1 requested a review from BrownGenius December 8, 2024 15:54
Copy link
Collaborator

@BrownGenius BrownGenius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks good! I would make some minor changes to enhance reusability, but functionally ok as-is.

At the least, add a comment for the "A" button and confirm you means to remove the field from the SmartDashboard.

shooter.setDefaultCommand(
new ShooterCommand(
shooter,
() -> mainController.getLeftTriggerAxis(),
() -> mainController.getRightTriggerAxis()));

mainController.a().toggleOnTrue(new AutonomousDistance(drive));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a comment saying that this binds the "A" button to execute the AutonomousDistance routine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this to be part of the autonomous command logic.

*
* @param drivetrain The drivetrain subsystem on which this command will run
*/
public AutonomousDistance(DriveSubsystemXrp drivetrain) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change the "DriveSystemXrp" (the implementation) to "Drive" (the interface), so that this command could be re-used in any subsystem that implements the Drive interface. E.g. we could have the same command work on Romi, XRP, and even the actual comp bot.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would reccomend I do this? I would have to add a function to the Drive interface for getting the left and right positions. In the current code I do this by accessing that data through the DriveSubsystemXRP through the drivedifferentialIOXrp/DriveDifferentialIo class/interface but that is really specific to robots with a left and right wheels. Adding that logic to the Drive interface would limit it and all derived implementations to 2wd bots.

import frc.robot.subsystems.drive.DriveSubsystemXrp;

public class DriveDistance extends Command {
private final DriveSubsystemXrp drive;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same: Change DriveSubsystemXrp --> Drive

speed = driveSpeed;
drive = driveSubsystem;

pidController = new PIDController(1.0, 0.0, 0.0); // Adjust PID constants as needed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the command re-usable on any robot, the PID Controller should be passed into the command, the constant could be moved to Constants.java, the constants could be passed in, etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

public void execute() {
double leftDistance = leftWheelStartPosition - drive.getLeftPositionMeters();
double rightDistance = rightWheelStartPosition - drive.getRightPositionMeters();
System.out.println("Left: " + leftDistance + " Right: " + rightDistance);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "production" code shouldn't print to the console. Try to add AdvantageKit logging for these values. See https://docs.advantagekit.org/data-flow/recording-outputs/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it but will use advantage kit in the future

public class DriveTime extends Command {
private final double duration;
private final double speed;
private final DriveSubsystemXrp drive;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DriveSubsystemXrp --> Drive

// Create a DifferentialDriveKinematics object with the track width
kinematics = new DifferentialDriveKinematics(DriveConstants.trackWidthMeters);

addRequirements(drive);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change DriveSubsystemXrp --> Drive, then this needs to be cast to a Subsystem: addRequirements((Subsystem) drive);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the DriveTime command work? I tried something similar using drive(1 m/s) + WaitCommand(5 sec) + drive(0 m/s), and the XRP only drove for a split second.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I plan on removing this. Right now I don't see a use for this class.

Comment on lines 40 to 43

// START: Setup Odometry
SmartDashboard.putData("Field", field);
// END: Setup Odometry
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to remove the "Field" from the smartdashboard?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I put it back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants