Skip to content

Commit

Permalink
🩹 Handle clang-tidy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
H1rono committed May 17, 2024
1 parent 4165fb9 commit 2fe0594
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace utils {

/// 円周率π
constexpr float PI = 3.1415927F;
constexpr float PI = 3.1415927F; // NOLINT(readability-identifier-length)

} // namespace utils

Expand Down
2 changes: 2 additions & 0 deletions src/packet/input.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "packet/input.hpp"

// NOLINTBEGIN(bugprone-easily-swappable-parameters): FIXME
packet::InputValues::InputValues(
const std::pair<float, float> &joy, const float &volume, const std::array<float, 3> &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;
Expand Down
2 changes: 2 additions & 0 deletions src/packet/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

using float_pair = std::pair<float, float>;

// 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;
Expand Down
13 changes: 8 additions & 5 deletions src/schneider_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ auto Schneider::set_q(const std::array<float, 3>& gyro) -> packet::OutputValues
using float_pair = std::pair<float, float>;
// 系への入力値の実効下限値
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;
Expand All @@ -237,18 +241,16 @@ auto Schneider::set_q(const std::array<float, 3>& 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<float, float>;
// volumeのしきい値
Expand All @@ -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});
Expand Down

0 comments on commit 2fe0594

Please sign in to comment.