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/y2019/actors/autonomous_actor.cc b/y2019/actors/autonomous_actor.cc
index 078ad64..7622a64 100644
--- a/y2019/actors/autonomous_actor.cc
+++ b/y2019/actors/autonomous_actor.cc
@@ -1,13 +1,11 @@
#include "y2019/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 "frc971/control_loops/drivetrain/localizer_generated.h"
#include "y2019/actors/auto_splines.h"
#include "y2019/control_loops/drivetrain/drivetrain_base.h"
@@ -15,8 +13,8 @@
namespace y2019 {
namespace actors {
-using ::frc971::ProfileParametersT;
using ::aos::monotonic_clock;
+using ::frc971::ProfileParametersT;
using frc971::control_loops::drivetrain::LocalizerControl;
namespace chrono = ::std::chrono;
diff --git a/y2019/actors/autonomous_actor_main.cc b/y2019/actors/autonomous_actor_main.cc
index ec5234b..d04a806 100644
--- a/y2019/actors/autonomous_actor_main.cc
+++ b/y2019/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/y2019/constants.cc b/y2019/constants.cc
index 0a56ca5..f86110c 100644
--- a/y2019/constants.cc
+++ b/y2019/constants.cc
@@ -1,7 +1,6 @@
#include "y2019/constants.h"
-#include <inttypes.h>
-
+#include <cinttypes>
#include <map>
#if __has_feature(address_sanitizer)
diff --git a/y2019/constants.h b/y2019/constants.h
index d1d0c7c..b6c1b55 100644
--- a/y2019/constants.h
+++ b/y2019/constants.h
@@ -2,18 +2,18 @@
#define Y2019_CONSTANTS_H_
#include <array>
-#include <math.h>
-#include <stdint.h>
+#include <cmath>
+#include <cstdint>
#include "frc971/constants.h"
#include "frc971/control_loops/drivetrain/camera.h"
+#include "frc971/control_loops/pose.h"
#include "frc971/control_loops/static_zeroing_single_dof_profiled_subsystem.h"
#include "y2019/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
#include "y2019/control_loops/superstructure/elevator/elevator_plant.h"
#include "y2019/control_loops/superstructure/intake/intake_plant.h"
#include "y2019/control_loops/superstructure/stilts/stilts_plant.h"
#include "y2019/control_loops/superstructure/wrist/wrist_plant.h"
-#include "frc971/control_loops/pose.h"
namespace y2019 {
namespace constants {
@@ -28,7 +28,6 @@
//
// All ratios are from the encoder shaft to the output units.
-
class Field {
public:
typedef ::frc971::control_loops::TypedPose<double> Pose;
diff --git a/y2019/image_streamer/flip_image.h b/y2019/image_streamer/flip_image.h
index 7c31774..6837fb7 100644
--- a/y2019/image_streamer/flip_image.h
+++ b/y2019/image_streamer/flip_image.h
@@ -1,8 +1,9 @@
#ifndef Y2019_IMAGE_STREAMER_FLIP_IMAGE_H_
#define Y2019_IMAGE_STREAMER_FLIP_IMAGE_H_
-#include <stddef.h>
-#include <stdio.h>
+#include <cstddef>
+#include <cstdio>
+
#include "third_party/libjpeg/jerror.h"
#include "third_party/libjpeg/jpeglib.h"
diff --git a/y2019/jevois/camera/reader.cc b/y2019/jevois/camera/reader.cc
index 14faa24..259e650 100644
--- a/y2019/jevois/camera/reader.cc
+++ b/y2019/jevois/camera/reader.cc
@@ -1,17 +1,18 @@
#include "y2019/jevois/camera/reader.h"
-#include <errno.h>
#include <fcntl.h>
#include <malloc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
+#include <cerrno>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
#include "aos/time/time.h"
#include "glog/logging.h"
diff --git a/y2019/jevois/camera/reader.h b/y2019/jevois/camera/reader.h
index c5498fe..ef4f34d 100644
--- a/y2019/jevois/camera/reader.h
+++ b/y2019/jevois/camera/reader.h
@@ -1,7 +1,7 @@
#ifndef AOS_VISION_IMAGE_READER_H_
#define AOS_VISION_IMAGE_READER_H_
-#include <inttypes.h>
+#include <cinttypes>
#include <functional>
#include <string>
diff --git a/y2019/jevois/cobs.h b/y2019/jevois/cobs.h
index 0e92ed6..75761c9 100644
--- a/y2019/jevois/cobs.h
+++ b/y2019/jevois/cobs.h
@@ -1,10 +1,9 @@
#ifndef Y2019_JEVOIS_COBS_H_
#define Y2019_JEVOIS_COBS_H_
-#include <stdint.h>
-
#include <algorithm>
#include <array>
+#include <cstdint>
#include "third_party/GSL/include/gsl/gsl"
diff --git a/y2019/jevois/spi.h b/y2019/jevois/spi.h
index 8b16d5c..59e321a 100644
--- a/y2019/jevois/spi.h
+++ b/y2019/jevois/spi.h
@@ -1,12 +1,11 @@
#ifndef Y2019_JEVOIS_SPI_H_
#define Y2019_JEVOIS_SPI_H_
-#include <stdint.h>
-
#include <array>
+#include <cstdint>
+#include <optional>
#include "third_party/GSL/include/gsl/gsl"
-#include <optional>
#include "y2019/jevois/structures.h"
// This file manages serializing and deserializing the various structures for
diff --git a/y2019/jevois/spi_test.cc b/y2019/jevois/spi_test.cc
index 84938f0..c600869 100644
--- a/y2019/jevois/spi_test.cc
+++ b/y2019/jevois/spi_test.cc
@@ -1,6 +1,6 @@
#include "y2019/jevois/spi.h"
-#include <stdint.h>
+#include <cstdint>
#include "gtest/gtest.h"
diff --git a/y2019/jevois/structures.h b/y2019/jevois/structures.h
index fcf1ebe..b4bd755 100644
--- a/y2019/jevois/structures.h
+++ b/y2019/jevois/structures.h
@@ -1,14 +1,12 @@
#ifndef Y2019_JEVOIS_STRUCTURES_H_
#define Y2019_JEVOIS_STRUCTURES_H_
-#include <stdint.h>
-
#include <array>
#include <bitset>
#include <chrono>
+#include <cstdint>
#include "Eigen/Dense"
-
#include "aos/containers/sized_array.h"
#include "aos/time/time.h"
#include "third_party/GSL/include/gsl/gsl"
@@ -58,9 +56,7 @@
}
return true;
}
- bool operator!=(const Target &other) const {
- return !(*this == other);
- }
+ bool operator!=(const Target &other) const { return !(*this == other); }
// Distance to the target in meters. Specifically, the distance from the
// center of the camera's image plane to the center of the target.
@@ -95,9 +91,7 @@
}
return true;
}
- bool operator!=(const CameraFrame &other) const {
- return !(*this == other);
- }
+ bool operator!=(const CameraFrame &other) const { return !(*this == other); }
// The top most interesting targets found in this frame.
aos::SizedArray<Target, 3> targets;
@@ -120,9 +114,7 @@
}
return true;
}
- bool operator!=(const RoborioFrame &other) const {
- return !(*this == other);
- }
+ bool operator!=(const RoborioFrame &other) const { return !(*this == other); }
// The top most interesting targets found in this frame.
aos::SizedArray<Target, 3> targets;
diff --git a/y2019/jevois/teensy.cc b/y2019/jevois/teensy.cc
index 4da89a8..038ece9 100644
--- a/y2019/jevois/teensy.cc
+++ b/y2019/jevois/teensy.cc
@@ -1,6 +1,5 @@
-#include <inttypes.h>
-#include <stdio.h>
-
+#include <cinttypes>
+#include <cstdio>
#include <optional>
#include "aos/time/time.h"
@@ -17,8 +16,8 @@
#include "y2019/jevois/uart.h"
#include "y2019/vision/constants.h"
-using frc971::teensy::InterruptBufferedUart;
using frc971::teensy::InterruptBufferedSpi;
+using frc971::teensy::InterruptBufferedUart;
// All indices here refer to the ports as numbered on the PCB.
@@ -126,7 +125,8 @@
}
const auto now = aos::monotonic_clock::now();
if (TransferTimedOut(now)) {
- printf("SPI timeout with %d left\n", static_cast<int>(to_receive_.size()));
+ printf("SPI timeout with %d left\n",
+ static_cast<int>(to_receive_.size()));
WaitForNextTransfer();
return std::nullopt;
}
@@ -138,7 +138,8 @@
}
}
if (DeassertHappened(now)) {
- printf("CS deasserted with %d left\n", static_cast<int>(to_receive_.size()));
+ printf("CS deasserted with %d left\n",
+ static_cast<int>(to_receive_.size()));
WaitForNextTransfer();
return std::nullopt;
}
@@ -441,9 +442,7 @@
global_spi_instance->HandleInterrupt(disable_interrupts);
}
-void porta_isr(void) {
- SpiQueue::global_instance->HandleInterrupt();
-}
+void porta_isr(void) { SpiQueue::global_instance->HandleInterrupt(); }
} // extern "C"
@@ -1016,9 +1015,7 @@
extern "C" {
-int main(void) {
- return Main();
-}
+int main(void) { return Main(); }
} // extern "C"
diff --git a/y2019/jevois/uart_test.cc b/y2019/jevois/uart_test.cc
index 4f58e73..ff02f08 100644
--- a/y2019/jevois/uart_test.cc
+++ b/y2019/jevois/uart_test.cc
@@ -1,6 +1,6 @@
#include "y2019/jevois/uart.h"
-#include <stdint.h>
+#include <cstdint>
#include "gtest/gtest.h"
diff --git a/y2019/joystick_reader.cc b/y2019/joystick_reader.cc
index 7351130..a92dd90 100644
--- a/y2019/joystick_reader.cc
+++ b/y2019/joystick_reader.cc
@@ -1,9 +1,9 @@
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
#include <unistd.h>
#include <chrono>
+#include <cmath>
+#include <cstdio>
+#include <cstring>
#include "aos/actions/actions.h"
#include "aos/init.h"
diff --git a/y2019/vision/constants.h b/y2019/vision/constants.h
index b61bff7..8510f4c 100644
--- a/y2019/vision/constants.h
+++ b/y2019/vision/constants.h
@@ -1,8 +1,8 @@
#ifndef _Y2019_VISION_CONSTANTS_H_
#define _Y2019_VISION_CONSTANTS_H_
-#include <math.h>
#include <array>
+#include <cmath>
#include <string>
namespace y2019 {
diff --git a/y2019/vision/target_geometry.cc b/y2019/vision/target_geometry.cc
index 212759a..86ead34 100644
--- a/y2019/vision/target_geometry.cc
+++ b/y2019/vision/target_geometry.cc
@@ -1,16 +1,14 @@
-#include "y2019/vision/target_finder.h"
-
-#include "ceres/ceres.h"
-
-#include <math.h>
+#include <cmath>
#include "aos/util/math.h"
+#include "ceres/ceres.h"
+#include "y2019/vision/target_finder.h"
using ceres::CENTRAL;
using ceres::CostFunction;
using ceres::Problem;
-using ceres::Solver;
using ceres::Solve;
+using ceres::Solver;
namespace y2019 {
namespace vision {
@@ -75,7 +73,7 @@
// Used at runtime on a single image given camera parameters.
struct PointCostFunctor {
PointCostFunctor(Vector<2> result, Vector<2> template_pt,
- IntrinsicParams intrinsics)
+ IntrinsicParams intrinsics)
: result(result), template_pt(template_pt), intrinsics(intrinsics) {}
template <typename T>
@@ -110,7 +108,7 @@
// Distance from line(P1, P2) to point result
T dx = p2.x() - p1.x();
T dy = p2.y() - p1.y();
- T denom = (p2-p1).norm();
+ T denom = (p2 - p1).norm();
residual[0] = ceres::abs(dy * result.x() - dx * result.y() +
p2.x() * p1.y() - p2.y() * p1.x()) /
denom;
@@ -147,8 +145,7 @@
down_axis.normalize();
// Positive means out.
- const T component =
- down_axis.transpose() * (bottom_point_ - p1);
+ const T component = down_axis.transpose() * (bottom_point_ - p1);
if (component > T(0)) {
residual[0] = component * 1.0;
@@ -187,7 +184,7 @@
aos::vision::Vector<2> b = target_value[i];
if (i % 2 == 1) {
- aos::vision::Vector<2> a2 = template_value[i-1];
+ aos::vision::Vector<2> a2 = template_value[i - 1];
aos::vision::Segment<2> line = Segment<2>(a, a2);
problem_4point.AddResidualBlock(
@@ -212,8 +209,8 @@
Solver::Summary summary_8point;
Solve(options, &problem_8point, &summary_8point);
-
- // So, let's sneak up on it. Start by warm-starting it with where we got on the 8 point solution.
+ // So, let's sneak up on it. Start by warm-starting it with where we got on
+ // the 8 point solution.
ExtrinsicParams::get(¶ms_8point[0]).set(¶ms_4point[0]);
// Then solve without the bottom constraint.
Solver::Summary summary_4point1;
@@ -334,7 +331,6 @@
std::cout << "r1 = " << IR.backup_extrinsics.r1 * 180 / M_PI << ";\n";
std::cout << "r2 = " << IR.backup_extrinsics.r2 * 180 / M_PI << ";\n";
-
printf("left upper outer corner angle: %f, top (%f, %f), outer (%f, %f)\n",
(outer_left_vector.transpose() * top_left_vector)(0),
top_left_vector(0, 0), top_left_vector(1, 0),
diff --git a/y2019/wpilib_interface.cc b/y2019/wpilib_interface.cc
index 891031a..885bc12 100644
--- a/y2019/wpilib_interface.cc
+++ b/y2019/wpilib_interface.cc
@@ -1,15 +1,15 @@
-#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 <memory>
#include <mutex>
#include <thread>
-#include <memory>
#include "ctre/phoenix/CANifier.h"
#include "frc971/wpilib/ahal/AnalogInput.h"