Make a DurationInSeconds function
Also, run clang-format on all the files I changed because I am too lazy
to figure out how to call clang-format on just the lines I changed.
Change-Id: I071c6f81dced533a0a269f25a258348132a7056a
diff --git a/y2017/control_loops/superstructure/column/column.cc b/y2017/control_loops/superstructure/column/column.cc
index 8a3644e..85af86b 100644
--- a/y2017/control_loops/superstructure/column/column.cc
+++ b/y2017/control_loops/superstructure/column/column.cc
@@ -127,9 +127,7 @@
indexer_dt_velocity_ =
(new_position.indexer.encoder - indexer_last_position_) /
- chrono::duration_cast<chrono::duration<double>>(
- ::aos::controls::kLoopFrequency)
- .count();
+ ::aos::time::DurationInSeconds(::aos::controls::kLoopFrequency);
indexer_last_position_ = new_position.indexer.encoder;
stuck_indexer_detector_->Correct(Y_);
@@ -144,9 +142,7 @@
indexer_average_angular_velocity_ =
(indexer_history_[indexer_oldest_history_position] -
indexer_history_[indexer_history_position_]) /
- (chrono::duration_cast<chrono::duration<double>>(
- ::aos::controls::kLoopFrequency)
- .count() *
+ (::aos::time::DurationInSeconds(::aos::controls::kLoopFrequency) *
static_cast<double>(kHistoryLength - 1));
// Ready if average angular velocity is close to the goal.
@@ -255,9 +251,8 @@
::Eigen::Matrix<double, 2, 1> goal_state =
profile_.Update(unprofiled_goal_(2, 0), unprofiled_goal_(3, 0));
- constexpr double kDt = chrono::duration_cast<chrono::duration<double>>(
- ::aos::controls::kLoopFrequency)
- .count();
+ constexpr double kDt =
+ ::aos::time::DurationInSeconds(::aos::controls::kLoopFrequency);
loop_->mutable_next_R(0, 0) = 0.0;
// TODO(austin): This might not handle saturation right, but I'm not sure I
@@ -297,7 +292,8 @@
bool ColumnProfiledSubsystem::CheckHardLimits() {
// Returns whether hard limits have been exceeded.
- if (turret_position() > range_.upper_hard || turret_position() < range_.lower_hard) {
+ if (turret_position() > range_.upper_hard ||
+ turret_position() < range_.lower_hard) {
LOG(ERROR,
"ColumnProfiledSubsystem at %f out of bounds [%f, %f], ESTOPing\n",
turret_position(), range_.lower_hard, range_.upper_hard);
diff --git a/y2017/control_loops/superstructure/column/column.h b/y2017/control_loops/superstructure/column/column.h
index 73da9b9..4a4dfbd 100644
--- a/y2017/control_loops/superstructure/column/column.h
+++ b/y2017/control_loops/superstructure/column/column.h
@@ -148,9 +148,7 @@
status->voltage_error = X_hat(5, 0);
status->calculated_velocity =
(turret_position() - turret_last_position_) /
- ::std::chrono::duration_cast<::std::chrono::duration<double>>(
- ::aos::controls::kLoopFrequency)
- .count();
+ ::aos::time::DurationInSeconds(::aos::controls::kLoopFrequency);
status->estimator_state = EstimatorState(0);