Our SlideRack is supposed to climb, but it turns into a jackhammer?

hello, back for help again lol,

so our robot has a code for climbing. While a button is pressed, it is supposed to raise up our SlideRack. I’ve tried doing a lot of trouble shooting, asking for help, research, trying to see if I can fix it, but it’s taking so long and Regoinals are right around the corner.

Instead of raising at the press of a button, our motor sends out like rapid pulses, pulling and pushing our rod which holds the cords for our pullys. I think there is something with the code that tells it to call it every second but I can’t seem to find it, I’m still fairly new to this. And also worth noting we’re trying to use encoders to restrict the height of our arm

Here’s my git:

If anyone could help me, that would be fantastic
Thank You!

I haven’t used encoders as DIO inputs, but maybe consider looking into that? I think getDistance() in your subsystem might be wrong.

You never set the encoders DistancePerPulse, so it doesn’t know what distance it is at

Try looking into that first

If im reading your code right then as long as you are pressing button 5 it is cycling between debounce is equal true and false every cycle

  1. debounce == false -> debounce = true && isUp = true
  2. debounce == true -> debounce = false
  3. debounce == false -> debounce = true && isUp = false
  4. debounce == true -> debounce = false

So every 4 cycles it resets and repeats

So now since you are changing isUp every 2 cycles it is going between position 20 and 0 every 2 cycles

i just had to change it to getDistance, but it doesnt seem like the encoders are doing anything. Our climber works and everything, but its supposed to stop once the encoder reaches a certain rotation

I would suggest posting your encoder information to the smart dashboard to look at the values you are getting there

how do i do that, because i go to the dashboard and theres nothing, like actually nothing, its just a blank white screen

In SlideRack::periodic, put SmartDashboard.putNumber("SlideRack encoder value", slideRackEncoder.getDistance());

https://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/smartdashboard/SmartDashboard.html

the problem was that the encoders weren’t being detected to their target values, it kept jumping from 0 to 20 in its interval.

thank you!!!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.