Skip to content

Commit

Permalink
Min height in simulation
Browse files Browse the repository at this point in the history
Co-authored-by: ambers7 <[email protected]>
  • Loading branch information
colyic and ambers7 committed Dec 13, 2023
1 parent 06bdc0e commit 9608324
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
6 changes: 6 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,11 @@
"buttonCount": 0,
"povCount": 0
}
],
"robotJoysticks": [
{
"guid": "78696e70757401000000000000000000",
"useGamepad": true
}
]
}
3 changes: 3 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
}
}
},
"Gamepads": {
"open": true
},
"open": true
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/com/stuypulse/robot/constants/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import com.stuypulse.stuylib.network.SmartNumber;

import edu.wpi.first.math.util.Units;

/*-
* File containing tunable settings for every subsystem on the robot.
*
Expand All @@ -17,13 +15,13 @@
*/
public interface Settings {
public interface Elevator {
double DT = 0.3; //time between each simulation update
double DT = 0.3; // time between each simulation update
double GEARING = 1;
double CARRIAGE_MASS = 15; // kg
double DRUM_RADIUS = 0.025; // meters
double DRUM_RADIUS = 0.025; // meters

double MIN_HEIGHT = 0.1;
double MAX_HEIGHT = 1.5;
double MIN_HEIGHT = 0;
double MAX_HEIGHT = 1.1;

double MAX_HEIGHT_ERROR = 0.03;

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/stuypulse/robot/subsystems/Elevator.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.stuypulse.stuylib.streams.filters.MotionProfile;

import edu.wpi.first.wpilibj.RobotBase;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public abstract class Elevator extends SubsystemBase {
Expand Down Expand Up @@ -64,6 +63,8 @@ public final boolean isReady(double error) {

@Override
public void periodic() {
elevatorVisualizer.setHeight(targetHeight.getAsDouble());
if (targetHeight.getAsDouble() >= MIN_HEIGHT) {
elevatorVisualizer.setHeight(targetHeight.getAsDouble());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class SimElevator extends Elevator {
public SimElevator() {
height = 0.0;
velocity = 0.0;

sim = new ElevatorSim(DCMotor.getNEO(2), GEARING, CARRIAGE_MASS, DRUM_RADIUS, MIN_HEIGHT, MAX_HEIGHT, true);
}

Expand Down

0 comments on commit 9608324

Please sign in to comment.