-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
4,262 additions
and
22 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com._604robotics.robot2020.modules; | ||
|
||
import com._604robotics.robot2020.constants.Calibration; | ||
import com._604robotics.robot2020.constants.Ports; | ||
import com._604robotics.robotnik.Action; | ||
import com._604robotics.robotnik.Module; | ||
import com._604robotics.robotnik.Output; | ||
import com._604robotics.robotnik.prefabs.devices.NEOEncoder; | ||
import com._604robotics.robotnik.prefabs.motorcontrol.Motor; | ||
import com._604robotics.robotnik.prefabs.motorcontrol.QuixSparkMAX; | ||
import com._604robotics.robotnik.prefabs.motorcontrol.controllers.MotorControllerPIDConfig; | ||
import com._604robotics.robotnik.prefabs.motorcontrol.controllers.SparkPID; | ||
import com.revrobotics.CANSparkMax.IdleMode; | ||
import com.revrobotics.CANSparkMax.SoftLimitDirection; | ||
import com.revrobotics.CANSparkMaxLowLevel.PeriodicFrame; | ||
|
||
public class Climber extends Module { | ||
private QuixSparkMAX climbMotor = new QuixSparkMAX(Ports.CLIMBER_MOTOR, "Climber Motor", Motor.kNEO, this); | ||
|
||
private NEOEncoder climbEncoder = new NEOEncoder(climbMotor); | ||
private SparkPID climbPID = new SparkPID(climbMotor, climbEncoder, new MotorControllerPIDConfig(0.03, 0, 0)); | ||
|
||
public final Output<Double> climbPosition = addOutput("Climb Position", () -> climbEncoder.getPosition()); | ||
|
||
public Climber() { | ||
super(Climber.class); | ||
climbMotor.controller.getEncoder().setPosition(0.0); | ||
|
||
climbMotor.controller.setIdleMode(IdleMode.kBrake); | ||
climbMotor.controller.setSoftLimit(SoftLimitDirection.kForward, 365); | ||
|
||
climbMotor.controller.setPeriodicFramePeriod(PeriodicFrame.kStatus1, 100); | ||
climbMotor.controller.setPeriodicFramePeriod(PeriodicFrame.kStatus2, 100); | ||
|
||
climbMotor.setCurrentLimit(60); | ||
|
||
setDefaultAction(idle); | ||
} | ||
|
||
public class Idle extends Action { | ||
|
||
public Idle() { | ||
super(Climber.this, Idle.class); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
climbMotor.set(0.0); | ||
} | ||
} | ||
|
||
public class Extend extends Action { | ||
|
||
public Extend() { | ||
super(Climber.this, Extend.class); | ||
} | ||
|
||
@Override | ||
public void begin() { | ||
climbPID.setSetpointPosition(climbEncoder.getPosition() + 160); | ||
} | ||
} | ||
|
||
public class Retract extends Action { | ||
|
||
public Retract() { | ||
super(Climber.this, Retract.class); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
climbMotor.set(-0.25); | ||
} | ||
} | ||
|
||
public class Climb extends Action { | ||
|
||
public Climb() { | ||
super(Climber.this, Climb.class); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
|
||
climbMotor.set(Calibration.Climber.CLIMB_SPEED); | ||
} | ||
} | ||
|
||
public Action idle = new Idle(); | ||
public Action extend = new Extend(); | ||
public Action retract = new Retract(); | ||
public Action climb = new Climb(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters