Skip to content

Commit

Permalink
joystickmotor 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ss0g committed Jan 15, 2022
1 parent b05d9ad commit 9958e57
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/spartronics4915/frc/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public final class Constants
public static final class OI
{
public static final int kJoystickId = 0;
public static final int kDriveStraightDriveStickButton = 8;

// this block also copied from ir2020 (magic)
public static final int kButtonBoardId = 1;
Expand All @@ -45,6 +46,15 @@ public DeviceSpec(String nm, int id, int nbut)
}
}

// from atlas 2020
public static final class DriveStraightConstants
{
public static final double kP = 0; // Was 0.4
public static final double kI = 0.2;
public static final double kD = 0;
public static final double kAllowedError = 0; // In degrees
}

public static final class JoystickMotorConstants
{
public static final double kMotorSpeedMultiplier = 1;
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/com/spartronics4915/frc/RobotContainer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.spartronics4915.frc;

import com.spartronics4915.frc.Constants;
import com.spartronics4915.frc.commands.ExampleCommand;
import com.spartronics4915.frc.commands.JoystickMotorCommands;
import com.spartronics4915.frc.subsystems.ExampleSubsystem;
Expand All @@ -11,6 +12,10 @@
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import edu.wpi.first.wpilibj2.command.PIDCommand;
import edu.wpi.first.wpilibj2.command.ScheduleCommand;
import edu.wpi.first.wpilibj.controller.PIDController;
import edu.wpi.first.wpilibj.RobotBase;

//
Expand All @@ -31,7 +36,8 @@ public class RobotContainer
// public final ExampleCommand mAutoCommand;
public final JoystickMotorCommands mJoystickMotorCommands;

private final int mJoystickPort = Constants.OI.kJoystickId;
// private final int kJoystickPort = Constants.OI.kJoystickId;
public static final Joystick mDriverController = new Joystick(Constants.OI.kJoystickId);

/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer()
Expand All @@ -47,10 +53,15 @@ public RobotContainer()

configureButtonBindings();
SmartDashboard.putString("Container","Completed");

mJoystickMotor.setDefaultCommand(new JoystickMotorCommands(mJoystickMotor));
}

/** Use this method to define your button ==> command mappings. */
private void configureButtonBindings() {}
private void configureButtonBindings()
{

}

/**
* Use this to pass the autonomous command to the main {@link Robot} class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import com.spartronics4915.frc.Constants;
import com.spartronics4915.frc.subsystems.JoystickMotor;

public class JoystickMotorCommands
public class JoystickMotorCommands extends CommandBase
{
private final JoystickMotor mMotor;
private final JoystickMotor mJoystickMotor;
private final Joystick mJoystick;
private boolean mInverted;
private boolean mSlow;

public JoystickMotorCommands(JoystickMotor motor)
{
mMotor = motor;
mJoystickMotor = motor;
mJoystick = motor.getJoystick();
mInverted = false;
mSlow = false;
Expand All @@ -25,7 +25,7 @@ public class TeleOpCommand extends CommandBase
{
public TeleOpCommand()
{
addRequirements(mMotor);
addRequirements(mJoystickMotor);
}

@Override
Expand All @@ -45,7 +45,7 @@ public void execute()

// copied from 2020-InfiniteRecharge, no idea how it works (magic)
y = Math.copySign(Math.pow(Math.abs(y), 5.0/3.0), y); // apply response curve
mMotor.set(applyDeadzone(y, Constants.JoystickMotorConstants.kJoystickDeadzone));
mJoystickMotor.set(applyDeadzone(y, Constants.JoystickMotorConstants.kJoystickDeadzone));
}

// also copied from ir2020
Expand Down

0 comments on commit 9958e57

Please sign in to comment.