FRC2706 / 2019-2706-Robot-Code

The main robot code for the FIRST 2019 challenge: Deep Space
MIT License
2 stars 0 forks source link

Mechanisms #112

Closed KyleRAnderson closed 5 years ago

KyleRAnderson commented 5 years ago

Since we are running out of time and everyone else is waiting on mechanisms to get their stuff done, this is allowed to be merged without automated tests for now. Automated tests should come later.

Closes #109, closes #103, closes #107, closes #87, closes #86, closes #79.

Summary of Changes

Testing Performed

Environment: All mechanism code has been tested on the practice bot (cosmobot).

KyleRAnderson commented 5 years ago

The driver assist vision tests are validly failing for some reason, not too sure why. Will keep looking in to it, but it may be a while before they are fixed.

robertlucyshyn commented 5 years ago

Strange. Are the Pathfinder libraries missing? What about that JSON file with the name "old" in it? (Don't have access to code at the moment.) The Pathfinder libraries ended up in sensors I believe. (Maybe they should be in command or somewhere else.) Please provide details when you can. Robert On Tuesday, March 5, 2019, 12:35:52 p.m. EST, Kyle Anderson notifications@github.com wrote:

The driver assist vision tests are validly failing for some reason, not too sure why. Will keep looking in to it, but it may be a while before they are fixed.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

ryanlarkin commented 5 years ago

@robertlucyshyn, it's still there, but because there were no changes to it, it won't show up in the diff for this pull request. It can be found here.

KyleRAnderson commented 5 years ago

@eandr127 @carmen1234 @Zinka010 ready to merge this now.

KyleRAnderson commented 5 years ago

Requested changes have been made. Not sure what to do about overrunning the loop time yet.

On Wed, Mar 6, 2019, 21:45 Ryan Larkin notifications@github.com wrote:

@eandr127 requested changes on this pull request.

Mostly Javadoc and formatting needs work. Tests can be ignored for now.

In src/main/java/ca/team2706/frc/robot/OI.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263217736 :

  • new FluidButton(controlStick, Config.LIFT_SECOND_SETPOINT_BINDING)
  • .whenHeld(new MoveLiftToSetpoint(1));
  • new FluidButton(controlStick, Config.LIFT_THIRD_SETPOINT_BINDING)
  • .whenHeld(new MoveLiftToSetpoint(2));
  • new FluidButton(controlStick, Config.LIFT_FOURTH_SETPOINT_BINDING)
  • .whenHeld(new MoveLiftToSetpoint(3));
  • new FluidButton(controlStick, Config.MANUAL_PISTON_BINDING)
  • .whenPressed(new MovePlunger());
  • FluidButton button = new FluidButton(controlStick, Config.EJECT_BINDING);
  • LiftPosition position = new LiftPosition();
  • button.whenHeld(new EjectConditional(position));
  • button.whenReleased(new AfterEjectConditional(position::getPosition));
  • new FluidButton(controlStick, Config.AUTO_INTAKE_CARGO_BINDING)
  • .whenHeld(new AutoIntakeCargo());
  • new FluidButton(controlStick, Config.TOGGLE_RING_LIGHT_BINDING)
  • .whenPressed(new ToggleRingLight());
     // Operator controls
     new FluidButton(driverStick, Config.DRIVER_ASSIST_VISION_CARGO_AND_LOADING_BINDING)

Double check whether these should be whenPressed() or whenHeld().

In src/main/java/ca/team2706/frc/robot/Robot.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263217791 :

@@ -77,6 +80,7 @@ public void robotInit() { new StraightDriveGyro(0.2, 2.0, 100), // 4 new FollowTrajectoryFromFile(1.0, 100, "Test")//5 }; +

Unnecessary newline

In src/main/java/ca/team2706/frc/robot/commands/intake/arms/LowerArms.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263217851 :

@@ -0,0 +1,27 @@ +package ca.team2706.frc.robot.commands.intake.arms; + +import ca.team2706.frc.robot.config.Config; +import ca.team2706.frc.robot.subsystems.Pneumatics; +import edu.wpi.first.wpilibj.command.TimedCommand; + +/**

    • Lowers the intake arms in preparation for dealing with cargo
  • */ +public class LowerArms extends TimedCommand {
  • public LowerArms() {

Missing javadoc

In src/main/java/ca/team2706/frc/robot/commands/intake/arms/LowerArmsSafely.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263217885 :

@@ -0,0 +1,16 @@ +package ca.team2706.frc.robot.commands.intake.arms; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/**

    • Lowers the arms, checking if the plunger is stowed beforehand and lowering it safely if not.
  • */ +public class LowerArmsSafely extends CommandGroup {
  • /**

Needs extra newline

In src/main/java/ca/team2706/frc/robot/commands/intake/arms/MovePlunger.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263217942 :

@@ -0,0 +1,71 @@ +package ca.team2706.frc.robot.commands.intake.arms; + +import ca.team2706.frc.robot.config.Config; +import ca.team2706.frc.robot.subsystems.Pneumatics; +import edu.wpi.first.wpilibj.command.TimedCommand; + +/**

    • Command for moving the plunger, either retracting it or expanding it.
    • Timeout is to ensure that the command ends when the plunger is in the right position.
  • */ +public class MovePlunger extends TimedCommand {
  • private DesiredState oldState;
  • public enum DesiredState {

Needs Javadoc

In src/main/java/ca/team2706/frc/robot/commands/intake/arms/RaiseArms.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263217976 :

@@ -0,0 +1,28 @@ +package ca.team2706.frc.robot.commands.intake.arms; + +import ca.team2706.frc.robot.config.Config; +import ca.team2706.frc.robot.subsystems.Pneumatics; +import edu.wpi.first.wpilibj.command.TimedCommand; + +/**

    • Raises the intake arms to prepare for handling hatches.
  • */ +public class RaiseArms extends TimedCommand {
  • public RaiseArms() {

Javadoc

In src/main/java/ca/team2706/frc/robot/commands/intake/arms/RaiseArmsSafely.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263217996 :

@@ -0,0 +1,13 @@ +package ca.team2706.frc.robot.commands.intake.arms; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/**

    • Command group for safely raising the arms by checking and retracting the pneumatic piston.
  • */ +public class RaiseArmsSafely extends CommandGroup {
  • public RaiseArmsSafely() {

Javadoc

In src/main/java/ca/team2706/frc/robot/commands/intake/cargo/RunIntakeAtSpeed.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263218068 :

@@ -0,0 +1,33 @@ +package ca.team2706.frc.robot.commands.intake.cargo; + +import ca.team2706.frc.robot.subsystems.Intake; +import edu.wpi.first.wpilibj.command.Command; + +/**

    • Command for running the intake motors at the given speed.
  • */ +public class RunIntakeAtSpeed extends Command {
  • private final double speed;
  • /**
    • @param speed The intake motor speed, from 0 to 1.
  • */
  • public RunIntakeAtSpeed(double speed) {

Missing description (although there isn't much to say)

In src/main/java/ca/team2706/frc/robot/commands/intake/cargo/RunIntakeOnJoystick.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263218126 :

  • Intake.getInstance().runIntakeForward(speed);
  • } else {
  • Intake.getInstance().runIntakeBackward(speed);
  • }
  • }
  • @Override
  • public void end() {
  • Intake.getInstance().stop();
  • }
  • @Override
  • protected boolean isFinished() {
  • return false;
  • }

Extra newline

In src/main/java/ca/team2706/frc/robot/commands/lift/MoveLiftJoystickVelocity.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263218174 :

+import ca.team2706.frc.robot.config.Config; +import ca.team2706.frc.robot.config.FluidConstant; +import ca.team2706.frc.robot.config.XboxValue; +import ca.team2706.frc.robot.subsystems.Lift; +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.command.Command; + +/**

    • Command for moving the lift on joystick input using velocity.
  • */ +public class MoveLiftJoystickVelocity extends Command {
  • private final Joystick controller;
  • private int axisPort;
  • public MoveLiftJoystickVelocity(Joystick joystick, final FluidConstant portBinding) {

Javadoc

In src/main/java/ca/team2706/frc/robot/commands/lift/MoveLiftToPosition.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263218239 :

@@ -0,0 +1,45 @@ +package ca.team2706.frc.robot.commands.lift; + +import ca.team2706.frc.robot.subsystems.Lift; +import edu.wpi.first.wpilibj.command.Command; + +import java.util.function.Supplier; + +public class MoveLiftToPosition extends Command {

Javadoc

In src/main/java/ca/team2706/frc/robot/commands/ringlight/ToggleRingLight.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263218282 :

@@ -0,0 +1,20 @@ +package ca.team2706.frc.robot.commands.ringlight; + +import ca.team2706.frc.robot.subsystems.RingLight; +import edu.wpi.first.wpilibj.command.InstantCommand; + +/**

    • Command for toggling the ring light.
  • */ +public class ToggleRingLight extends InstantCommand {
  • public ToggleRingLight() {

Javadoc

In src/main/java/ca/team2706/frc/robot/config/Config.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263218492 :

 public static final double PIGEON_DPP = robotSpecific(360.0 / 8192.0, 360.0 / 8192.0, 360.0 / 8192.0);
  • public static final boolean ENABLE_CAMERA = robotSpecific(true, true, false);
  • public static final boolean ENABLE_CAMERA = robotSpecific(true, true, true);

We have this disabled in case the simulation robot because there won't be a camera. Is there a reason that you changed it?

In src/main/java/ca/team2706/frc/robot/config/Config.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263218663 :

  • public static final double INTAKE_ARMS_DELAY = 1.0;
  • /**
    • How much height (in feet) to subtract from the lift's height for ejecting hatches.
  • */
  • public static final double SUBTRACT_LIFT_HEIGHT = -0.125;
  • /**
    • How far from the top and the bottom of the lift that the lift should begin to slow down, in manual control.
  • */
  • public static final double LIFT_SLOWDOWN_RANGE_UP = 0.5;
  • public static final double LIFT_SLOWDOWN_RANGE_DOWN = 1.0;
  • public static final double MAX_INTAKE_SPEED = 1.0; //to be finalized later, this has yet to be tested
  • public static final double[] ENCODER_LIFT_PID_UP = {0.5, 0, 50}; //to be finalized later, these values have not yet been tested

Is this different from the fluid constants below for Lift PID?

In src/main/java/ca/team2706/frc/robot/subsystems/Intake.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263218828 :

  • this(new VictorSPX(Config.INTAKE_MOTOR_ID),
  • new AnalogInput(Config.CARGO_IR_SENSOR_ID));
  • }
  • @Override
  • public void initDefaultCommand() {
  • }
  • /**
    • Getting the voltage from the IR sensor.
  • *
    • @return the voltage reading
  • */
  • public double readIr() {
  • return irSensor.getAverageVoltage();

Needs formatting

In src/main/java/ca/team2706/frc/robot/subsystems/Lift.java https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#discussion_r263218986 :

  • default:
  • setpoints = new int[0];
  • break;
  • }
  • return setpoints;
  • }
  • /**
    • Sets the position for the talons to reach.
  • *
    • @param maxSpeed Maximum speed at which to travel, from 0 to 1.
    • @param position The position, in feet.
  • */
  • public void setPosition(final double maxSpeed, final double position) {
  • setPositionEncoderTicks( maxSpeed,position / Config.LIFT_ENCODER_DPP);

Extra space

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/FRC2706/2019-2706-Robot-Code/pull/112#pullrequestreview-211575592, or mute the thread https://github.com/notifications/unsubscribe-auth/AVjzEDPKIWSVkQ_uT9Va-7RHGW2benkvks5vUH07gaJpZM4bfHXs .

KyleRAnderson commented 5 years ago

Resolved all problems.