mode auto manuel
This commit is contained in:
parent
9f4142d7aa
commit
b1124bd3f0
File diff suppressed because one or more lines are too long
@ -35,8 +35,8 @@
|
|||||||
"globalConstraints": {
|
"globalConstraints": {
|
||||||
"maxVelocity": 3.0,
|
"maxVelocity": 3.0,
|
||||||
"maxAcceleration": 3.0,
|
"maxAcceleration": 3.0,
|
||||||
"maxAngularVelocity": 540.0,
|
"maxAngularVelocity": 0.1,
|
||||||
"maxAngularAcceleration": 720.0,
|
"maxAngularAcceleration": 0.1,
|
||||||
"nominalVoltage": 12.0,
|
"nominalVoltage": 12.0,
|
||||||
"unlimited": false
|
"unlimited": false
|
||||||
},
|
},
|
||||||
|
@ -28,8 +28,10 @@ import edu.wpi.first.wpilibj2.command.Commands;
|
|||||||
import edu.wpi.first.wpilibj2.command.InstantCommand;
|
import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||||
import edu.wpi.first.wpilibj2.command.RunCommand;
|
import edu.wpi.first.wpilibj2.command.RunCommand;
|
||||||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
|
||||||
|
import edu.wpi.first.wpilibj2.command.WaitUntilCommand;
|
||||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||||
import frc.robot.TunerConstants.TunerConstants;
|
import frc.robot.TunerConstants.TunerConstants;
|
||||||
|
import frc.robot.commands.AvancerAuto;
|
||||||
import frc.robot.commands.RainBow;
|
import frc.robot.commands.RainBow;
|
||||||
import frc.robot.commands.reset;
|
import frc.robot.commands.reset;
|
||||||
import frc.robot.commands.Elevateur.Depart;
|
import frc.robot.commands.Elevateur.Depart;
|
||||||
@ -177,14 +179,19 @@ public class RobotContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Command getAutonomousCommand() {
|
public Command getAutonomousCommand() {
|
||||||
return new SequentialCommandGroup(Commands.runOnce(()->{
|
return new SequentialCommandGroup(
|
||||||
boolean flip = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red;
|
new AvancerAuto(drive).withTimeout(2),
|
||||||
if(flip){
|
new L1Requin(requin, bougie).withTimeout(2),
|
||||||
drivetrain.resetPose(FlippingUtil.flipFieldPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose()));
|
new ExpireCorail(requin, bougie).withTimeout(2),
|
||||||
}
|
new RainBow(bougie));
|
||||||
else{
|
// return new SequentialCommandGroup(Commands.runOnce(()->{
|
||||||
drivetrain.resetPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose());
|
// boolean flip = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red;
|
||||||
}
|
// if(flip){
|
||||||
}),autoChooser.getSelected(), new RainBow(bougie));
|
// drivetrain.resetPose(FlippingUtil.flipFieldPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose()));
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// drivetrain.resetPose(((PathPlannerAuto)autoChooser.getSelected()).getStartingPose());
|
||||||
|
// }
|
||||||
|
// }),autoChooser.getSelected(), new RainBow(bougie));
|
||||||
}
|
}
|
||||||
}
|
}
|
46
src/main/java/frc/robot/commands/AvancerAuto.java
Normal file
46
src/main/java/frc/robot/commands/AvancerAuto.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (c) FIRST and other WPILib contributors.
|
||||||
|
// Open Source Software; you can modify and/or share it under the terms of
|
||||||
|
// the WPILib BSD license file in the root directory of this project.
|
||||||
|
|
||||||
|
package frc.robot.commands;
|
||||||
|
|
||||||
|
import static edu.wpi.first.units.Units.*;
|
||||||
|
|
||||||
|
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj2.command.Command;
|
||||||
|
import frc.robot.TunerConstants.TunerConstants;
|
||||||
|
|
||||||
|
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
||||||
|
public class AvancerAuto extends Command {
|
||||||
|
private double MaxSpeed = TunerConstants.kSpeedAt12Volts.in(MetersPerSecond); // kSpeedAt12Volts desired top speed
|
||||||
|
private double MaxAngularRate = RotationsPerSecond.of(0.75).in(RadiansPerSecond); // 3/4 of
|
||||||
|
private final SwerveRequest.RobotCentric drive = new SwerveRequest.RobotCentric()
|
||||||
|
.withDeadband(MaxSpeed * 0.1).withRotationalDeadband(MaxAngularRate * 0.1);
|
||||||
|
/** Creates a new AvancerAuto. */
|
||||||
|
public AvancerAuto(SwerveRequest.RobotCentric drive) {
|
||||||
|
// Use addRequirements() here to declare subsystem dependencies.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the command is initially scheduled.
|
||||||
|
@Override
|
||||||
|
public void initialize() {}
|
||||||
|
|
||||||
|
// Called every time the scheduler runs while the command is scheduled.
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
drive.withVelocityX(0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called once the command ends or is interrupted.
|
||||||
|
@Override
|
||||||
|
public void end(boolean interrupted) {
|
||||||
|
drive.withVelocityX(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true when the command should end.
|
||||||
|
@Override
|
||||||
|
public boolean isFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -49,14 +49,16 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
|||||||
try {
|
try {
|
||||||
var config = RobotConfig.fromGUISettings();
|
var config = RobotConfig.fromGUISettings();
|
||||||
AutoBuilder.configure(
|
AutoBuilder.configure(
|
||||||
|
|
||||||
() -> getState().Pose, // Supplier of current robot pose
|
() -> getState().Pose, // Supplier of current robot pose
|
||||||
this::resetPose, // Consumer for seeding pose against auto
|
this::resetPose, // Consumer for seeding pose against auto
|
||||||
() -> getState().Speeds, // Supplier of current robot speeds
|
() -> getState().Speeds, // Supplier of current robot speeds
|
||||||
|
|
||||||
// Consumer of ChassisSpeeds and feedforwards to drive the robot
|
// Consumer of ChassisSpeeds and feedforwards to drive the robot
|
||||||
(speeds, feedforwards) -> setControl(
|
(speeds, feedforwards) -> setControl(
|
||||||
m_pathApplyRobotSpeeds.withSpeeds(speeds)
|
m_pathApplyRobotSpeeds.withSpeeds(speeds)
|
||||||
.withWheelForceFeedforwardsX(feedforwards.robotRelativeForcesXNewtons())
|
.withWheelForceFeedforwardsY(feedforwards.robotRelativeForcesXNewtons())
|
||||||
.withWheelForceFeedforwardsY(feedforwards.robotRelativeForcesYNewtons())
|
.withWheelForceFeedforwardsX(feedforwards.robotRelativeForcesYNewtons())
|
||||||
),
|
),
|
||||||
new PPHolonomicDriveController(
|
new PPHolonomicDriveController(
|
||||||
// PID constants for translation
|
// PID constants for translation
|
||||||
@ -70,6 +72,7 @@ public class CommandSwerveDrivetrain extends TunerSwerveDrivetrain implements Su
|
|||||||
// Assume the path needs to be flipped for Red vs Blue, this is normally the case
|
// Assume the path needs to be flipped for Red vs Blue, this is normally the case
|
||||||
() -> DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red,
|
() -> DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Red,
|
||||||
this // Subsystem for requirements
|
this // Subsystem for requirements
|
||||||
|
|
||||||
);
|
);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
DriverStation.reportError("Failed to load PathPlanner config and configure AutoBuilder", ex.getStackTrace());
|
DriverStation.reportError("Failed to load PathPlanner config and configure AutoBuilder", ex.getStackTrace());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user