Skip to content

Commit 9a5b20b

Browse files
author
Noah Gleason
authored
Merge pull request #100 from blair-robot-project/iroc_code
Iroc code
2 parents 03e3abb + fface77 commit 9a5b20b

File tree

453 files changed

+15791
-50266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

453 files changed

+15791
-50266
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ bash.exe.stackdump
4141

4242
#Copied log files
4343
logs/
44+
*Log-*.csv
4445

4546
#Generated profiles in the base-level directory
4647
*Profile.csv

Pathgen/lib/Pathfinder-Java.jar

24.3 KB
Binary file not shown.

Pathgen/src/main/java/org/usfirst/frc/team449/pathgen/Pathgen.java

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@ public static void main(String[] args) throws IOException {
2222
final double BACK_FROM_PEG = -5;
2323
//DO NOT TOUCH THE ONES BELOW
2424
final double CARRIAGE_LEN = 3.63;
25-
final double BLUE_WALL_TO_CENTER_PEG = 113.75;
26-
final double BLUE_WALL_TO_SIDE_PEG = 130.75;
27-
final double BLUE_BACK_CORNER_TO_SIDE_PEG = 91.;
28-
final double BLUE_HALF_KEY_LENGTH = 150.5/2.;
29-
final double BLUE_KEY_CORNER_TO_SIDE_PEG = 15.;
30-
final double RED_WALL_TO_CENTER_PEG = 114.;
31-
final double RED_WALL_TO_SIDE_PEG = 130.;
32-
final double RED_BACK_CORNER_TO_SIDE_PEG = 93.5;
33-
final double RED_HALF_KEY_LENGTH = 152.5/2.;
34-
final double RED_KEY_CORNER_TO_SIDE_PEG = 18.75;
35-
final double AIRSHIP_PARALLEL_OFFSET = 6.;
25+
final double BLUE_WALL_TO_CENTER_PEG = 114.;
26+
final double BLUE_WALL_TO_SIDE_PEG = 130.5;
27+
final double BLUE_BACK_CORNER_TO_SIDE_PEG = 89.;
28+
final double BLUE_HALF_KEY_LENGTH = 152./2.;
29+
final double BLUE_KEY_CORNER_TO_SIDE_PEG = 16.;
30+
final double RED_WALL_TO_CENTER_PEG = 113.5;
31+
final double RED_WALL_TO_SIDE_PEG = 131.;
32+
final double RED_BACK_CORNER_TO_SIDE_PEG = 97.;
33+
final double RED_HALF_KEY_LENGTH = 152./2.;
34+
final double RED_KEY_CORNER_TO_SIDE_PEG = 21.;
35+
final double AIRSHIP_PARALLEL_OFFSET_BLUE = 1.;
36+
final double AIRSHIP_PARALLEL_OFFSET_RED = 2.;
3637

3738
final double PEG_BASE_TO_CENTER = CENTER_TO_FRONT + CARRIAGE_LEN + BACK_FROM_PEG;
3839

@@ -43,14 +44,14 @@ public static void main(String[] args) throws IOException {
4344

4445
Waypoint[] blueLeft = new Waypoint[]{
4546
new Waypoint(0, 0, 0),
46-
new Waypoint((BLUE_WALL_TO_SIDE_PEG-CENTER_TO_BACK - 0.5*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET*Math.cos(5.*Math.PI/6.))/12.
47-
,-(BLUE_BACK_CORNER_TO_SIDE_PEG - CENTER_TO_SIDE - (Math.sqrt(3.)/2.)*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET*Math.sin(5.*Math.PI/6.))/12.,-Math.PI/3.)
47+
new Waypoint((BLUE_WALL_TO_SIDE_PEG-CENTER_TO_BACK - 0.5*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET_BLUE*Math.cos(5.*Math.PI/6.))/12.
48+
,-(BLUE_BACK_CORNER_TO_SIDE_PEG - CENTER_TO_SIDE - (Math.sqrt(3.)/2.)*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET_BLUE*Math.sin(5.*Math.PI/6.))/12.,-Math.PI/3.)
4849
};
4950

5051
Waypoint[] blueRight = new Waypoint[]{
5152
new Waypoint(0, 0, 0),
52-
new Waypoint((BLUE_WALL_TO_SIDE_PEG-CENTER_TO_BACK - 0.5*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET*Math.cos(5.*Math.PI/6.))/12.
53-
,(BLUE_BACK_CORNER_TO_SIDE_PEG - CENTER_TO_SIDE - (Math.sqrt(3.)/2.)*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET*Math.sin(5.*Math.PI/6.))/12.,Math.PI/3.)
53+
new Waypoint((BLUE_WALL_TO_SIDE_PEG-CENTER_TO_BACK - 0.5*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET_BLUE*Math.cos(5.*Math.PI/6.))/12.
54+
,(BLUE_BACK_CORNER_TO_SIDE_PEG - CENTER_TO_SIDE - (Math.sqrt(3.)/2.)*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET_BLUE*Math.sin(5.*Math.PI/6.))/12.,Math.PI/3.)
5455
};
5556

5657
Waypoint[] blueCenter = new Waypoint[]{
@@ -60,14 +61,14 @@ public static void main(String[] args) throws IOException {
6061

6162
Waypoint[] redLeft = new Waypoint[]{
6263
new Waypoint(0, 0, 0),
63-
new Waypoint((RED_WALL_TO_SIDE_PEG-CENTER_TO_BACK - 0.5*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET*Math.cos(5.*Math.PI/6.))/12.
64-
,-(RED_BACK_CORNER_TO_SIDE_PEG - CENTER_TO_SIDE - (Math.sqrt(3.)/2.)*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET*Math.sin(5.*Math.PI/6.))/12.,-Math.PI/3.)
64+
new Waypoint((RED_WALL_TO_SIDE_PEG-CENTER_TO_BACK - 0.5*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET_RED*Math.cos(5.*Math.PI/6.))/12.
65+
,-(RED_BACK_CORNER_TO_SIDE_PEG - CENTER_TO_SIDE - (Math.sqrt(3.)/2.)*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET_RED*Math.sin(5.*Math.PI/6.))/12.,-Math.PI/3.)
6566
};
6667

6768
Waypoint[] redRight = new Waypoint[]{
6869
new Waypoint(0, 0, 0),
69-
new Waypoint((RED_WALL_TO_SIDE_PEG-CENTER_TO_BACK - 0.5*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET*Math.cos(5.*Math.PI/6.))/12.
70-
,(RED_BACK_CORNER_TO_SIDE_PEG - CENTER_TO_SIDE - (Math.sqrt(3.)/2.)*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET*Math.sin(5.*Math.PI/6.))/12.,Math.PI/3.)
70+
new Waypoint((RED_WALL_TO_SIDE_PEG-CENTER_TO_BACK - 0.5*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET_RED*Math.cos(5.*Math.PI/6.))/12.
71+
,(RED_BACK_CORNER_TO_SIDE_PEG - CENTER_TO_SIDE - (Math.sqrt(3.)/2.)*PEG_BASE_TO_CENTER + AIRSHIP_PARALLEL_OFFSET_RED*Math.sin(5.*Math.PI/6.))/12.,Math.PI/3.)
7172
};
7273

7374
Waypoint[] redCenter = new Waypoint[]{
@@ -105,24 +106,24 @@ public static void main(String[] args) throws IOException {
105106

106107
Waypoint[] blueLoadingToLoading = new Waypoint[]{
107108
new Waypoint(0, 0, 0),
108-
new Waypoint(27, -5, 0)
109+
new Waypoint(22, -5, 0)
109110
};
110111

111112
Waypoint[] blueBoilerToLoading = new Waypoint[]{
112113
new Waypoint(0, 0, 0),
113114
new Waypoint(5, 0, 0),
114-
new Waypoint(27, -15, 0)
115+
new Waypoint(22, -15, 0)
115116
};
116117

117118
Waypoint[] redLoadingToLoading = new Waypoint[]{
118119
new Waypoint(0, 0, 0),
119-
new Waypoint(27, 5, 0)
120+
new Waypoint(22, 5, 0)
120121
};
121122

122123
Waypoint[] redBoilerToLoading = new Waypoint[]{
123124
new Waypoint(0, 0, 0),
124125
new Waypoint(5, 0, 0),
125-
new Waypoint(27, 15, 0)
126+
new Waypoint(22, 15, 0)
126127
};
127128

128129
Map<String, Waypoint[]> profiles = new HashMap<>();
@@ -136,25 +137,28 @@ public static void main(String[] args) throws IOException {
136137
profiles.put("BlueShoot", bluePegToKey);
137138
profiles.put("RedBackup", backupRed);
138139
profiles.put("BlueBackup", backupBlue);
140+
profiles.put("forward100In", points);
141+
profiles.put("BlueBackup", backupBlue);
139142
profiles.put("BlueLoadingToLoading", blueLoadingToLoading);
140143
profiles.put("BlueBoilerToLoading", blueBoilerToLoading);
141144
profiles.put("RedLoadingToLoading", redLoadingToLoading);
142145
profiles.put("RedBoilerToLoading", redBoilerToLoading);
146+
// profiles.put("forward100In", points);
143147

144148
final String ROBOT_NAME = "calcifer";
145149

146150
//Calculated by driving each wheel n inches in opposite directions, then taking the angle moved, θ, and finding
147151
// the circumference of a circle moved by the robot via C = 360 * n / θ
148152
//You then find the diameter via C / π.
149-
double balbasaurWheelbase = 33.3 / 12.;
153+
double balbasaurWheelbase = 30. / 12.;
150154
//200 in: 29.96
151155
//50 in: 34.2
152156

153157
//433.415
154158
double calciferWheelbase = 26./12.;
155159

156160
Trajectory.Config config = new Trajectory.Config(Trajectory.FitMethod.HERMITE_CUBIC, Trajectory.Config.SAMPLES_HIGH,
157-
0.05, 5., 3, 6); //Units are seconds, feet/second, feet/(second^2), and feet/(second^3)
161+
0.05, 5., 4.5, 9.); //Units are seconds, feet/second, feet/(second^2), and feet/(second^3)
158162

159163
for (String profile : profiles.keySet()) {
160164
Trajectory trajectory = Pathfinder.generate(profiles.get(profile), config);
@@ -168,14 +172,14 @@ public static void main(String[] args) throws IOException {
168172
lfw.write(tm.getLeftTrajectory().length() + "\n");
169173
for (int i = 0; i < tm.getLeftTrajectory().length(); i++) {
170174
lfw.write(tm.getLeftTrajectory().get(i).position + ",\t" + tm.getLeftTrajectory().get(i).velocity + ",\t"
171-
+ tm.getLeftTrajectory().get(i).dt + ",");
175+
+ tm.getLeftTrajectory().get(i).acceleration + ",\t" + tm.getLeftTrajectory().get(i).dt);
172176
lfw.write("\n");
173177
}
174178

175179
rfw.write(tm.getRightTrajectory().length() + "\n");
176180
for (int i = 0; i < tm.getRightTrajectory().length(); i++) {
177-
rfw.write(tm.getRightTrajectory().get(i).position + ",\t" + tm.getRightTrajectory().get(i).velocity + "," +
178-
"\t" + tm.getRightTrajectory().get(i).dt + ",");
181+
rfw.write(tm.getRightTrajectory().get(i).position + ",\t" + tm.getRightTrajectory().get(i).velocity +
182+
",\t" + tm.getLeftTrajectory().get(i).acceleration + ",\t" + tm.getRightTrajectory().get(i).dt);
179183
rfw.write("\n");
180184
}
181185

Pathgen/src/main/R/drawMP.R renamed to R scripts/drawMP.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plotProfile <- function(profileName, inverted = FALSE, wheelbaseDiameter, centerToFront, centerToBack, centerToSide, startY = 0, startPos = c(-1,-1,-1,-1,-1), usePosition = TRUE){
2-
left <- read.csv(paste("../../../../calciferLeft",profileName,"Profile.csv",sep=""), header=FALSE)
3-
right <- read.csv(paste("../../../../calciferRight",profileName,"Profile.csv",sep=""), header=FALSE)
2+
left <- read.csv(paste("../calciferLeft",profileName,"Profile.csv",sep=""), header=FALSE)
3+
right <- read.csv(paste("../calciferRight",profileName,"Profile.csv",sep=""), header=FALSE)
44
startingCenter <- c(startY, centerToBack)
55
left$V1[1] <- 0
66
left$V2[1] <- 0
@@ -73,11 +73,11 @@ plotProfile <- function(profileName, inverted = FALSE, wheelbaseDiameter, center
7373
#This is the angle for the vector pointing towards the new position of each
7474
#wheel.
7575
#To understand why this formula is correct, overlay isoclese triangles on the sectors
76-
vectorTheta <- (pi - theta)/2 - (pi/2 - perpendicular)
76+
vectorTheta <- perpendicular+theta/2
7777

7878
#The is the length of the vector pointing towards the new position of each
7979
#wheel divided by the radius of the turning circle.
80-
vectorDistanceWithoutR <- sin(theta)/sin((pi-theta)/2)
80+
vectorDistanceWithoutR <- 2*sin(theta/2)
8181

8282
#If inverted, swap which wheel gets which input
8383
if(inverted){
File renamed without changes.

R scripts/findVelVsVoltage.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Title : findVelVsVoltage
2+
# Objective : Find the line or curve describing how
3+
# Created by: Noah Gleason
4+
# Created on: 9/30/17
5+
6+
trials = 1
7+
voltages = seq(1.5,5,by=0.5)
8+
#voltages = c(0.6, 2, 2.5)
9+
raw <- read.csv("eventLog-2017.10.01.13.58.02.csv")
10+
raw$class <- as.character(raw$class)
11+
maxes <- raw[grep("class org.usfirst.frc.team449.robot.drive.unidirectional.commands.DetermineVelVsVoltage", raw$class), 3]
12+
maxes <- as.numeric(as.vector(maxes))
13+
14+
model <- lm(maxes ~ voltages)
15+
coeffs <- c(coefficients(model))
16+
View(coeffs)
17+
xInt <- -coeffs[1]/coeffs[2]
18+
19+
res <- resid(model)
20+
21+
plot(x=voltages, y=maxes, main = "Max Velocity vs. Voltage", xlab="Voltage (volts)", ylab="Max speed (feet/sec)", xlim=c(0,12), ylim=c(0,12))
22+
abline(model)
23+
plot(x=voltages, y=res, main="Residuals", xlab="Voltage (volts)", ylab="Residuals (feet/sec)", xlim=c(0,12))
24+
abline(0,0)

0 commit comments

Comments
 (0)