From 2fe0594b977362f1b6c2f6a5d2d9b4aa859a4fe7 Mon Sep 17 00:00:00 2001 From: H1rono Date: Fri, 17 May 2024 11:21:28 +0900 Subject: [PATCH] :adhesive_bandage: Handle clang-tidy errors --- include/utils.hpp | 2 +- src/packet/input.cpp | 2 ++ src/packet/output.cpp | 2 ++ src/schneider_model.cpp | 13 ++++++++----- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/utils.hpp b/include/utils.hpp index f65e5a8..2e07da4 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -5,7 +5,7 @@ namespace utils { /// 円周率π -constexpr float PI = 3.1415927F; +constexpr float PI = 3.1415927F; // NOLINT(readability-identifier-length) } // namespace utils diff --git a/src/packet/input.cpp b/src/packet/input.cpp index 35053bc..31dd422 100644 --- a/src/packet/input.cpp +++ b/src/packet/input.cpp @@ -1,8 +1,10 @@ #include "packet/input.hpp" +// NOLINTBEGIN(bugprone-easily-swappable-parameters): FIXME packet::InputValues::InputValues( const std::pair &joy, const float &volume, const std::array &gyro) : joy(joy), volume(volume), gyro(gyro) {} +// NOLINTEND(bugprone-easily-swappable-parameters) constexpr auto in_range(const float &value) -> bool { return 0 <= value && value <= 1; diff --git a/src/packet/output.cpp b/src/packet/output.cpp index da29861..d0b7ea6 100644 --- a/src/packet/output.cpp +++ b/src/packet/output.cpp @@ -4,8 +4,10 @@ using float_pair = std::pair; +// NOLINTBEGIN(bugprone-easily-swappable-parameters): FIXME packet::OutputValues::OutputValues(const float_pair &servo, const float_pair &dc_motor) : servo(servo), dc_motor(dc_motor) {} +// NOLINTEND(bugprone-easily-swappable-parameters) constexpr auto pi_range(float value) -> bool { return 0 <= value && value <= utils::PI; diff --git a/src/schneider_model.cpp b/src/schneider_model.cpp index b1dc0b3..bdbb96d 100644 --- a/src/schneider_model.cpp +++ b/src/schneider_model.cpp @@ -213,6 +213,10 @@ auto Schneider::set_q(const std::array& gyro) -> packet::OutputValues using float_pair = std::pair; // 系への入力値の実効下限値 constexpr float input_min = 0.4F; + // 3.64 ~= 2200 * PI / 1900 + // ea3f45b の src/schneider_model.cpp:238 と同様の計算式になるように + // TODO: 係数調整 + constexpr float gyro_coef = 3.64F; if (abs(this->inputs[0] <= input_min)) { this->inputs[0] = 0; @@ -237,18 +241,16 @@ auto Schneider::set_q(const std::array& gyro) -> packet::OutputValues float_pair servo_output = this->last_output.servo; if (0 < this->inputs[2] && this->inputs[2] < PI) { - // 3.64 ~= 2200 * PI / 1900 - // ea3f45b の src/schneider_model.cpp:238 と同様の計算式になるように - // TODO: gyroの係数調整 - servo_output.first = this->inputs[2] - 3.64 * gyro[2]; + servo_output.first = this->inputs[2] - gyro_coef * gyro[2]; } if (0 < this->inputs[3] && this->inputs[3] < PI) { - servo_output.second = this->inputs[3] + 3.64 * gyro[2]; + servo_output.second = this->inputs[3] + gyro_coef * gyro[2]; } const packet::OutputValues output(servo_output, fet_output); return output; } +// NOLINTBEGIN(readability-convert-member-functions-to-static) auto Schneider::rotate(const float& volume_value) const -> packet::OutputValues { using float_pair = std::pair; // volumeのしきい値 @@ -261,6 +263,7 @@ auto Schneider::rotate(const float& volume_value) const -> packet::OutputValues const packet::OutputValues output(servo_output, {fet_duty, fet_duty}); return output; } +// NOLINTEND(readability-convert-member-functions-to-static) auto Schneider::stop_fet() const -> packet::OutputValues { packet::OutputValues output(this->last_output.servo, {0, 0});