Skip to content

Commit 72477f8

Browse files
author
Noah Gleason
committed
Merge in master
2 parents aa28f89 + 5208aa3 commit 72477f8

File tree

10 files changed

+104
-64
lines changed

10 files changed

+104
-64
lines changed

RoboRIO/build.gradle

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ plugins {
33
id 'java'
44
id 'eclipse'
55
id 'idea'
6-
id "jaci.openrio.gradle.GradleRIO" version "2017.10.30"
6+
id 'jaci.openrio.gradle.GradleRIO' version "2017.1.5"
77
}
88

9+
group 'org.usfirst.frc.team449.robot2017'
10+
version '1.0'
11+
912
repositories {
1013
mavenCentral()
1114
maven {
@@ -16,39 +19,13 @@ repositories {
1619
maven { url "https://plugins.gradle.org/m2/" }
1720
}
1821

19-
group 'org.usfirst.frc.team449.robot2017'
20-
version '1.0'
21-
22-
def TEAM = 449
23-
def ROBOT_CLASS = "org.usfirst.frc.team449.robot.Robot"
24-
25-
// Define my targets (RoboRIO) and artifacts (deployable files)
26-
// This is added by GradleRIO's backing project EmbeddedTools.
27-
deploy {
28-
targets {
29-
target("roborio", jaci.openrio.gradle.frc.RoboRIO) {
30-
team = TEAM
31-
}
32-
}
33-
artifacts {
34-
artifact('frcJava', jaci.openrio.gradle.frc.FRCJavaArtifact) {
35-
targets << "roborio"
36-
}
37-
}
38-
}
39-
4022
wpi {
4123
wpilibVersion = "2017.3.1" // The WPILib version to use. For this version of GradleRIO, must be a 2017 version.
4224
ntcoreVersion = "3.1.7" // The NetworkTables Core version to use.
4325
opencvVersion = "3.1.0" // The OpenCV version to use.
4426
cscoreVersion = "1.0.2" // The CSCore version to use.
45-
ctreVersion = "4.4.1.14" // The CTRE Toolsuite (Talon SRX) version to use.
27+
talonSrxVersion = "4.4.1.14" // The CTRE Toolsuite (Talon SRX) version to use.
4628
navxVersion = "3.0.331" // The NavX-MXP library version to use.
47-
48-
smartDashboardVersion = '...'
49-
javaInstallerVersion = '...'
50-
51-
toolchainVersion = '...'
5229
}
5330

5431
dependencies {
@@ -63,11 +40,11 @@ dependencies {
6340
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-parameter-names', version: '2.9.0.pr3'
6441
compile 'org.jetbrains:annotations:13.0'
6542
compile wpilib()
66-
compile ctre()
43+
compile talonSrx()
6744
compile navx()
6845
}
6946

70-
/* CopyResources stuff */
47+
/* GradleRIO stuff */
7148
remotes {
7249
rio {
7350
host = 'roboRIO-449-frc.local'
@@ -76,6 +53,16 @@ remotes {
7653
}
7754
}
7855

56+
frc {
57+
team = '449'
58+
robotClass = "org.usfirst.frc.team449.robot.Robot"
59+
}
60+
61+
def robotManifest = {
62+
attributes 'Main-Class': 'edu.wpi.first.wpilibj.RobotBase'
63+
attributes 'Robot-Class': frc.robotClass
64+
}
65+
7966
task('copyResources') {
8067
doLast {
8168
ssh.run {
@@ -90,12 +77,9 @@ task('copyResources') {
9077
}
9178

9279
/* Generic artifact gen stuff */
93-
// Java only. Setup your Jar File.
9480
jar {
95-
// Compile a 'fat jar' (libraries included)
9681
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
97-
// Include your Manifest. Arguments are your Robot Main Class.
98-
manifest jaci.openrio.gradle.GradleRIOPlugin.javaManifest(ROBOT_CLASS)
82+
manifest robotManifest
9983
}
10084

10185
task genJavadoc(type: Jar, dependsOn: javadoc) {

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/oi/throttles/ThrottleBasic.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
import com.fasterxml.jackson.annotation.JsonProperty;
66
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
77
import edu.wpi.first.wpilibj.Joystick;
8+
import edu.wpi.first.wpilibj.PIDSource;
9+
import edu.wpi.first.wpilibj.PIDSourceType;
810
import org.jetbrains.annotations.NotNull;
911
import org.usfirst.frc.team449.robot.jacksonWrappers.MappedJoystick;
12+
import org.usfirst.frc.team449.robot.other.Clock;
13+
14+
import java.util.Random;
1015

1116
/**
1217
* A class representing a single axis on a joystick.
1318
*/
1419
@JsonIdentityInfo(generator = ObjectIdGenerators.StringIdGenerator.class)
15-
public class ThrottleBasic implements Throttle {
20+
public class ThrottleBasic implements Throttle, PIDSource{
1621

1722
/**
1823
* The stick we're using
@@ -77,4 +82,34 @@ public double getValueCached() {
7782
public void update() {
7883
cachedOutput = getValue();
7984
}
85+
86+
/**
87+
* Set which parameter of the device you are using as a process control variable.
88+
*
89+
* @param pidSource An enum to select the parameter.
90+
*/
91+
@Override
92+
public void setPIDSourceType(PIDSourceType pidSource) {
93+
//Do nothing
94+
}
95+
96+
/**
97+
* Get which parameter of the device you are using as a process control variable.
98+
*
99+
* @return the currently selected PID source parameter
100+
*/
101+
@Override
102+
public PIDSourceType getPIDSourceType() {
103+
return null;
104+
}
105+
106+
/**
107+
* Get the result to use in PIDController.
108+
*
109+
* @return the result to use in PIDController
110+
*/
111+
@Override
112+
public double pidGet() {
113+
return (inverted ? -1 : 1) * stick.getRawAxis(axis);
114+
}
80115
}

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/oi/throttles/ThrottleDeadbanded.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package org.usfirst.frc.team449.robot.oi.throttles;
22

33
import com.fasterxml.jackson.annotation.*;
4+
import edu.wpi.first.wpilibj.filters.LinearDigitalFilter;
45
import org.jetbrains.annotations.NotNull;
6+
import org.jetbrains.annotations.Nullable;
57
import org.usfirst.frc.team449.robot.jacksonWrappers.MappedJoystick;
68

79
/**
8-
* A throttle with a deadband.
10+
* A throttle with a deadband and smoothing.
911
*/
1012
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.WRAPPER_OBJECT, property = "@class")
1113
@JsonIdentityInfo(generator = ObjectIdGenerators.StringIdGenerator.class)
@@ -26,35 +28,40 @@ public class ThrottleDeadbanded extends ThrottleBasic {
2628
*/
2729
private double sign;
2830

31+
/**
32+
* The smoothing filter for this joystick.
33+
*/
34+
private final LinearDigitalFilter filter;
35+
2936
/**
3037
* A basic constructor.
3138
*
3239
* @param stick The Joystick object being used
3340
* @param axis The axis being used. 0 is X, 1 is Y, 2 is Z.
3441
* @param deadband The deadband below which the input will be read as 0, on [0, 1]. Defaults to 0.
42+
* @param smoothingTimeSecs How many seconds of input to take into account when smoothing. Defaults to 0.02.
3543
* @param inverted Whether or not to invert the joystick input. Defaults to false.
3644
*/
3745
@JsonCreator
3846
public ThrottleDeadbanded(@NotNull @JsonProperty(required = true) MappedJoystick stick,
3947
@JsonProperty(required = true) int axis,
4048
double deadband,
49+
@Nullable Double smoothingTimeSecs,
4150
boolean inverted) {
4251
super(stick, axis, inverted);
4352
this.deadband = deadband;
53+
this.filter = LinearDigitalFilter.singlePoleIIR(this, smoothingTimeSecs != null ? smoothingTimeSecs : 0.02,0.02);
4454
}
4555

4656
/**
47-
* Gets the value from the joystick and deadbands it. The non-deadband values are scaled to avoid a discontinuity,
48-
* so the graph of joystick input to deadbanded output looks like this:
49-
* <p>
50-
* _/ /
57+
* Gets the value from the joystick and deadbands it. The non-deadband values are scaled to avoid a discontinuity.
5158
*
5259
* @return The joystick's value, after being deadbanded.
5360
*/
5461
@Override
5562
public double getValue() {
5663
//Get the smoothed value
57-
input = super.getValue();
64+
input = filter.pidGet();
5865

5966
sign = Math.signum(input);
6067
input = Math.abs(input);

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/oi/throttles/ThrottleExponential.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.fasterxml.jackson.annotation.JsonProperty;
66
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
77
import org.jetbrains.annotations.NotNull;
8+
import org.jetbrains.annotations.Nullable;
89
import org.usfirst.frc.team449.robot.jacksonWrappers.MappedJoystick;
910

1011
/**
@@ -34,16 +35,18 @@ public class ThrottleExponential extends ThrottleDeadbanded {
3435
* @param stick The Joystick object being used
3536
* @param axis The axis being used.
3637
* @param deadband The deadband below which the input will be read as 0, on [0, 1]. Defaults to 0.
38+
* @param smoothingTimeSecs How many seconds of input to take into account when smoothing. Defaults to 0.02.
3739
* @param inverted Whether or not to invert the joystick input. Defaults to false.
3840
* @param base The base that is raised to the power of the joystick input.
3941
*/
4042
@JsonCreator
4143
public ThrottleExponential(@NotNull @JsonProperty(required = true) MappedJoystick stick,
4244
@JsonProperty(required = true) int axis,
4345
double deadband,
46+
@Nullable Double smoothingTimeSecs,
4447
boolean inverted,
4548
@JsonProperty(required = true) double base) {
46-
super(stick, axis, deadband, inverted);
49+
super(stick, axis, deadband, smoothingTimeSecs, inverted);
4750
this.base = base;
4851
}
4952

RoboRIO/src/main/java/org/usfirst/frc/team449/robot/oi/throttles/ThrottlePolynomial.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.fasterxml.jackson.annotation.JsonProperty;
66
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
77
import org.jetbrains.annotations.NotNull;
8+
import org.jetbrains.annotations.Nullable;
89
import org.usfirst.frc.team449.robot.jacksonWrappers.MappedJoystick;
910
import org.usfirst.frc.team449.robot.other.Polynomial;
1011

@@ -26,16 +27,18 @@ public class ThrottlePolynomial extends ThrottleDeadbanded {
2627
* @param stick The Joystick object being used
2728
* @param axis The axis being used. 0 is X, 1 is Y, 2 is Z.
2829
* @param deadband The deadband below which the input will be read as 0, on [0, 1]. Defaults to 0.
30+
* @param smoothingTimeSecs How many seconds of input to take into account when smoothing. Defaults to 0.02.
2931
* @param inverted Whether or not to invert the joystick input. Defaults to false.
3032
* @param polynomial The polynomially that scales the throttle. Must not have any negative exponents.
3133
*/
3234
@JsonCreator
3335
public ThrottlePolynomial(@NotNull @JsonProperty(required = true) MappedJoystick stick,
3436
@JsonProperty(required = true) int axis,
3537
double deadband,
38+
@Nullable Double smoothingTimeSecs,
3639
boolean inverted,
3740
@NotNull @JsonProperty(required = true) Polynomial polynomial) {
38-
super(stick, axis, deadband, inverted);
41+
super(stick, axis, deadband, smoothingTimeSecs, inverted);
3942

4043
//Check for negative exponents
4144
for (Double power : polynomial.getPowerToCoefficientMap().keySet()) {

RoboRIO/src/main/resources/ballbasaur_map.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ oi:
8787
'@id': rotThrottle
8888
stick: driverGamepad
8989
axis: 0
90+
smoothingTimeSecs: 0.04
9091
deadband: 0.05
9192
inverted: false
9293
fwdThrottle:

0 commit comments

Comments
 (0)