Replace use of deprecated C Standard library headers in C++ code.
Change-Id: I9fa6630c7e4bdb2897df34d417635d8c7d8253bc
Signed-off-by: Tyler Chatow <tchatow@gmail.com>
diff --git a/y2018/actors/autonomous_actor.cc b/y2018/actors/autonomous_actor.cc
index 89082df..cee84d8 100644
--- a/y2018/actors/autonomous_actor.cc
+++ b/y2018/actors/autonomous_actor.cc
@@ -1,13 +1,11 @@
#include "y2018/actors/autonomous_actor.h"
-#include <inttypes.h>
-
#include <chrono>
+#include <cinttypes>
#include <cmath>
#include "aos/logging/logging.h"
#include "aos/util/phased_loop.h"
-
#include "y2018/control_loops/drivetrain/drivetrain_base.h"
namespace y2018 {
diff --git a/y2018/actors/autonomous_actor_main.cc b/y2018/actors/autonomous_actor_main.cc
index bce375c..71f115e 100644
--- a/y2018/actors/autonomous_actor_main.cc
+++ b/y2018/actors/autonomous_actor_main.cc
@@ -1,4 +1,4 @@
-#include <stdio.h>
+#include <cstdio>
#include "aos/events/shm_event_loop.h"
#include "aos/init.h"
diff --git a/y2018/constants.cc b/y2018/constants.cc
index 156bc5b..e6951cc 100644
--- a/y2018/constants.cc
+++ b/y2018/constants.cc
@@ -1,9 +1,8 @@
#include "y2018/constants.h"
-#include <inttypes.h>
-#include <math.h>
-#include <stdint.h>
-
+#include <cinttypes>
+#include <cmath>
+#include <cstdint>
#include <map>
#if __has_feature(address_sanitizer)
@@ -13,7 +12,6 @@
#include "aos/logging/logging.h"
#include "aos/network/team_number.h"
#include "aos/stl_mutex/stl_mutex.h"
-
#include "y2018/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
#include "y2018/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h"
diff --git a/y2018/constants.h b/y2018/constants.h
index 44f0726..16f1f8c 100644
--- a/y2018/constants.h
+++ b/y2018/constants.h
@@ -1,11 +1,10 @@
#ifndef Y2018_CONSTANTS_H_
#define Y2018_CONSTANTS_H_
-#include <stdint.h>
-#include <math.h>
+#include <cmath>
+#include <cstdint>
#include "frc971/constants.h"
-
#include "y2018/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
#include "y2018/control_loops/superstructure/arm/dynamics.h"
#include "y2018/control_loops/superstructure/intake/intake_plant.h"
@@ -43,7 +42,9 @@
static constexpr double kDrivetrainShifterPotMaxVoltage() { return 3.63; }
static constexpr double kDrivetrainShifterPotMinVoltage() { return 1.94; }
- static constexpr double kProximalEncoderCountsPerRevolution() { return 4096.0; }
+ static constexpr double kProximalEncoderCountsPerRevolution() {
+ return 4096.0;
+ }
static constexpr double kProximalEncoderRatio() {
return (12.0 / 60.0) * (18.0 / 84.0);
}
@@ -84,8 +85,7 @@
static constexpr ::frc971::constants::Range kIntakeRange() {
// TODO(austin) Sort this out.
- return ::frc971::constants::Range{-3.7, (1.25 * M_PI),
- -3.3, M_PI};
+ return ::frc971::constants::Range{-3.7, (1.25 * M_PI), -3.3, M_PI};
}
struct IntakeSide {
diff --git a/y2018/control_loops/python/arm_bounds.cc b/y2018/control_loops/python/arm_bounds.cc
index 2c7b94c..1515192 100644
--- a/y2018/control_loops/python/arm_bounds.cc
+++ b/y2018/control_loops/python/arm_bounds.cc
@@ -3,7 +3,8 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_2_algorithms.h>
#include <CGAL/squared_distance_2.h>
-#include <math.h>
+
+#include <cmath>
#include <iostream>
namespace y2018 {
diff --git a/y2018/control_loops/superstructure/arm/graph.cc b/y2018/control_loops/superstructure/arm/graph.cc
index 54ec79d..ad6f982 100644
--- a/y2018/control_loops/superstructure/arm/graph.cc
+++ b/y2018/control_loops/superstructure/arm/graph.cc
@@ -1,7 +1,7 @@
#include "y2018/control_loops/superstructure/arm/graph.h"
-#include <assert.h>
#include <algorithm>
+#include <cassert>
namespace y2018 {
namespace control_loops {
diff --git a/y2018/control_loops/superstructure/arm/graph.h b/y2018/control_loops/superstructure/arm/graph.h
index 6724eac..5d49dd0 100644
--- a/y2018/control_loops/superstructure/arm/graph.h
+++ b/y2018/control_loops/superstructure/arm/graph.h
@@ -1,9 +1,9 @@
#ifndef Y2018_CONTROL_LOOPS_SUPERSTRUCTURE_ARM_GRAPH_H_
#define Y2018_CONTROL_LOOPS_SUPERSTRUCTURE_ARM_GRAPH_H_
-#include <assert.h>
-#include <stdlib.h>
#include <algorithm>
+#include <cassert>
+#include <cstdlib>
#include <limits>
#include <memory>
#include <vector>
diff --git a/y2018/control_loops/superstructure/intake/intake.h b/y2018/control_loops/superstructure/intake/intake.h
index 7bc3986..09a7e4d 100644
--- a/y2018/control_loops/superstructure/intake/intake.h
+++ b/y2018/control_loops/superstructure/intake/intake.h
@@ -1,7 +1,7 @@
#ifndef Y2018_CONTROL_LOOPS_SUPERSTRUCTURE_INTAKE_INTAKE_H_
#define Y2018_CONTROL_LOOPS_SUPERSTRUCTURE_INTAKE_INTAKE_H_
-#include <math.h>
+#include <cmath>
#include "aos/commonmath.h"
#include "frc971/control_loops/control_loop.h"
diff --git a/y2018/joystick_reader.cc b/y2018/joystick_reader.cc
index b5df79a..42620ff 100644
--- a/y2018/joystick_reader.cc
+++ b/y2018/joystick_reader.cc
@@ -1,9 +1,9 @@
#include <google/protobuf/stubs/stringprintf.h>
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
#include <unistd.h>
+#include <cmath>
+#include <cstdio>
+#include <cstring>
#include <mutex>
#include "aos/actions/actions.h"
diff --git a/y2018/wpilib_interface.cc b/y2018/wpilib_interface.cc
index e3175af..8c8560a 100644
--- a/y2018/wpilib_interface.cc
+++ b/y2018/wpilib_interface.cc
@@ -1,15 +1,16 @@
-#include <inttypes.h>
-#include <stdio.h>
-#include <string.h>
#include <unistd.h>
#include <array>
#include <chrono>
+#include <cinttypes>
#include <cmath>
+#include <cstdio>
+#include <cstring>
#include <functional>
-#include <thread>
#include <memory>
+#include <thread>
+#include "ctre/phoenix/CANifier.h"
#include "frc971/wpilib/ahal/AnalogInput.h"
#include "frc971/wpilib/ahal/Counter.h"
#include "frc971/wpilib/ahal/DigitalGlitchFilter.h"
@@ -18,7 +19,6 @@
#include "frc971/wpilib/ahal/Relay.h"
#include "frc971/wpilib/ahal/Servo.h"
#include "frc971/wpilib/ahal/VictorSP.h"
-#include "ctre/phoenix/CANifier.h"
#undef ERROR
#include "aos/commonmath.h"
@@ -55,8 +55,8 @@
#define M_PI 3.14159265358979323846
#endif
-using std::make_unique;
using ::aos::monotonic_clock;
+using std::make_unique;
using ::y2018::constants::Values;
namespace chrono = ::std::chrono;
namespace superstructure = ::y2018::control_loops::superstructure;
@@ -262,7 +262,8 @@
box_back_beambreak_ = ::std::move(input);
}
- void set_lidar_lite_input(::std::unique_ptr<frc::DigitalInput> lidar_lite_input) {
+ void set_lidar_lite_input(
+ ::std::unique_ptr<frc::DigitalInput> lidar_lite_input) {
lidar_lite_input_ = ::std::move(lidar_lite_input);
lidar_lite_.set_input(lidar_lite_input_.get());
}
@@ -277,17 +278,17 @@
drivetrain_builder.add_left_encoder(
drivetrain_translate(drivetrain_left_encoder_->GetRaw()));
- drivetrain_builder.add_left_speed (
+ drivetrain_builder.add_left_speed(
drivetrain_velocity_translate(drivetrain_left_encoder_->GetPeriod()));
- drivetrain_builder.add_left_shifter_position (
+ drivetrain_builder.add_left_shifter_position(
drivetrain_shifter_pot_translate(
left_drivetrain_shifter_->GetVoltage()));
- drivetrain_builder.add_right_encoder (
+ drivetrain_builder.add_right_encoder(
-drivetrain_translate(drivetrain_right_encoder_->GetRaw()));
- drivetrain_builder.add_right_speed (
- -drivetrain_velocity_translate(drivetrain_right_encoder_->GetPeriod()));
- drivetrain_builder.add_right_shifter_position (
+ drivetrain_builder.add_right_speed(-drivetrain_velocity_translate(
+ drivetrain_right_encoder_->GetPeriod()));
+ drivetrain_builder.add_right_shifter_position(
drivetrain_shifter_pot_translate(
right_drivetrain_shifter_->GetVoltage()));
@@ -299,8 +300,7 @@
const auto values = constants::GetValues();
{
- auto builder =
- superstructure_position_sender_.MakeBuilder();
+ auto builder = superstructure_position_sender_.MakeBuilder();
// Proximal arm
frc971::PotAndAbsolutePositionT arm_proximal;
@@ -330,8 +330,7 @@
// Left intake
frc971::PotAndAbsolutePositionT left_intake_motor_position;
- CopyPosition(left_intake_encoder_,
- &left_intake_motor_position,
+ CopyPosition(left_intake_encoder_, &left_intake_motor_position,
Values::kIntakeMotorEncoderCountsPerRevolution(),
Values::kIntakeMotorEncoderRatio(), intake_pot_translate,
false, values.left_intake.potentiometer_offset);
@@ -342,15 +341,14 @@
// Right intake
frc971::PotAndAbsolutePositionT right_intake_motor_position;
- CopyPosition(right_intake_encoder_,
- &right_intake_motor_position,
+ CopyPosition(right_intake_encoder_, &right_intake_motor_position,
Values::kIntakeMotorEncoderCountsPerRevolution(),
Values::kIntakeMotorEncoderRatio(), intake_pot_translate,
true, values.right_intake.potentiometer_offset);
flatbuffers::Offset<frc971::PotAndAbsolutePosition>
right_intake_motor_position_offset =
- frc971::PotAndAbsolutePosition::Pack(*builder.fbb(),
- &right_intake_motor_position);
+ frc971::PotAndAbsolutePosition::Pack(
+ *builder.fbb(), &right_intake_motor_position);
superstructure::IntakeElasticSensors::Builder
left_intake_sensors_builder =
@@ -780,8 +778,8 @@
// Thread 4.
::aos::ShmEventLoop imu_event_loop(&config.message());
auto imu_trigger = make_unique<frc::DigitalInput>(5);
- ::frc971::wpilib::ADIS16448 imu(&imu_event_loop, frc::SPI::Port::kOnboardCS1,
- imu_trigger.get());
+ ::frc971::wpilib::ADIS16448 imu(
+ &imu_event_loop, frc::SPI::Port::kOnboardCS1, imu_trigger.get());
imu.SetDummySPI(frc::SPI::Port::kOnboardCS2);
auto imu_reset = make_unique<frc::DigitalOutput>(6);
imu.set_reset(imu_reset.get());