diff --git a/simgui.json b/simgui.json index be49c52..a612677 100644 --- a/simgui.json +++ b/simgui.json @@ -7,6 +7,29 @@ }, "windows": { "/SmartDashboard/Field": { + "Robot": { + "arrowColor": [ + 1.0, + 1.0, + 1.0, + 255.0 + ], + "color": [ + 1.0, + 1.0, + 1.0, + 255.0 + ], + "style": "Box/Image" + }, + "XModules": { + "arrowColor": [ + 0.0, + 1.0, + 0.0, + 255.0 + ] + }, "window": { "visible": true } diff --git a/src/main/deploy/swerve/controllerproperties.json b/src/main/deploy/swerve/controllerproperties.json index 669097e..1c115ca 100644 --- a/src/main/deploy/swerve/controllerproperties.json +++ b/src/main/deploy/swerve/controllerproperties.json @@ -1,5 +1,5 @@ { - "angleJoystickRadiusDeadband": 0.5, + "angleJoystickRadiusDeadband": 0.6, "heading": { "p": 0.4, "i": 0, diff --git a/src/main/deploy/swerve/modules/backleft.json b/src/main/deploy/swerve/modules/backleft.json index 9eecec3..40325ab 100644 --- a/src/main/deploy/swerve/modules/backleft.json +++ b/src/main/deploy/swerve/modules/backleft.json @@ -3,7 +3,7 @@ "front": -12.375, "left": 12.375 }, - "absoluteEncoderOffset": 0, + "absoluteEncoderOffset": 80.332, "drive": { "type": "sparkmax", "id": 8, @@ -16,11 +16,11 @@ }, "encoder": { "type": "cancoder", - "id": 22, + "id": 7, "canbus": null }, "inverted": { "drive": false, - "angle": false + "angle": true } } \ No newline at end of file diff --git a/src/main/deploy/swerve/modules/backright.json b/src/main/deploy/swerve/modules/backright.json index 4d87807..d1526d4 100644 --- a/src/main/deploy/swerve/modules/backright.json +++ b/src/main/deploy/swerve/modules/backright.json @@ -3,7 +3,7 @@ "front": -12.375, "left": -12.375 }, - "absoluteEncoderOffset": 0, + "absoluteEncoderOffset": 28.740 , "drive": { "type": "sparkmax", "id": 11, @@ -16,11 +16,11 @@ }, "encoder": { "type": "cancoder", - "id": 22, + "id": 6, "canbus": null }, "inverted": { "drive": false, - "angle": false + "angle": true } } \ No newline at end of file diff --git a/src/main/deploy/swerve/modules/frontleft.json b/src/main/deploy/swerve/modules/frontleft.json index d6d3fcc..8c8ecd3 100644 --- a/src/main/deploy/swerve/modules/frontleft.json +++ b/src/main/deploy/swerve/modules/frontleft.json @@ -3,7 +3,7 @@ "front": 12.375, "left": 12.375 }, - "absoluteEncoderOffset": 0, + "absoluteEncoderOffset": 98.438, "drive": { "type": "sparkmax", "id": 2, @@ -16,11 +16,11 @@ }, "encoder": { "type": "cancoder", - "id": 22, + "id": 4, "canbus": null }, "inverted": { "drive": false, - "angle": false + "angle": true } } \ No newline at end of file diff --git a/src/main/deploy/swerve/modules/frontright.json b/src/main/deploy/swerve/modules/frontright.json index b0dd13b..7a257d2 100644 --- a/src/main/deploy/swerve/modules/frontright.json +++ b/src/main/deploy/swerve/modules/frontright.json @@ -3,7 +3,7 @@ "front": 12.375, "left": -12.375 }, - "absoluteEncoderOffset": 0, + "absoluteEncoderOffset": 17.227, "drive": { "type": "sparkmax", "id": 17, @@ -16,11 +16,11 @@ }, "encoder": { "type": "cancoder", - "id": 22, + "id": 5, "canbus": null }, "inverted": { "drive": false, - "angle": false + "angle": true } } \ No newline at end of file diff --git a/src/main/deploy/swerve/modules/pidfproperties.json b/src/main/deploy/swerve/modules/pidfproperties.json index 3834a36..f2faf26 100644 --- a/src/main/deploy/swerve/modules/pidfproperties.json +++ b/src/main/deploy/swerve/modules/pidfproperties.json @@ -7,7 +7,7 @@ "iz": 0 }, "angle": { - "p": 0.0020645, + "p": 0.005, "i": 0, "d": 0, "f": 0, diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 88ff911..293d7a5 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -3,18 +3,15 @@ package frc.robot; public class Constants { //Moteur - public static int lanceur = 0; + public static int lanceur = 10; public static int avantdroitDrive = 17; public static int avantdroitAngle = 18; - public static int avantgaucheDrive = 0; - public static int avantgaucheAngle = 1; + public static int avantgaucheDrive = 2; + public static int avantgaucheAngle = 3; public static int arrieredroitDrive = 11; public static int arrieredroitAngle = 12; public static int arrieregaucheDrive = 8; public static int arrieregaucheAngle = 9; - public static int accumulateur = 9; - - //limit switch - public static int ballon = 10; + public static int accumulateur = 19; } diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index c697e40..0ee7bdb 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -3,8 +3,8 @@ // the WPILib BSD license file in the root directory of this project. package frc.robot; +import edu.wpi.first.math.MathUtil; import edu.wpi.first.networktables.GenericEntry; -import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout; @@ -14,7 +14,6 @@ import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import edu.wpi.first.wpilibj2.command.button.CommandJoystick; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; -import edu.wpi.first.wpilibj2.command.button.JoystickButton; import frc.robot.commands.Avancer; import frc.robot.commands.Force1; import frc.robot.commands.Force2; @@ -45,6 +44,7 @@ public class RobotContainer { GenericEntry force5 = forces.add("Force5", 0).getEntry(); GenericEntry force6 = forces.add("Force6", 0).getEntry(); GenericEntry force7 = forces.add("Force7", 0).getEntry(); + CommandXboxController manette = new CommandXboxController(0); CommandJoystick joystick1 = new CommandJoystick(0); Drive drive = new Drive(); @@ -52,7 +52,7 @@ public class RobotContainer { configureBindings(); drive.setDefaultCommand(new RunCommand(()->{ - drive.drive(joystick1.getX(), -joystick1.getY(), -joystick1.getZ()); + drive.drive(-joystick1.getY(), -joystick1.getX(), MathUtil.applyDeadband(-joystick1.getZ(), 0.2)); },drive)); } diff --git a/src/main/java/frc/robot/commands/Avancer.java b/src/main/java/frc/robot/commands/Avancer.java index 00286c4..476601e 100644 --- a/src/main/java/frc/robot/commands/Avancer.java +++ b/src/main/java/frc/robot/commands/Avancer.java @@ -35,6 +35,6 @@ public class Avancer extends CommandBase { // Returns true when the command should end. @Override public boolean isFinished() { - return false; + return drive.distance()[0].distanceMeters>1; } } diff --git a/src/main/java/frc/robot/commands/Reculer.java b/src/main/java/frc/robot/commands/Reculer.java index 4c474b8..9d67460 100644 --- a/src/main/java/frc/robot/commands/Reculer.java +++ b/src/main/java/frc/robot/commands/Reculer.java @@ -33,6 +33,6 @@ public class Reculer extends CommandBase { // Returns true when the command should end. @Override public boolean isFinished() { - return false; + return drive.distance()[0].distanceMeters>1; } } diff --git a/src/main/java/frc/robot/subsystems/Drive.java b/src/main/java/frc/robot/subsystems/Drive.java index d2391d1..c0aa314 100644 --- a/src/main/java/frc/robot/subsystems/Drive.java +++ b/src/main/java/frc/robot/subsystems/Drive.java @@ -19,7 +19,7 @@ public class Drive extends SubsystemBase { File swerveJsonDirectory = new File(Filesystem.getDeployDirectory(),"swerve"); public void drive(double x, double y, double zRotation){ - swerveDrive.drive(new Translation2d(x, y), zRotation, true, false); + swerveDrive.drive(new Translation2d(x, y), zRotation, false, false); }