Team-5509 / PrincessZeta

2020 Robot
2 stars 0 forks source link

driveXFeet command (parameterized) #18

Closed her0me closed 4 years ago

her0me commented 4 years ago

should take negatives

her0me commented 4 years ago

I started following this https://github.com/REVrobotics/SPARK-MAX-Examples/blob/master/Java/Velocity%20Closed%20Loop%20Control/src/main/java/frc/robot/Robot.java is it the right start?

her0me commented 4 years ago

I dont know where to go now for this

Shalmezad commented 4 years ago

1) You'll need to redo the command in robot builder as presently it's not paramaterized. It should take 2 parameters: feet, and max speed. 2) Add a second constructor for just feet, call the other constructor with a speed of 0.3. 3) Create a PIDController in the class. 4) During execute() figure out the feet you've gone based on the encoder ticks (there should be something like frontLeftMotor.getSelectedSensorPosition(), check the docs). 5) Once you have the ticks you've gone, call pidController.calculate(). One parameter is the feet you've gone, the other is the feet you're trying to reach (the parameter you passed in the constructor). Use the result to feed the motors 6) In isFinished(), return pidController.isAtSetpoint() 7) Make sure to stop the drive train in end() and interrupted().

her0me commented 4 years ago

okay, I added everything now, committing now.

her0me commented 4 years ago

the setpoint is not setting to the m_feet like I am expecting it to

Shalmezad commented 4 years ago

https://github.com/Team-5509/PrincessZeta/blob/master/PrincessZeta2020/src/main/java/frc/robot/commands/DriveXFeet.java#L60 initialEncoderPosition needs to be set in initialize (when you start the command).

Shalmezad commented 4 years ago

https://github.com/Team-5509/PrincessZeta/blob/master/PrincessZeta2020/src/main/java/frc/robot/commands/DriveXFeet.java#L54 DRY (don't repeat yourself). Call this(feet, 0.5). See info on constructor chaining for more details.

Shalmezad commented 4 years ago

https://github.com/Team-5509/PrincessZeta/blob/master/PrincessZeta2020/src/main/java/frc/robot/commands/DriveXFeet.java#L69 Make sure to call pidController.reset() in initialize.

Shalmezad commented 4 years ago

During execute(), throw pidController.getPositionError() on the smart dashboard to help debugging.

Shalmezad commented 4 years ago

https://github.com/Team-5509/PrincessZeta/blob/master/PrincessZeta2020/src/main/java/frc/robot/commands/DriveXFeet.java#L67 Our encoders don't loop, remove enableContinuousInput (only for things where max = min, like analog encoders, or gyros where 180 = -180)

her0me commented 4 years ago

I reupped the code, It has the stuff we have been throwing on smart dashboard. the setpoint is stuck at 0.7 when I want it to be 10

her0me commented 4 years ago

okay, the continous input thing fixed it

her0me commented 4 years ago

How do I set a max speed then?

Shalmezad commented 4 years ago

You'll have to manually do it. Pidcontroller calculate will always return (-1,1). So, if you want it to be (-0.5, 0.5)...

On Sat, Feb 15, 2020, 4:04 PM Corbin notifications@github.com wrote:

How do I set a max speed then?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Team-5509/PrincessZeta/issues/18?email_source=notifications&email_token=AALH5ZUKVO5KXUKSBHHDR7TRDBKGNA5CNFSM4KQUS3NKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL3W5ZA#issuecomment-586641124, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALH5ZQBDBGSR6TJ3MT46ZTRDBKGNANCNFSM4KQUS3NA .

her0me commented 4 years ago

ok

her0me commented 4 years ago

Ready to test on main robot