Wrote the 5 autonomous modes.
Change-Id: I46d3607811c78be14a3ca5f445899b15b0627fb5
diff --git a/y2016/control_loops/shooter/shooter.cc b/y2016/control_loops/shooter/shooter.cc
index 32ccc7e..0936eea 100644
--- a/y2016/control_loops/shooter/shooter.cc
+++ b/y2016/control_loops/shooter/shooter.cc
@@ -70,6 +70,7 @@
Shooter::Shooter(ShooterQueue *my_shooter)
: aos::controls::ControlLoop<ShooterQueue>(my_shooter),
+ shots_(0),
last_pre_shot_timeout_(0, 0) {}
void Shooter::RunIteration(const ShooterQueue::Goal *goal,
@@ -127,20 +128,24 @@
}
if (::std::abs(goal->angular_velocity) < 10 ||
last_pre_shot_timeout_ < Time::Now()) {
- state_ = ShooterLatchState::WAITING_FOR_SHOT_NEGEDGE;
+ state_ = ShooterLatchState::INCREMENT_SHOT_COUNT;
}
break;
case ShooterLatchState::WAITING_FOR_SPINUP:
shoot = true;
if (left_.velocity() > goal->angular_velocity * 0.95 &&
right_.velocity() > goal->angular_velocity * 0.95) {
- state_ = ShooterLatchState::WAITING_FOR_SHOT_NEGEDGE;
+ state_ = ShooterLatchState::INCREMENT_SHOT_COUNT;
}
if (::std::abs(goal->angular_velocity) < 10 ||
last_pre_shot_timeout_ < Time::Now()) {
- state_ = ShooterLatchState::WAITING_FOR_SHOT_NEGEDGE;
+ state_ = ShooterLatchState::INCREMENT_SHOT_COUNT;
}
break;
+ case ShooterLatchState::INCREMENT_SHOT_COUNT:
+ ++shots_;
+ state_ = ShooterLatchState::WAITING_FOR_SHOT_NEGEDGE;
+ break;
case ShooterLatchState::WAITING_FOR_SHOT_NEGEDGE:
shoot = true;
if (!goal->push_to_shooter) {
@@ -153,6 +158,8 @@
output->push_to_shooter = shoot;
}
}
+
+ status->shots = shots_;
}
} // namespace shooter
diff --git a/y2016/control_loops/shooter/shooter.h b/y2016/control_loops/shooter/shooter.h
index d3a2f86..0b515f1 100644
--- a/y2016/control_loops/shooter/shooter.h
+++ b/y2016/control_loops/shooter/shooter.h
@@ -65,8 +65,10 @@
WAITING_FOR_SPINDOWN = 1,
// We are latched shooting waiting for the wheel to spin back up.
WAITING_FOR_SPINUP = 2,
+ // Increment the shot count for the Status.
+ INCREMENT_SHOT_COUNT = 3,
// Wait until the button is released.
- WAITING_FOR_SHOT_NEGEDGE = 3
+ WAITING_FOR_SHOT_NEGEDGE = 4,
};
protected:
@@ -78,6 +80,9 @@
private:
ShooterSide left_, right_;
+ // The number of shots since starting the Shooter.
+ uint32_t shots_;
+
// Current state.
ShooterLatchState state_ = ShooterLatchState::PASS_THROUGH;
::aos::time::Time last_pre_shot_timeout_;
diff --git a/y2016/control_loops/shooter/shooter.q b/y2016/control_loops/shooter/shooter.q
index 6598319..b799b5a 100644
--- a/y2016/control_loops/shooter/shooter.q
+++ b/y2016/control_loops/shooter/shooter.q
@@ -48,6 +48,10 @@
// True if the shooter is ready. It is better to compare the velocities
// directly so there isn't confusion on if the goal is up to date.
bool ready;
+
+ // The number of shots that have been fired since the start of the shooter
+ // control loop.
+ uint32_t shots;
};
message Output {