Remove global .frc971.control_loops.drivetrain_queue object
Change-Id: I424f09dcc8bc210e49cbdc805d1a423a72332617
diff --git a/y2018/actors/autonomous_actor.cc b/y2018/actors/autonomous_actor.cc
index 5b4bda8..80cdbe9 100644
--- a/y2018/actors/autonomous_actor.cc
+++ b/y2018/actors/autonomous_actor.cc
@@ -16,12 +16,13 @@
using ::frc971::ProfileParameters;
using ::aos::monotonic_clock;
-using ::frc971::control_loops::drivetrain_queue;
namespace chrono = ::std::chrono;
namespace this_thread = ::std::this_thread;
namespace {
+namespace arm = ::y2018::control_loops::superstructure::arm;
+
const ProfileParameters kFinalSwitchDrive = {0.5, 1.5};
const ProfileParameters kDrive = {5.0, 2.5};
const ProfileParameters kThirdBoxDrive = {3.0, 2.5};
diff --git a/y2018/actors/autonomous_actor.h b/y2018/actors/autonomous_actor.h
index 1b20190..4cedff3 100644
--- a/y2018/actors/autonomous_actor.h
+++ b/y2018/actors/autonomous_actor.h
@@ -15,9 +15,6 @@
namespace y2018 {
namespace actors {
-using ::frc971::control_loops::drivetrain_queue;
-
-namespace arm = ::y2018::control_loops::superstructure::arm;
class AutonomousActor : public ::frc971::autonomous::BaseAutonomousActor {
public:
@@ -31,7 +28,8 @@
roller_voltage_ = 0.0;
left_intake_angle_ = -3.2;
right_intake_angle_ = -3.2;
- arm_goal_position_ = arm::NeutralIndex();
+ arm_goal_position_ =
+ ::y2018::control_loops::superstructure::arm::NeutralIndex();
grab_box_ = false;
open_claw_ = false;
close_claw_ = false;
@@ -50,7 +48,8 @@
double roller_voltage_ = 0.0;
double left_intake_angle_ = -3.2;
double right_intake_angle_ = -3.2;
- uint32_t arm_goal_position_ = arm::NeutralIndex();
+ uint32_t arm_goal_position_ =
+ ::y2018::control_loops::superstructure::arm::NeutralIndex();
bool grab_box_ = false;
bool open_claw_ = false;
bool close_claw_ = false;
@@ -125,22 +124,22 @@
}
superstructure_status_fetcher_.Fetch();
- drivetrain_queue.status.FetchLatest();
- if (drivetrain_queue.status.get() &&
+ drivetrain_status_fetcher_.Fetch();
+ if (drivetrain_status_fetcher_.get() &&
superstructure_status_fetcher_.get()) {
const double left_profile_error =
(initial_drivetrain_.left -
- drivetrain_queue.status->profiled_left_position_goal);
+ drivetrain_status_fetcher_->profiled_left_position_goal);
const double right_profile_error =
(initial_drivetrain_.right -
- drivetrain_queue.status->profiled_right_position_goal);
+ drivetrain_status_fetcher_->profiled_right_position_goal);
const double left_error =
(initial_drivetrain_.left -
- drivetrain_queue.status->estimated_left_position);
+ drivetrain_status_fetcher_->estimated_left_position);
const double right_error =
(initial_drivetrain_.right -
- drivetrain_queue.status->estimated_right_position);
+ drivetrain_status_fetcher_->estimated_right_position);
const double profile_distance_to_go =
(left_profile_error + right_profile_error) / 2.0;
diff --git a/y2018/control_loops/superstructure/superstructure.cc b/y2018/control_loops/superstructure/superstructure.cc
index d0ff71d..24a8880 100644
--- a/y2018/control_loops/superstructure/superstructure.cc
+++ b/y2018/control_loops/superstructure/superstructure.cc
@@ -33,6 +33,10 @@
vision_status_fetcher_(
event_loop->MakeFetcher<::y2018::vision::VisionStatus>(
".y2018.vision.vision_status")),
+ drivetrain_output_fetcher_(
+ event_loop
+ ->MakeFetcher<::frc971::control_loops::DrivetrainQueue::Output>(
+ ".frc971.control_loops.drivetrain_queue.output")),
intake_left_(constants::GetValues().left_intake.zeroing),
intake_right_(constants::GetValues().right_intake.zeroing) {}
@@ -256,7 +260,7 @@
}
status->rotation_state = static_cast<uint32_t>(rotation_state_);
- ::frc971::control_loops::drivetrain_queue.output.FetchLatest();
+ drivetrain_output_fetcher_.Fetch();
vision_status_fetcher_.Fetch();
monotonic_clock::time_point monotonic_now = event_loop()->monotonic_now();
@@ -275,11 +279,10 @@
SendColors(0.0, 0.0, 0.5);
} else if (position->box_distance < 0.2) {
SendColors(0.0, 0.5, 0.0);
- } else if (::frc971::control_loops::drivetrain_queue.output.get() &&
- ::std::max(::std::abs(::frc971::control_loops::drivetrain_queue
- .output->left_voltage),
- ::std::abs(::frc971::control_loops::drivetrain_queue
- .output->right_voltage)) > 11.5) {
+ } else if (drivetrain_output_fetcher_.get() &&
+ ::std::max(::std::abs(drivetrain_output_fetcher_->left_voltage),
+ ::std::abs(drivetrain_output_fetcher_->right_voltage)) >
+ 11.5) {
SendColors(0.5, 0.0, 0.5);
} else {
SendColors(0.0, 0.0, 0.0);
diff --git a/y2018/control_loops/superstructure/superstructure.h b/y2018/control_loops/superstructure/superstructure.h
index bceb643..81b6d9d 100644
--- a/y2018/control_loops/superstructure/superstructure.h
+++ b/y2018/control_loops/superstructure/superstructure.h
@@ -5,6 +5,7 @@
#include "aos/controls/control_loop.h"
#include "aos/events/event-loop.h"
+#include "frc971/control_loops/drivetrain/drivetrain.q.h"
#include "frc971/control_loops/state_feedback_loop.h"
#include "y2018/control_loops/superstructure/arm/arm.h"
#include "y2018/control_loops/superstructure/intake/intake.h"
@@ -40,6 +41,8 @@
::aos::Sender<::y2018::StatusLight> status_light_sender_;
::aos::Fetcher<::y2018::vision::VisionStatus> vision_status_fetcher_;
+ ::aos::Fetcher<::frc971::control_loops::DrivetrainQueue::Output>
+ drivetrain_output_fetcher_;
intake::IntakeSide intake_left_;
intake::IntakeSide intake_right_;
diff --git a/y2018/control_loops/superstructure/superstructure_lib_test.cc b/y2018/control_loops/superstructure/superstructure_lib_test.cc
index 8533dce..202c428 100644
--- a/y2018/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2018/control_loops/superstructure/superstructure_lib_test.cc
@@ -274,7 +274,6 @@
".y2018.control_loops.superstructure.status",
".y2018.control_loops.superstructure.position"),
superstructure_(&event_loop_, ".y2018.control_loops.superstructure") {
- ::frc971::control_loops::drivetrain_queue.output.Clear();
set_team_id(::frc971::control_loops::testing::kTeamNumber);
}
diff --git a/y2018/joystick_reader.cc b/y2018/joystick_reader.cc
index eb23196..d819c6f 100644
--- a/y2018/joystick_reader.cc
+++ b/y2018/joystick_reader.cc
@@ -25,7 +25,6 @@
#include "y2018/vision.pb.h"
using ::aos::monotonic_clock;
-using ::frc971::control_loops::drivetrain_queue;
using ::aos::events::ProtoTXUdpSocket;
using ::aos::events::RXUdpSocket;
using ::aos::input::driver_station::ButtonLocation;
diff --git a/y2018/wpilib_interface.cc b/y2018/wpilib_interface.cc
index 16c95c8..903301e 100644
--- a/y2018/wpilib_interface.cc
+++ b/y2018/wpilib_interface.cc
@@ -56,7 +56,6 @@
#define M_PI 3.14159265358979323846
#endif
-using ::frc971::control_loops::drivetrain_queue;
using ::y2018::control_loops::SuperstructureQueue;
using ::y2018::constants::Values;
using ::aos::monotonic_clock;
@@ -148,7 +147,11 @@
: ::frc971::wpilib::SensorReader(event_loop),
superstructure_position_sender_(
event_loop->MakeSender<SuperstructureQueue::Position>(
- ".y2018.control_loops.superstructure_queue.position")) {
+ ".y2018.control_loops.superstructure_queue.position")),
+ drivetrain_position_sender_(
+ event_loop->MakeSender<
+ ::frc971::control_loops::DrivetrainQueue::Position>(
+ ".frc971.control_loops.drivetrain_queue.position")) {
// Set to filter out anything shorter than 1/4 of the minimum pulse width
// we should ever see.
UpdateFastEncoderFilterHz(kMaxFastEncoderPulsesPerSecond);
@@ -269,7 +272,7 @@
void RunIteration() {
{
- auto drivetrain_message = drivetrain_queue.position.MakeMessage();
+ auto drivetrain_message = drivetrain_position_sender_.MakeMessage();
drivetrain_message->left_encoder =
drivetrain_translate(drivetrain_left_encoder_->GetRaw());
drivetrain_message->left_speed =
@@ -344,6 +347,8 @@
private:
::aos::Sender<SuperstructureQueue::Position> superstructure_position_sender_;
+ ::aos::Sender<::frc971::control_loops::DrivetrainQueue::Position>
+ drivetrain_position_sender_;
::std::unique_ptr<frc::AnalogInput> left_drivetrain_shifter_,
right_drivetrain_shifter_;