Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added plunging!

  • Loading branch information...
commit a0aed85fce3713a89d93686b8873d30271e32cce 1 parent f5e8cff
@paul-thomson paul-thomson authored
View
57 CommandReciever/src/group2/sdp/robot/commandreciever/Brain.java
@@ -85,10 +85,16 @@
// The speed to set the kicker motor, determines the power of the kick.
// private static final int KICKER_SPEED = 10000;
// The angle of the kicker at the end of the kick.
- private static final int KICKER_ANGLE = 900;
+ private static final int KICKER_ANGLE = 35;
// The delay before resetting the kicker.
private static final int KICKER_DELAY = 300;
+ // The angle of the kicker at the end of the kick.
+ private static final int PLUNGE_ANGLE = 900;
+ // The delay before resetting the kicker.
+ private static final int PLUNGE_DELAY = 1000;
+
+
// Alfie's actions. Robot state indicators.
private static volatile boolean kicking = false;
@@ -326,10 +332,9 @@ public static void stop() {
* Kick the ball!
*
* Starts a new thread and makes the robot kick if it isn't already kicking
- * @param power How hard should the motor rotate in degrees/s.
*
*/
- public static void kick(int power) {
+ public static void kick() {
assert(initialized);
// Start a new thread to control the kicker
Thread Kick_thread = new Thread() {
@@ -339,6 +344,48 @@ public void run() {
kicking = true;
KICKER.rotate(KICKER_ANGLE);
Thread.sleep(KICKER_DELAY);
+ KICKER.rotate(-KICKER_ANGLE);
+ Thread.sleep(KICKER_DELAY);
+ } catch (InterruptedException exc) {
+ System.out.println(exc.toString());
+ }
+
+ kicking = false;
+ }
+
+ };
+
+ // Alfie only has 1 leg, so he can only make 1 kick at a time
+ if (!kicking) {
+ kicking = true;
+ KICKER.setSpeed(KICKER.getMaxSpeed());
+ Kick_thread.start();
+
+ if (VERBOSE) {
+ LCD.clear();
+ LCD.drawString(KCK1, 0, 0);
+ LCD.drawString(KCK2, 0, 1);
+ LCD.refresh();
+ }
+ }
+ }
+
+ /**
+ * Plunge the ball! Works with the experimental kicker.
+ *
+ * Starts a new thread and makes the robot kick if it isn't already kicking
+ *
+ */
+ public static void ram() {
+ assert(initialized);
+ // Start a new thread to control the kicker
+ Thread Kick_thread = new Thread() {
+
+ public void run() {
+ try {
+ kicking = true;
+ KICKER.rotate(PLUNGE_ANGLE);
+ Thread.sleep(PLUNGE_DELAY);
} catch (InterruptedException exc) {
System.out.println(exc.toString());
}
@@ -351,9 +398,6 @@ public void run() {
// Alfie only has 1 leg, so he can only make 1 kick at a time
if (!kicking) {
kicking = true;
- power = Tools.sanitizeInput(power, MIN_KICK_POWER, MAX_KICK_POWER);
- if (power == 0)
- power = MAX_KICK_POWER;
KICKER.setSpeed(KICKER.getMaxSpeed());
Kick_thread.start();
@@ -361,7 +405,6 @@ public void run() {
LCD.clear();
LCD.drawString(KCK1, 0, 0);
LCD.drawString(KCK2, 0, 1);
- LCD.drawInt(power, 1, 2);
LCD.refresh();
}
}
View
2  CommandReciever/src/group2/sdp/robot/commandreciever/Ear.java
@@ -163,7 +163,7 @@ private static void reactOnCandy(CandyPacket candy) {
Brain.moveArc((float)-candy.getPretzel(0) / 10000, candy.getPretzel(1));
break;
case CandyPacket.KICK_CANDY:
- Brain.kick(candy.getPretzel(0));
+ Brain.kick();
break;
case CandyPacket.RESET_CANDY:
break;
Please sign in to comment.
Something went wrong with that request. Please try again.