Skip to content
Open

. #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion KitbotPID/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2025.1.1"
id "edu.wpi.first.GradleRIO" version "2025.3.2"
}

java {
Expand Down
8 changes: 8 additions & 0 deletions KitbotPID/src/main/deploy/swerve/controllerproperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"angleJoystickRadiusDeadband": 0.5,
"heading": {
"p": 0.4,
"i": 0,
"d": 0.01
}
}
27 changes: 27 additions & 0 deletions KitbotPID/src/main/deploy/swerve/modules/backleft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"location": {
"front": -12,
"left": 12
},
"absoluteEncoderOffset": 0,
"drive": {
"type": "falcon",
"id": 0,
"canbus": null
},
"angle": {
"type": "falcon",
"id": 0,
"canbus": null
},
"encoder": {
"type": "none",
"id": 0,
"canbus": null
},
"inverted": {
"drive": false,
"angle": false
},
"absoluteEncoderInverted": false
}
27 changes: 27 additions & 0 deletions KitbotPID/src/main/deploy/swerve/modules/backright.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"location": {
"front": -12,
"left": -12
},
"absoluteEncoderOffset": 0,
"drive": {
"type": "krakenx60",
"id": 0,
"canbus": null
},
"angle": {
"type": "falcon",
"id": 0,
"canbus": null
},
"encoder": {
"type": "none",
"id": 0,
"canbus": null
},
"inverted": {
"drive": false,
"angle": false
},
"absoluteEncoderInverted": false
}
27 changes: 27 additions & 0 deletions KitbotPID/src/main/deploy/swerve/modules/frontleft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"location": {
"front": 12,
"left": 12
},
"absoluteEncoderOffset": 0,
"drive": {
"type": "krakenx60",
"id": 0,
"canbus": null
},
"angle": {
"type": "falcon",
"id": 0,
"canbus": null
},
"encoder": {
"type": "none",
"id": 0,
"canbus": null
},
"inverted": {
"drive": false,
"angle": false
},
"absoluteEncoderInverted": false
}
27 changes: 27 additions & 0 deletions KitbotPID/src/main/deploy/swerve/modules/frontright.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"location": {
"front": 12,
"left": -12
},
"absoluteEncoderOffset": 0,
"drive": {
"type": "krakenx60",
"id": 0,
"canbus": null
},
"angle": {
"type": "falcon",
"id": 0,
"canbus": null
},
"encoder": {
"type": "none",
"id": 0,
"canbus": null
},
"inverted": {
"drive": false,
"angle": false
},
"absoluteEncoderInverted": false
}
24 changes: 24 additions & 0 deletions KitbotPID/src/main/deploy/swerve/modules/physicalproperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"optimalVoltage": 12,
"robotMass": 110.2311,
"wheelGripCoefficientOfFriction": 1.19,
"currentLimit": {
"drive": 20,
"angle": 20
},
"conversionFactors": {
"angle": {
"gearRatio": 0,
"factor": 0
},
"drive": {
"diameter": 4,
"gearRatio": 6.5,
"factor": 0
}
},
"rampRate": {
"drive": 0.25,
"angle": 0.25
}
}
16 changes: 16 additions & 0 deletions KitbotPID/src/main/deploy/swerve/modules/pidfproperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"drive": {
"p": 0.0020645,
"i": 0,
"d": 0,
"f": 0,
"iz": 0
},
"angle": {
"p": 0.0020645,
"i": 0,
"d": 0,
"f": 0,
"iz": 0
}
}
14 changes: 14 additions & 0 deletions KitbotPID/src/main/deploy/swerve/swervedrive.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"imu": {
"type": "navx_onboard",
"id": 0,
"canbus": null
},
"invertedIMU": false,
"modules": [
"frontleft.json",
"frontright.json",
"backleft.json",
"backright.json"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package Dropper;

public class SparkClosedLoopController {

}
4 changes: 4 additions & 0 deletions KitbotPID/src/main/java/frc/robot/SwerveMovement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package frc.robot;

public class SwerveMovement {
);
33 changes: 33 additions & 0 deletions KitbotPID/src/main/java/frc/robot/commands/SwerveComand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 edu.wpi.first.wpilibj2.command.Command;

/* 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 SwerveComand extends Command {
/** Creates a new SwerveComand. */
public SwerveComand() {
// 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() {}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}

// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}
42 changes: 39 additions & 3 deletions KitbotPID/src/main/java/frc/robot/subsystems/CoralReleaser.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.revrobotics.spark.SparkBase.PersistMode;
import com.revrobotics.spark.SparkBase.ResetMode;
import com.revrobotics.spark.SparkClosedLoopController;
import com.revrobotics.spark.SparkFlex;
import com.revrobotics.spark.SparkLowLevel.MotorType;
import com.revrobotics.spark.config.SparkMaxConfig;
import com.revrobotics.spark.SparkMax;
Expand All @@ -19,21 +20,45 @@
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class CoralReleaser extends SubsystemBase {

double kP = 0.0;
double kI = 0.0;
double kD = 0.0;
double targetRPM = 0.0;
/*

* Creates a Sparkmax Object so we can control the Sparkmax that is plugged into the motor
* The name of the object is dropper, the ID is 5 and the motor is brushed (it's a CIM motor)
*/
private SparkMax Dropper = new SparkMax(5,MotorType.kBrushless);
/*
* Hint: Objects and variables are declared here
*/
Dropper.SparkClosedLoopController coralController = new Dropper.SparkClosedLoopController();
public CoralReleaser() {
RelativeEncoder coralEncoder;
coralEncoder = Dropper.getEncoder();


public CoralReleaser() {
/*
* Hint: This is where the NEO's and Sparkmax's settings and/or configurations are set up.
* Anything that interacts with the NEOs and Sparkmax goes here too

*/
SparkMaxConfig DropperConfig = new SparkMaxConfig();
// Set PID gains
DropperConfig.closedLoop
.p(kP).i(kI).d(kD);


CoralReleaser.configure(coralEncoder, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);

// Initialize the motor (Flex/MAX are setup the same way)







// For Elastic and Advtange Scope
SmartDashboard.putNumber("PID/kP", kP);
Expand All @@ -45,9 +70,17 @@ public CoralReleaser() {
/*
* Hint: New Commands and Methods go here
*/

public Command PIDCMD(double newtargetRPM){
return runOnce(
() -> {
coralController.setReference(newtargetRPM, ControlType.kVelocity);
}
);
}

@Override
// This method will be called once per scheduler run
// This method wll be called once per scheduler run
public void periodic() {
// For Elastic and Advtange Scope
double newP = SmartDashboard.getNumber("PID/kP", kP);
Expand All @@ -59,4 +92,7 @@ public void periodic() {
SmartDashboard.putNumber("Dropper Velocity", coralEncoder.getVelocity()); // Actual velocity

}

}


Loading