Remove easy uses of //aos/mutex
I was hoping to get rid of it completely as one of the nontrivial users
of AOS_LOG, but need to write a compatible condition variable first.
Change-Id: I86c1c4084882bf789baabd0255e115d821154830
diff --git a/y2016/constants.cc b/y2016/constants.cc
index 2b75345..1f4ae9e 100644
--- a/y2016/constants.cc
+++ b/y2016/constants.cc
@@ -1,8 +1,8 @@
#include "y2016/constants.h"
+#include <inttypes.h>
#include <math.h>
#include <stdint.h>
-#include <inttypes.h>
#include <map>
@@ -10,13 +10,13 @@
#include "sanitizer/lsan_interface.h"
#endif
-#include "aos/logging/logging.h"
-#include "aos/mutex/mutex.h"
-#include "aos/network/team_number.h"
#include "absl/base/call_once.h"
+#include "aos/logging/logging.h"
+#include "aos/network/team_number.h"
+#include "aos/stl_mutex/stl_mutex.h"
-#include "y2016/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h"
#include "y2016/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
+#include "y2016/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
@@ -52,23 +52,23 @@
// Intake
{
- 0.0,
- {Values::kZeroingSampleSize, Values::kIntakeEncoderIndexDifference,
- 0.0, 0.3},
+ 0.0,
+ {Values::kZeroingSampleSize,
+ Values::kIntakeEncoderIndexDifference, 0.0, 0.3},
},
// Shoulder
{
- 0.0,
- {Values::kZeroingSampleSize, Values::kShoulderEncoderIndexDifference,
- 0.0, 0.3},
+ 0.0,
+ {Values::kZeroingSampleSize,
+ Values::kShoulderEncoderIndexDifference, 0.0, 0.3},
},
// Wrist
{
- 0.0,
- {Values::kZeroingSampleSize, Values::kWristEncoderIndexDifference,
- 0.0, 0.3},
+ 0.0,
+ {Values::kZeroingSampleSize, Values::kWristEncoderIndexDifference,
+ 0.0, 0.3},
},
0.0,
@@ -81,27 +81,32 @@
5.0, // drivetrain max speed
// Intake
- {// Value to add to the pot reading for the intake.
- -4.550531 + 150.40906362 * M_PI / 180.0 + 0.5098 - 0.0178 - 0.0725,
- {Values::kZeroingSampleSize, Values::kIntakeEncoderIndexDifference,
- // Location of an index pulse.
- 0.018008, 2.5},
+ {
+ // Value to add to the pot reading for the intake.
+ -4.550531 + 150.40906362 * M_PI / 180.0 + 0.5098 - 0.0178 -
+ 0.0725,
+ {Values::kZeroingSampleSize,
+ Values::kIntakeEncoderIndexDifference,
+ // Location of an index pulse.
+ 0.018008, 2.5},
},
// Shoulder
- {// Value to add to the pot reading for the shoulder.
- -2.86275657117,
- {Values::kZeroingSampleSize, Values::kShoulderEncoderIndexDifference,
- 0.097312, 2.5},
+ {
+ // Value to add to the pot reading for the shoulder.
+ -2.86275657117,
+ {Values::kZeroingSampleSize,
+ Values::kShoulderEncoderIndexDifference, 0.097312, 2.5},
},
// Wrist
- {// Value to add to the pot reading for the wrist.
- 3.2390714288298668 + -0.06138835 * M_PI / 180.0 + 0.0078 - 0.0548 -
- 0.0167 + 0.002 - 0.0026 - 0.1040 - 0.0035 - 0.0012 + 0.0166 -
- 0.017 + 0.148 + 0.004 + 0.024701 - 0.0741,
- {Values::kZeroingSampleSize, Values::kWristEncoderIndexDifference,
- 0.000820, 2.5},
+ {
+ // Value to add to the pot reading for the wrist.
+ 3.2390714288298668 + -0.06138835 * M_PI / 180.0 + 0.0078 -
+ 0.0548 - 0.0167 + 0.002 - 0.0026 - 0.1040 - 0.0035 - 0.0012 +
+ 0.0166 - 0.017 + 0.148 + 0.004 + 0.024701 - 0.0741,
+ {Values::kZeroingSampleSize, Values::kWristEncoderIndexDifference,
+ 0.000820, 2.5},
},
0.0,
@@ -113,28 +118,29 @@
5.0, // drivetrain max speed
// Intake
- {// Hard stop is 160.0185751389329 degrees.
- -4.2193 + (160.0185751389329 * M_PI / 180.0 + 0.02 - 0.0235) +
- 0.0549 - 0.104 + 0.019 - 0.938 + 0.660 - 0.002 - 0.2081,
- {Values::kZeroingSampleSize, Values::kIntakeEncoderIndexDifference,
- 0.332370, 1.3},
+ {
+ // Hard stop is 160.0185751389329 degrees.
+ -4.2193 + (160.0185751389329 * M_PI / 180.0 + 0.02 - 0.0235) +
+ 0.0549 - 0.104 + 0.019 - 0.938 + 0.660 - 0.002 - 0.2081,
+ {Values::kZeroingSampleSize,
+ Values::kIntakeEncoderIndexDifference, 0.332370, 1.3},
},
// Shoulder (Now calibrated at 0)
{
- -1.0016 - 0.0841 + 0.06138835 * M_PI / 180.0 + 1.07838 - 1.0441 +
- 0.0034 + 0.0065 - 0.0505,
- {Values::kZeroingSampleSize, Values::kShoulderEncoderIndexDifference,
- 0.027180, 1.3},
+ -1.0016 - 0.0841 + 0.06138835 * M_PI / 180.0 + 1.07838 - 1.0441 +
+ 0.0034 + 0.0065 - 0.0505,
+ {Values::kZeroingSampleSize,
+ Values::kShoulderEncoderIndexDifference, 0.027180, 1.3},
},
// Wrist
{
- 3.326328571170133 - 0.06138835 * M_PI / 180.0 - 0.177 + 0.0323 -
- 0.023 + 0.0488 + 0.0120 - 0.0005 - 0.0784 - 0.0010 - 0.080 +
- 0.1245,
- {Values::kZeroingSampleSize, Values::kWristEncoderIndexDifference,
- -0.263227, 1.3},
+ 3.326328571170133 - 0.06138835 * M_PI / 180.0 - 0.177 + 0.0323 -
+ 0.023 + 0.0488 + 0.0120 - 0.0005 - 0.0784 - 0.0010 - 0.080 +
+ 0.1245,
+ {Values::kZeroingSampleSize, Values::kWristEncoderIndexDifference,
+ -0.263227, 1.3},
},
0.011,
@@ -163,8 +169,8 @@
}
const Values &GetValuesForTeam(uint16_t team_number) {
- static ::aos::Mutex mutex;
- ::aos::MutexLocker locker(&mutex);
+ static aos::stl_mutex mutex;
+ std::unique_lock<aos::stl_mutex> locker(mutex);
// IMPORTANT: This declaration has to stay after the mutex is locked to avoid
// race conditions.