Skip to content

Commit

Permalink
changed armteleop so its a defualt command instead of periodic in sub…
Browse files Browse the repository at this point in the history
…system
  • Loading branch information
Kenneth-Choothakan committed Jan 19, 2024
1 parent 65dc6b6 commit 1496ebd
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
14 changes: 10 additions & 4 deletions src/main/java/org/carlmontrobotics/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@

package org.carlmontrobotics;

import org.carlmontrobotics.commands.ArmTeleop;
import org.carlmontrobotics.subsystems.Arm;

import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;

import edu.wpi.first.wpilibj.XboxController.Axis;
public class RobotContainer {
//set up subsystems / controllers / limelight

private final XboxController driverController = new XboxController(0);
public Arm arm = new Arm();
public RobotContainer() {
//defaultCommands: elevator, dt
//(pass in controller!)


arm.setDefaultCommand(new ArmTeleop(driverController.getLeftY(() -> ProcessedAxisValue(driverController, Axis.kLeftY))));

configureBindingsDriver();
configureBindingsManipulator();
}
Expand All @@ -31,7 +38,6 @@ private void configureBindingsManipulator() {
//3 setpositions of arm on letterpad
//right joystick used for manual arm control
}

public Command getAutonomousCommand() {
return Commands.print("No autonomous command configured");

Expand Down
42 changes: 42 additions & 0 deletions src/main/java/org/carlmontrobotics/commands/ArmTeleop.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package org.carlmontrobotics.commands;


import java.util.function.DoubleSupplier;

import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.CommandBase;


public class ArmTeleop extends CommandBase {
private final DoubleSupplier joystick;
/** Creates a new ArmTeleop. */
public ArmTeleop(DoubleSupplier joystickSupplier) {
// Use addRequirements() here to declare subsystem dependencies.
joystick = joystickSupplier;
addRequirements();
}

// Called when the command is initially scheduled.
@Override
public void initialize() {}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
double value = joystick.getAsDouble();
}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}

// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}
8 changes: 3 additions & 5 deletions src/main/java/org/carlmontrobotics/subsystems/Arm.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
public class Arm extends SubsystemBase {
private final CANSparkMax armMotor = MotorControllerFactory.createSparkMax(Constants.Arm.MOTOR_PORT,MotorConfig.NEO);
private final SimpleMotorFeedforward armFeed = new SimpleMotorFeedforward(Constants.Arm.kS, Constants.Arm.kV);
private final XboxController controller;
public Arm(XboxController controller) {

public Arm() {
//arm
/*
have 3 set positions
Expand All @@ -39,7 +39,6 @@ public Arm(XboxController controller) {
There will also be a manual control for the arm using the right joystick
*/
this.controller = controller;
}

public void setArmGoal(double targetPosition, double targetVelocity) {
Expand Down Expand Up @@ -71,7 +70,6 @@ public double getArmClampedGoal(double goal) {
}
@Override
public void periodic() {
// run moveArm passing in controller here
controllerMoveArm(controller.getRightY());

}
}

0 comments on commit 1496ebd

Please sign in to comment.