Elevator Code

Hi, this is the first time i am coding an elevator for offseason practice. I want to structure my code like littleton robotics( with io layers and such) and couldnt find any elevator example out there. I also dont know the basic programing of an elevator and worked with arms so far. Any help would be appreciated!

Here is 6328’s elevator code from 2024: RobotCode2024/src/main/java/org/littletonrobotics/frc2024/subsystems/superstructure/GenericSlamElevator.java at main · Mechanical-Advantage/RobotCode2024 · GitHub

Couple questions.
What Motors?
What other electronics?
What is the elevator doing?
This would be a start to knowing what needs to be done.

yeah i looked at this but confused as of the logic behind it.

i was thinking 2 krakens with 8:1 ratio. idk if i would need an absolute encoder, if so we recently ordered wcp’s new hex bore encoder. The elevator would be carrying the manipulator which i dont know how much it weights but shouldnt bee much.

The “elevator” subsystems in 6328’s 2024 code aren’t traditional elevators, and use an unusual control scheme. Off the top of my head, I know of 2910 and 5940 that have code for more traditional elevators with IO interfaces from 2023 (I believe both are combined arms and elevators). Neither of those subsystems were written by us and I’m sure there are many more examples out there, but they may at least be a decent starting point.

1 Like

You are so specific about this that I hate to see you discouraged without question. @jonahb55 answer may be perfect (paraphrased) - you don't really want to copy us and here are good examples best for you. I know why I could have written that statement to you but maybe you really want to learn how they do it. There’s a lot to be learned from that code (including how to find the word elevator in the repository, the basics of a Finite State Machine FSM, implementing an interface for multiple different mechanisms and packaging within an abstract class for starters.

You could have a gotten a different answer (if that’s what you want) with your question pointing out details of the structure you are seeking and what part of their code you didn’t understand.

I have a simple example of a Command-Based Goal oriented subsystem (if that’s what you want to see) using a PID controller. The WPILib 2025 beta version is in GitHub - tom131313/Examples. Look at the AchieveHueGoal subsystem.

The several examples are independent and run in simulator mode with a joystick; output is simulated LEDs.

1 Like

Hi, thank you for your response. The particular think about 6328’s 2024 code that i didnt understand was how the elevator actually reached a setpoint. what control did they use. from what i saw they did something with amps which i have no idea how it works.

The “elevators” in our code are actually two-position mechanisms driven by a motor, so they don’t use position control at all. The key requirement was just to move them back and forward to hard stops at the ends of their travel, which we implemented by providing a constant output current to move them up and down. By controlling output current instead of voltage, we don’t need to stop them when they reach the end of their travel since the motors won’t stall. There are a couple of extra details to the implementation but that’s the basic idea.

As I said, this is an unusual control scheme; it worked very well for what we needed but it’s not even close to a traditional position-controlled elevator (because we aren’t controlling the mechanisms to arbitrary positions). It’s closer to a pneumatic mechanism with two states, just driven with motors. The examples linked above are all position-controlled mechanisms, which it what I presume you mean by “elevator.”

1 Like

Yes, thank you for your response

Is there a way to visualise the elevor in advantage scope. Like a 2d mechanism that I can associate with the elevators cad

I would suggest checking this out.

I would start with 2d mechanisms such which will not look like the cad but still show you the state of the system. After that you can try moving to custom assets to use your teams cad

2 Likes