Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
we worked on PID elevator again in a new way.
Browse files Browse the repository at this point in the history
  • Loading branch information
Driver Station Computer committed Dec 15, 2024
1 parent f6e5efd commit 14ed720
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/com/team766/robot/candle_bot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ public OI() {
}

public void run(final Context context) {

context.takeOwnership(Robot.elevator);
while (true) {
// wait for driver station data (and refresh it using the WPILib APIs)
context.waitFor(() -> RobotProvider.instance.hasNewDriverStationData());
RobotProvider.instance.refreshDriverStationData();

if(joystick0.getButtonPressed(1)){
Robot.candle.LED();
Robot.elevator.setPosition (10);
}

if(joystick0.getButtonPressed(2)){
Robot.candle.stop();

Robot.elevator.setPosition (150);
}

// Add driver controls here - make sure to take/release ownership
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/team766/robot/candle_bot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
import com.team766.framework.AutonomousMode;
import com.team766.framework.Procedure;
import com.team766.hal.RobotConfigurator;
import com.team766.robot.candle_bot.mechanisms.Elevator;
import com.team766.robot.candle_bot.mechanisms.candle;
import com.team766.robot.example.mechanisms.*;

public class Robot implements RobotConfigurator {
public static candle candle;

public static Elevator elevator;

// Declare mechanisms (as static fields) here

@Override
public void initializeMechanisms() {
candle = new candle();
elevator = new Elevator();
// Initialize mechanisms here
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.team766.robot.candle_bot.mechanisms;

import com.team766.framework.Mechanism;
import com.team766.hal.MotorController;
import com.team766.hal.RobotProvider;

public class Elevator extends Mechanism{
private MotorController elevatormotor;

public Elevator(){
elevatormotor = RobotProvider.instance.getMotor("Elevator.elevatormotor");
elevatormotor.setSensorPosition(0);
}
public void setPosition(double position) {
checkContextOwnership();
elevatormotor.set(MotorController.ControlMode.Position, position);
}
public void run(){
log("elevator encoder: " + elevatormotor.getSensorPosition());
}

}

0 comments on commit 14ed720

Please sign in to comment.