Skip to content

Elevator subsystem #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 9, 2025
Merged

Elevator subsystem #57

merged 11 commits into from
Feb 9, 2025

Conversation

Urbanmass
Copy link
Contributor

Last branch is too cooked, told Max C to make another branch so he can fix most of my mistake ;)

@Urbanmass Urbanmass linked an issue Jan 29, 2025 that may be closed by this pull request
Comment on lines +19 to +30
public default void updateInputs(ElevatorInputs inputs) {}

public default double getElevatorPosition() {
return 0.0;
}

public default void setElevatorPosition(double position) {}

public default void setVolts(double volts) {}

public default double getVolts() {
return 0.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make docstrings for all of these methods

elevatorConfig.Slot0.kS = ElevatorConstants.ELEVATOR_S;
elevatorConfig.Slot0.kV = ElevatorConstants.ELEVATOR_V;
elevatorConfig.Slot0.kA = ElevatorConstants.ELEVATOR_A;
elevatorConfig.Slot0.kG = ElevatorConstants.ELEVATOR_G;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't g to like account for gravity? I remember messing with this for charles

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Comment on lines 20 to 34
public double getElevatorPosition() {
return elevatorInterface.getElevatorPosition();
}

public double getVolts() {
return elevatorInterface.getVolts();
}

public void setElevatorPosition(double position) {
elevatorInterface.setElevatorPosition(position);
}

public void setVolts(double volts) {
elevatorInterface.setVolts(volts);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstrings

}

public double getVolts() {
return elevatorInterface.getVolts();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also return inputs.elevatorVolts or whatever it is

}

public double getElevatorPosition() {
return elevatorInterface.getElevatorPosition();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also use the autologged inputs for this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe not bc of conversions

elevatorConfig.Slot0.kS = ElevatorConstants.ELEVATOR_S;
elevatorConfig.Slot0.kV = ElevatorConstants.ELEVATOR_V;
elevatorConfig.Slot0.kA = ElevatorConstants.ELEVATOR_A;
elevatorConfig.Slot0.kG = ElevatorConstants.ELEVATOR_G;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to configure the GravityType

elevatorConfig.Slot0.kS = ElevatorConstants.ELEVATOR_S;
elevatorConfig.Slot0.kV = ElevatorConstants.ELEVATOR_V;
elevatorConfig.Slot0.kA = ElevatorConstants.ELEVATOR_A;
elevatorConfig.Slot0.kG = ElevatorConstants.ELEVATOR_G;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

}

@Override
public void updateInputs(ElevatorInputs inputs) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do a refresh all here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. BaseStatusSignal.refreshAll(signals....)

ElevatorConstants.MAX_HEIGHT,
ElevatorConstants.SIMULATE_GRAVITY,
ElevatorConstants.MIN_HEIGHT,
null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the null for stddevs? if so you can remove it


@Override
public double getElevatorPosition() {
return m_elevatorSim.getPositionMeters();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your units for the position methods (and the inputs) in the sim and physical implementations are inconsistent. Make sure they are the same so you can just call the getElevatorPosition function in Elevator.java without having to worry about units.

They should all be the same units, unless u wanna do conversions and stuff.

public void setElevatorPosition(double position) {
m_pidController.setSetpoint(position);
double output = m_pidController.calculate(getElevatorPosition(), position);
double feedforward = m_feedforward.calculate(m_pidController.getSetpoint());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't feedforward supposed to have velocity as the input?


/** Creates a new ElevatorHardware. */
private final TalonFX leaderMotor = new TalonFX(ElevatorConstants.ELEVATOR_LEADER_MOTOR_ID);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this new line

import org.littletonrobotics.junction.Logger;

public class Elevator extends SubsystemBase {
/** Creates a new Elevator. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what

the constructor creates a new elevator. not the elevator interface.

@Ishan1522 Ishan1522 merged commit bb2f798 into main Feb 9, 2025
4 checks passed
@Ishan1522 Ishan1522 deleted the elevator-no-errors-maxc branch February 25, 2025 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Write elevator code
5 participants