Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests and a couple minor bug fixes/tweaks #8

Merged
merged 6 commits into from
Oct 20, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/futility/Flag.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ else if (parts.length == 3) {
}
else if (parts[1].equals("b")) {
x = Settings.PHYSICAL_BOUNDARY().getCenter().getX();
y = Settings.PHYSICAL_BOUNDARY().getTop();
y = Settings.PHYSICAL_BOUNDARY().getBottom();
}
else if (parts[1].equals("l")) {
x = Settings.PHYSICAL_BOUNDARY().getLeft();
Expand Down
8 changes: 8 additions & 0 deletions src/futility/PositionEstimate.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public final Point getPosition() {
return position;
}

public final double getX() {
return position.getX();
}

public final double getY() {
return position.getY();
}

public final String render(int time) {
return this.position.render() + " with " + Double.toString(this.getConfidence(time)) + " confidence.";
}
Expand Down
7 changes: 4 additions & 3 deletions src/futility/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class Settings {
public static final double FIELD_HEIGHT = 68.0;
public static final double FIELD_BUFFER = 5.0;
public static final double GOAL_HEIGHT = 14.02;
public static final double PENALTY_AREA_DISTANCE = 16.5; // Unconfirmed
public static final double PENALTY_AREA_WIDTH = 16.5; // 97.4% confirmed in robocup; based on size of actual field
public static final double PENALTY_AREA_HEIGHT = 40.3; // 97.4% confirmed in robocup; based on size of actual field

// Other constants
public static final char LEFT_SIDE = 'l';
Expand Down Expand Up @@ -63,11 +64,11 @@ public static class LOG_LEVELS {
}

public static Rectangle PENALTY_AREA_LEFT() {
return new Rectangle(FIELD_BUFFER + FIELD_HEIGHT / 2.0 + GOAL_HEIGHT / 2.0 + PENALTY_AREA_DISTANCE, FIELD_BUFFER + PENALTY_AREA_DISTANCE, FIELD_BUFFER - GOAL_HEIGHT / 2 - PENALTY_AREA_DISTANCE, FIELD_BUFFER);
return new Rectangle(FIELD_BUFFER + FIELD_HEIGHT / 2.0 + PENALTY_AREA_HEIGHT / 2.0, FIELD_BUFFER + PENALTY_AREA_WIDTH, FIELD_BUFFER + FIELD_HEIGHT / 2.0 - PENALTY_AREA_HEIGHT / 2.0, FIELD_BUFFER);
}

public static Rectangle PENALTY_AREA_RIGHT() {
return new Rectangle(FIELD().getCenter().getY() + (GOAL_HEIGHT / 2) + PENALTY_AREA_DISTANCE, FIELD().getRight(), FIELD().getCenter().getY() - GOAL_HEIGHT - PENALTY_AREA_DISTANCE, FIELD().getRight() - PENALTY_AREA_DISTANCE);
return new Rectangle(FIELD().getCenter().getY() + PENALTY_AREA_HEIGHT / 2.0, FIELD().getRight(), FIELD().getCenter().getY() - PENALTY_AREA_HEIGHT / 2.0, FIELD().getRight() - PENALTY_AREA_WIDTH);
}

// List of known game-state play modes
Expand Down
207 changes: 205 additions & 2 deletions src/tests/futility/FlagTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import org.junit.Before;
import org.junit.Test;

import futility.Flag;
import futility.Goal;

public class FlagTest {

@Before
Expand All @@ -19,6 +22,206 @@ public void tearDown() throws Exception {

@Test
public void testFlag() {
fail("Not implemented yet");
String[] flags = {
// Field perimeter flags
"(f t l 50)",
"(f t l 40)",
"(f t l 30)",
"(f t l 20)",
"(f t l 10)",
"(f t 0)",
"(f t r 10)",
"(f t r 20)",
"(f t r 30)",
"(f t r 40)",
"(f t r 50)",
"(f r t 30)",
"(f r t 20)",
"(f r t 10)",
"(f r 0)",
"(f r b 10)",
"(f r b 20)",
"(f r b 30)",
"(f b r 50)",
"(f b r 40)",
"(f b r 30)",
"(f b r 20)",
"(f b r 10)",
"(f b 0)",
"(f b l 10)",
"(f b l 20)",
"(f b l 30)",
"(f b l 40)",
"(f b l 50)",
"(f l b 30)",
"(f l b 20)",
"(f l b 10)",
"(f l 0)",
"(f l t 10)",
"(f l t 20)",
"(f l t 30)",

// Field corner flags
"(f l t)",
"(f r t)",
"(f r b)",
"(f l b)",

// Field center flags
"(f c t)",
"(f c)",
"(f c b)",

// Penalty area flags
"(f p l t)",
"(f p l c)",
"(f p l b)",
"(f p r t)",
"(f p r c)",
"(f p r b)",

// Goalpost flags
"(f g l t)",
"(f g l b)",
"(f g r t)",
"(f g r b)",
};

double[] xcoords = {
// Field perimeter flags
7.5, //(f t l 50)
17.5, //(f t l 40)
27.5, //(f t l 30)
37.5, //(f t l 20)
47.5, //(f t l 10)
57.5, //(f t 0)
67.5, //(f t r 10)
77.5, //(f t r 20)
87.5, //(f t r 30)
97.5, //(f t r 40)
107.5, //(f t r 50)
115, //(f r t 30)
115, //(f r t 20)
115, //(f r t 10)
115, //(f r 0)
115, //(f r b 10)
115, //(f r b 20)
115, //(f r b 30)
107.5, //(f b r 50)
97.5, //(f b r 40)
87.5, //(f b r 30)
77.5, //(f b r 20)
67.5, //(f b r 10)
57.5, //(f b 0)
47.5, //(f b l 10)
37.5, //(f b l 20)
27.5, //(f b l 30)
17.5, //(f b l 40)
7.5, //(f b l 50)
0, //(f l b 30)
0, //(f l b 20)
0, //(f l b 10)
0, //(f l 0)
0, //(f l t 10)
0, //(f l t 20)
0, //(f l t 30)

// Field corner flags
5, //(f l t)
110, //(f r t)
110, //(f r b)
5, //(f l b)

// Field center flags
57.5, //(f c t)
57.5, //(f c)
57.5, //(f c b)

// Penalty area flags
21.5, //(f p l t)
21.5, //(f p l c)
21.5, //(f p l b)
93.5, //(f p r t)
93.5, //(f p r c)
93.5, //(f p r b)

// Goalpost flags
5, //(f g l t)
5, //(f g l b)
110, //(f g r t)
110, //(f g r b)
};

double[] ycoords = {
// Field perimeter flags
78, //(f t l 50)
78, //(f t l 40)
78, //(f t l 30)
78, //(f t l 20)
78, //(f t l 10)
78, //(f t 0)
78, //(f t r 10)
78, //(f t r 20)
78, //(f t r 30)
78, //(f t r 40)
78, //(f t r 50)
69, //(f r t 30)
59, //(f r t 20)
49, //(f r t 10)
39, //(f r 0)
29, //(f r b 10)
19, //(f r b 20)
9, //(f r b 30)
0, //(f b r 50)
0, //(f b r 40)
0, //(f b r 30)
0, //(f b r 20)
0, //(f b r 10)
0, //(f b 0)
0, //(f b l 10)
0, //(f b l 20)
0, //(f b l 30)
0, //(f b l 40)
0, //(f b l 50)
9, //(f l b 30)
19, //(f l b 20)
29, //(f l b 10)
39, //(f l 0)
49, //(f l t 10)
59, //(f l t 20)
69, //(f l t 30)

// Field corner flags
73, //(f l t)
73, //(f r t)
5, //(f r b)
5, //(f l b)

// Field center flags
73, //(f c t)
39, //(f c)
5, //(f c b)

// Penalty area flags
59.15, //(f p l t)
39, //(f p l c)
18.85, //(f p l b)
59.15, //(f p r t)
39, //(f p r c)
18.85, //(f p r b)

// Goalpost flags
46.01, //(f g l t)
31.99, //(f g l b)
46.01, //(f g r t)
31.99, //(f g r b)
};

for (int i = 0; i < flags.length; i++) {
Flag newFlag = new Flag(flags[i]);
System.out.println("Attempting flag id: " + flags[i]);
assertEquals(xcoords[i], newFlag.position.getX(), 0.001);
assertEquals(ycoords[i], newFlag.position.getY(), 0.001);
}
}
}
}