make scoring only a single button
Change-Id: I994c1a3fa6092a5263ccb81af15cc2d12f85edad
diff --git a/frc971/actors/score_action.q b/frc971/actors/score_action.q
index 79b8be3..c2a5dba 100644
--- a/frc971/actors/score_action.q
+++ b/frc971/actors/score_action.q
@@ -4,7 +4,9 @@
// Parameters to send with start.
struct ScoreParams {
- // If false, then extend. Otherwise, place the stack and retract.
+ // If true, move the stack first.
+ bool move_the_stack;
+ // If true, place the stack (possibly after moving it).
bool place_the_stack;
// TODO(Brian): Comments (by somebody who knows what these all mean).
diff --git a/frc971/actors/score_actor.cc b/frc971/actors/score_actor.cc
index d866f6a..baa7710 100644
--- a/frc971/actors/score_actor.cc
+++ b/frc971/actors/score_actor.cc
@@ -30,11 +30,19 @@
constants::GetValues().fridge.arm.lower_limit) {}
bool ScoreActor::RunAction(const ScoreParams& params) {
- if (params.place_the_stack) {
- return PlaceTheStack(params);
- } else {
- return MoveStackIntoPosition(params);
+ if (params.move_the_stack) {
+ LOG(INFO, "moving stack\n");
+ if (!MoveStackIntoPosition(params)) return false;
+ LOG(INFO, "done moving stack\n");
+ if (ShouldCancel()) return true;
}
+ if (params.place_the_stack) {
+ LOG(INFO, "placing stack\n");
+ if (!PlaceTheStack(params)) return false;
+ LOG(INFO, "done placing stack\n");
+ if (ShouldCancel()) return true;
+ }
+ return true;
}
bool ScoreActor::MoveStackIntoPosition(const ScoreParams& params) {
diff --git a/frc971/actors/score_actor_test.cc b/frc971/actors/score_actor_test.cc
index 25f3aa1..e462c54 100644
--- a/frc971/actors/score_actor_test.cc
+++ b/frc971/actors/score_actor_test.cc
@@ -59,7 +59,7 @@
frc971::actors::score_action.goal.MakeWithBuilder().run(false).Send();
// let the action start running, if we return from this call it has worked.
- const ScoreParams params = {true, 0.14, 0.13, -0.7, -0.10, 0.1};
+ const ScoreParams params = {true, true, 0.14, 0.13, -0.7, -0.10, 0.1};
score.RunAction(params);
SUCCEED();
@@ -87,7 +87,7 @@
frc971::actors::score_action.goal.MakeWithBuilder().run(false).Send();
// let the action start running, if we return from this call it has worked.
- const ScoreParams params = {false, 0.14, 0.13, -0.7, -0.10, 0.1};
+ const ScoreParams params = {false, true, 0.14, 0.13, -0.7, -0.10, 0.1};
score.RunAction(params);
SUCCEED();
diff --git a/frc971/joystick_reader.cc b/frc971/joystick_reader.cc
index 8ef2966..6311100 100644
--- a/frc971/joystick_reader.cc
+++ b/frc971/joystick_reader.cc
@@ -93,14 +93,13 @@
// Move the fridge out with the stack in preparation for scoring.
const ButtonLocation kScore(4, 8);
-// Release the stack and retract back in.
-const ButtonLocation kRetractFromScore(4, 12);
-
const ButtonLocation kCoopTop(3, 8);
const ButtonLocation kCoopTopRetract(3, 7);
const ButtonLocation kCoopBottom(3, 6);
const ButtonLocation kCoopBottomRetract(3, 9);
+const ButtonLocation kRetractFromScore(4, 12);
+
const POVLocation kFridgeToggle(4, 270);
const ButtonLocation kSpit(4, 3);
@@ -114,9 +113,9 @@
public:
Reader() : was_running_(false) {}
- static actors::ScoreParams MakeScoreParams(bool place_the_stack) {
+ static actors::ScoreParams MakeScoreParams() {
actors::ScoreParams r;
- r.place_the_stack = place_the_stack;
+ r.move_the_stack = r.place_the_stack = true;
r.upper_move_height = 0.14;
r.begin_horizontal_move_height = 0.13;
r.horizontal_move_target = -0.7;
@@ -127,6 +126,7 @@
static actors::ScoreParams MakeCoopTopParams(bool place_the_stack) {
actors::ScoreParams r;
+ r.move_the_stack = !place_the_stack;
r.place_the_stack = place_the_stack;
r.upper_move_height = 0.52;
r.begin_horizontal_move_height = 0.5;
@@ -138,6 +138,7 @@
static actors::ScoreParams MakeCoopBottomParams(bool place_the_stack) {
actors::ScoreParams r;
+ r.move_the_stack = !place_the_stack;
r.place_the_stack = place_the_stack;
r.upper_move_height = 0.17;
r.begin_horizontal_move_height = 0.16;
@@ -349,11 +350,7 @@
if (data.PosEdge(kScore)) {
action_queue_.EnqueueAction(
- actors::MakeScoreAction(MakeScoreParams(false)));
- }
- if (data.PosEdge(kRetractFromScore)) {
- action_queue_.EnqueueAction(
- actors::MakeScoreAction(MakeScoreParams(true)));
+ actors::MakeScoreAction(MakeScoreParams()));
fridge_closed_ = false;
}