Skip to content

Commit

Permalink
Add height + gearing constants
Browse files Browse the repository at this point in the history
  • Loading branch information
colyic committed Dec 20, 2023
1 parent 9608324 commit 29589f8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/stuypulse/robot/commands/ElevatorDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.CommandBase;

import static com.stuypulse.robot.constants.Settings.Elevator.*;

public class ElevatorDrive extends CommandBase {
private final Elevator elevator;
private IStream velocity;
Expand All @@ -22,8 +24,8 @@ public ElevatorDrive(Gamepad gamepad) {

@Override
public void execute() {
elevator.setTargetHeight(velocity.get());
SmartDashboard.putNumber("Gamepad velocity", velocity.getAsDouble());
elevator.setTargetHeight(velocity.get() * MAX_HEIGHT);
SmartDashboard.putNumber("Gamepad Velocity", velocity.getAsDouble());
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/stuypulse/robot/constants/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
public interface Settings {
public interface Elevator {
double DT = 0.3; // time between each simulation update
double GEARING = 1;
double CARRIAGE_MASS = 15; // kg
double GEARING = 9; // ~9:1
double CARRIAGE_MASS = 10; // kg
double DRUM_RADIUS = 0.025; // meters

double MIN_HEIGHT = 0;
double MAX_HEIGHT = 1.1;
double MAX_HEIGHT = 1.8475325; // meters

double MAX_HEIGHT_ERROR = 0.03;

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/stuypulse/robot/subsystems/Elevator.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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
3 changes: 3 additions & 0 deletions src/main/java/com/stuypulse/robot/subsystems/SimElevator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.stuypulse.robot.constants.Settings.Elevator.*;
import edu.wpi.first.math.system.plant.DCMotor;
import edu.wpi.first.wpilibj.simulation.ElevatorSim;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class SimElevator extends Elevator {
private ElevatorSim sim;
Expand Down Expand Up @@ -32,5 +33,7 @@ public void simulationPeriodic() {

height = sim.getPositionMeters();
velocity = sim.getVelocityMetersPerSecond();

SmartDashboard.putNumber("Height", getHeight());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,5 @@ public void setHeight(double newHeight) {
secondLeftBottomRoot.setPosition(leftRootX + 2 * STAGE_SPACING, secondStageBottomY);
secondRightBottomRoot.setPosition(rightRootX - 2 * STAGE_SPACING, secondStageBottomY);
secondTopRoot.setPosition(leftRootX + 2 * STAGE_SPACING, INNER_STAGE_HEIGHT + secondStageBottomY);

/*
THE FACTS:
- carriage moves at the same speed RELATIVE to teh inner stage
- carriage moves at twice the speed of the inner stage releative to teh observer
(use twice the speed for observer since we have them as separate from each other)
- carriage not connected to inner stage
- carria*/
}
}

0 comments on commit 29589f8

Please sign in to comment.