Skip to content

Commit

Permalink
Added: VikingPigeon, more documentation, and deadband to controllers.…
Browse files Browse the repository at this point in the history
… Changed: Variable names and position of code within some classes
  • Loading branch information
towner-10 committed Feb 15, 2020
1 parent 1f8cc4d commit dead390
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 137 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The JitPack is based off of FRC 1540s library ROOSTER and you can go check it ou
### Controller
`viking.Controller`

Includes support for X-Box One Controller for driving.
Includes support for X-Box One Controller with pre-made inverts for proper values.

### CSV File Manager
`viking.CSVFileManager`
Expand Down Expand Up @@ -38,15 +38,30 @@ A custom PID Controller for closed-loop control on FRC robots. Probably will be
Modular speed controller for our swerve robot since we don't have enough of one motor controller.

### VikingSPX
`viking.controllers.VikingSPX`
`viking.controllers.ctre.VikingSPX`

Wrapper for VictorSPX from CTRE. Includes easy to use controls + ability to follow master controllers.

### VikingSRX
`viking.controllers.VikingSPX`
`viking.controllers.ctre.VikingSPX`

Wrapper for TalonSRX from CTRE. Includes easy to use controls + closed-loop control + motion profiling.

### VikingPigeon
`viking.controllers.ctre.VikingPigeon`

Wrapper for PigeonIMU from CTRE. More features to come in future updates when we actually get a PigeonIMU.

### VikingMAX
`viking.controllers.rev.VikingMAX`

Wrapper for CANSparkMAX from REV Robotics. Includes easy to use controls + closed-loop control + smart motion + follower controllers.

### ColorSensor
`viking.controllers.rev.ColorSensor`

Wrapper for ColorSensorV3 from REV Robotics. Comes with matcher for detecting colours from the sensor output.

### LED Controller
`viking.led.LEDController`

Expand Down Expand Up @@ -78,7 +93,10 @@ dependencies {
}
```

Additionally, you should be using the latest version of GradleRIO with CTRE Phoenix vendor libraries installed.
Make sure you have the following `vendordeps` added to your project.
- Phoenix
- REVColorSensorV3
- REVRobotics

We use [JitPack](https://jitpack.io) as a Gradle/Maven repository. This means that if you add the project using Gradle it will be automatically updated with the latest changes to the `master` branch, as well as source code and documentation .jar files.

Expand Down
200 changes: 107 additions & 93 deletions src/main/java/viking/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,106 +4,120 @@

public class Controller {

private XboxController controller;
private XboxController controller;

private double lTriggerDeadband = 0;
private double rTriggerDeadband = 0;
private double lTriggerDeadband = 0;
private double rTriggerDeadband = 0;

private double lJoystickDeadbandX = 0;
private double lJoystickDeadbandY = 0;
private double lJoystickDeadbandX = 0;
private double lJoystickDeadbandY = 0;

private double rJoystickDeadbandX = 0;
private double rJoystickDeadbandY = 0;
private double rJoystickDeadbandX = 0;
private double rJoystickDeadbandY = 0;

public Controller(int port) {
controller = new XboxController(port);
}
public Controller(int port) {
controller = new XboxController(port);
}

public void setControllerLeftStickXDeadband(double value) {
lJoystickDeadbandX = value;
}
public double getControllerLeftStickX() {
if (controller.getRawAxis(0) < lJoystickDeadbandX) return 0;
return controller.getRawAxis(0);
}

public void setControllerLeftStickYDeadband(double value) {
lJoystickDeadbandY = value;
}
public double getControllerLeftStickY() {
if (controller.getRawAxis(1) * -1 < lJoystickDeadbandY) return 0;
return controller.getRawAxis(1) * -1;
}

public void setControllerRightStickXDeadband(double value) {
rJoystickDeadbandX = value;
}
public double getControllerRightStickX() {
if (controller.getRawAxis(4) < rJoystickDeadbandX) return 0;
return controller.getRawAxis(4);
}

public void setControllerRightStickYDeadband(double value) {
rJoystickDeadbandY = value;
}
public double getControllerRightStickY() {
if (controller.getRawAxis(5) < rJoystickDeadbandY) return 0;
return controller.getRawAxis(5);
}

public double getControllerLeftStickY() {
return controller.getRawAxis(1) * -1;
}

public double getControllerLeftStickX() {
return controller.getRawAxis(0);
}

public double getControllerRightStickX() {
return controller.getRawAxis(4);
}

public double getControllerRightStickY() {
return controller.getRawAxis(5);
}

public double getControllerLTrigger() {
return controller.getRawAxis(2);
}

public double getControllerRTrigger() {
return controller.getRawAxis(3);
}

public boolean getControllerLBumperPressed(){
return controller.getRawButtonPressed(5);
}

public boolean getControllerLBumper(){
return controller.getRawButton(5);
}

public boolean getControllerRBumperPressed(){
return controller.getRawButtonPressed(6);
}

public boolean getControllerRBumper(){
return controller.getRawButton(6);
}

public boolean getControllerAButtonPressed() {
return controller.getAButtonPressed();
}

public boolean getControllerAButton() {
return controller.getAButton();
}

public boolean getControllerBButtonPressed() {
return controller.getBButtonPressed();
}

public boolean getControllerBButton() {
return controller.getBButton();
}

public boolean getControllerXButtonPressed() {
return controller.getXButtonPressed();
}

public boolean getControllerYButtonPressed() {
return controller.getYButtonPressed();
}

public boolean getControllerStartButtonPressed() {
return controller.getStartButtonPressed();
}

public boolean getControllerStartButton(){
return controller.getStartButton();
}
public double getControllerLTrigger() {
if (controller.getRawAxis(2) < lTriggerDeadband) return 0;
return controller.getRawAxis(2);
}

public double getControllerRTrigger() {
if (controller.getRawAxis(3) < rTriggerDeadband) return 0;
return controller.getRawAxis(3);
}

public boolean getControllerLBumperPressed(){
return controller.getRawButtonPressed(5);
}

public boolean getControllerLBumper(){
return controller.getRawButton(5);
}

public boolean getControllerRBumperPressed(){
return controller.getRawButtonPressed(6);
}

public boolean getControllerRBumper(){
return controller.getRawButton(6);
}

public boolean getControllerAButtonPressed() {
return controller.getAButtonPressed();
}

public boolean getControllerAButton() {
return controller.getAButton();
}

public boolean getControllerBButtonPressed() {
return controller.getBButtonPressed();
}

public boolean getControllerBButton() {
return controller.getBButton();
}

public boolean getControllerXButtonPressed() {
return controller.getXButtonPressed();
}

public boolean getControllerYButtonPressed() {
return controller.getYButtonPressed();
}

public boolean getControllerStartButtonPressed() {
return controller.getStartButtonPressed();
}

public boolean getControllerStartButton(){
return controller.getStartButton();
}

public void setControllerLeftStickXDeadband(double value) {
lJoystickDeadbandX = value;
}

public void setControllerLeftStickYDeadband(double value) {
lJoystickDeadbandY = value;
}

public void setControllerRightStickXDeadband(double value) {
rJoystickDeadbandX = value;
}

public void setControllerRightStickYDeadband(double value) {
rJoystickDeadbandY = value;
}

public void setControllerLeftTriggerDeadband(double value) {
lTriggerDeadband = value;
}

public void setControllerRightTriggerDeadband(double value) {
rTriggerDeadband = value;
}
}
30 changes: 30 additions & 0 deletions src/main/java/viking/controllers/ctre/VikingPigeon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package viking.controllers.ctre;

import com.ctre.phoenix.sensors.PigeonIMU;

public class VikingPigeon {

private PigeonIMU gyro;

/**
* @param controller the master VikingSRX controller
*/
public VikingPigeon(VikingSRX controller) {
gyro = new PigeonIMU(controller.getTalonSRX());

gyro.configFactoryDefault();
}

/**
* Get the current yaw
* @return the current yaw from 0 to 360
*/
public double getYaw() {
return gyro.getAbsoluteCompassHeading();
}

public PigeonIMU getPigeonIMU() {
return gyro;
}
}

Loading

0 comments on commit dead390

Please sign in to comment.