This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
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
1 parent
528b97f
commit cda7400
Showing
6 changed files
with
92 additions
and
10 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
src/main/java/com/team766/robot/rookie_bot/mechanisms/Elevator.java
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,33 @@ | ||
package.com.team766.robot.rookie_bot.mechanisms; | ||
|
||
|
||
import com.team766.framework.Mechanism; | ||
import com.team766.hal.RobotProvider; | ||
import com.team766.hal.MotorController; | ||
import com.team766.hal.EncoderReader; | ||
|
||
public class Elevator extends Mechanism{ | ||
private MotorController m_elevator; | ||
private EncoderReader m_elevatorEncoder; | ||
|
||
public Elevator() { | ||
m_elevator = RobotProvider.instance.getMotor("elevator"); | ||
m_elevatorEncoder = RobotProvider .instance.getEncoder("elevator_encoder"); | ||
resetEncoder(); | ||
|
||
} | ||
|
||
public void move(double power){ | ||
m_elevator.set(power); | ||
} | ||
|
||
public double getElevatorDistance(){ | ||
return m_elevatorEncoder.getDistance(); | ||
} | ||
|
||
public void resetEncoder(){ | ||
m_elevatorEncoder.reset(); | ||
} | ||
|
||
} | ||
|
25 changes: 19 additions & 6 deletions
25
src/main/java/com/team766/robot/rookie_bot/mechanisms/Launcher.java
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 |
---|---|---|
@@ -1,11 +1,24 @@ | ||
package com.team766.robot.mechanisms; | ||
package com.team766.robot.rookie_bot.mechanisms; | ||
|
||
|
||
import com.team766.framework.Mechanism; | ||
import com.team766.hal.SolenoidController; | ||
import com.team766.hal.RobotProvider; | ||
import com.team766.hal.SolenoidController; | ||
|
||
|
||
public class Launcher extends Mechanism { | ||
private SolenoidController pusher; | ||
|
||
|
||
public Launcher() { | ||
pusher = RobotProvider.instance.getSolenoid("launch"); | ||
} | ||
|
||
|
||
public void setPusher(boolean extended) { | ||
checkContextOwnership(); | ||
|
||
public class Launcher extends Mechanism{ | ||
private SolenoidController pusher; | ||
|
||
public Launcher() | ||
} | ||
pusher.set(extended); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/team766/robot/rookie_bot/procedures/PIDElevator.java
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,33 @@ | ||
package com.team766.robot.rookie_bot.procedures; | ||
|
||
import com.team766.framework.Procedure; | ||
import com.team766.controllers.PIDController; | ||
import com.team766.framework.Context; | ||
import com.team766.robot.rookie_bot.Robot; | ||
|
||
public class PIDElevator extends Procedure { | ||
double setpoint; | ||
PIDController controller; | ||
|
||
public PIDElevator(){ | ||
|
||
this.setpoint = 1; | ||
} | ||
|
||
public void run(Context context){ | ||
context.takeOwnership(Robot.elevator); | ||
Robot.elevator.resetEncoder(); | ||
|
||
controller = new PIDController(0.001, 0, 0.0001, 0, 1, 0.01); | ||
controller.setSetpoint(setpoint); | ||
while (!controller.isDone()) | ||
{ | ||
controller.calculate(Robot.elevator.getElevatorDistance()); | ||
double motor_effort = controller.getOutput(); | ||
Robot.elevator.move(motor_effort); | ||
} | ||
Robot.elevator.move(0); | ||
context.yield(); | ||
} | ||
} | ||
|