Skip to content

Commit

Permalink
fix: 実機でクラス名が引っ掛かったので修正
Browse files Browse the repository at this point in the history
  • Loading branch information
CHIHAYATAKU committed Jun 8, 2024
1 parent 601677c commit 5cd69ba
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @file Speed.cpp
* @file SpeedCalculator.cpp
* @brief 目標速度に対応するPWM値を算出するクラス
* @author CHIHAYATAKU
*/
#include "Speed.h"
#include "SpeedCalculator.h"

Speed::Speed(double _targetSpeed)
SpeedCalculator::SpeedCalculator(double _targetSpeed)
: rightTargetSpeed(_targetSpeed),
leftTargetSpeed(_targetSpeed),
rightPid(K_P, K_I, K_D, _targetSpeed),
Expand All @@ -22,7 +22,7 @@ Speed::Speed(double _targetSpeed)
prevLeftTime = currentTime;
}

Speed::Speed(double _rightTargetSpeed, double _leftTargetSpeed)
SpeedCalculator::SpeedCalculator(double _rightTargetSpeed, double _leftTargetSpeed)
: rightTargetSpeed(_rightTargetSpeed),
leftTargetSpeed(_leftTargetSpeed),
rightPid(R_K_P, R_K_I, R_K_D, _rightTargetSpeed),
Expand All @@ -39,7 +39,7 @@ Speed::Speed(double _rightTargetSpeed, double _leftTargetSpeed)
prevLeftTime = currentTime;
}

double Speed::calculateRightPwmFromTargetSpeed()
double SpeedCalculator::calculateRightPwmFromTargetSpeed()
{
// 右タイヤの回転角度を取得
int rightAngle = measurer.getRightCount();
Expand All @@ -60,7 +60,7 @@ double Speed::calculateRightPwmFromTargetSpeed()
return rightPwm;
}

double Speed::calculateLeftPwmFromTargetSpeed()
double SpeedCalculator::calculateLeftPwmFromTargetSpeed()
{
// 左タイヤの回転角度を取得
int leftAngle = measurer.getLeftCount();
Expand All @@ -81,7 +81,7 @@ double Speed::calculateLeftPwmFromTargetSpeed()
return leftPwm;
}

double Speed::calculateSpeed(double diffMileage, double diffTime)
double SpeedCalculator::calculateSpeed(double diffMileage, double diffTime)
{
// 走行時間が0のとき、0を返す
if(diffTime == 0.0) return 0.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
/**
* @file Speed.h
* @file SpeedCalculator.h
* @brief 目標速度に対応するPWM値を算出するクラス
* @author CHIHAYATAKU
*/

#ifndef Speed_H
#define Speed_H
#ifndef SPEEDCALCULATOR_H
#define SPEEDCALCULATOR_H

#include "Mileage.h"
#include "Pid.h"
#include "Timer.h"
#include "Controller.h"
#include "Measurer.h"

class Speed {
class SpeedCalculator {
public:
/**
* @brief 引数1つの場合のコンストラクタ
* @param _targetSpeed 目標とする走行速度[mm/s]
*/
Speed(double _targetSpeed);
SpeedCalculator(double _targetSpeed);

/**
* @brief 引数2つの場合のコンストラクタ
* @param _rightTargetSpeed 目標とする右タイヤ走行速度[mm/s]
* @param _leftTargetSpeed 目標とする左タイヤ走行速度[mm/s]
*/
Speed(double _rightTargetSpeed, double _leftTargetSpeed);
SpeedCalculator(double _rightTargetSpeed, double _leftTargetSpeed);

/**
* @brief 目標とする走行速度に相当する右車輪のPWM値を算出する
Expand Down
26 changes: 13 additions & 13 deletions test/SpeedTest.cpp → test/SpeedCalculatorTest.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @file SpeedTest.cpp
* @brief Speedクラスをテストする
* @file SpeedCalculatorTest.cpp
* @brief SpeedCalculatorクラスをテストする
* @author CHIHAYATAKU
*/

#include "Speed.h"
#include "SpeedCalculator.h"
#include <gtest/gtest.h>

namespace etrobocon2024_test {
Expand All @@ -15,7 +15,7 @@ namespace etrobocon2024_test {
// PWMの初期化
controller.setRightMotorPwm(0.0);
controller.setLeftMotorPwm(0.0);
Speed speedCalc(300.0);
SpeedCalculator speedCalc(300.0);
double actualPwm = speedCalc.calculateLeftPwmFromTargetSpeed();
EXPECT_LT(0, actualPwm);
}
Expand All @@ -26,7 +26,7 @@ namespace etrobocon2024_test {
// PWMの初期化
controller.setRightMotorPwm(0.0);
controller.setLeftMotorPwm(0.0);
Speed speedCalc(-250.7);
SpeedCalculator speedCalc(-250.7);
double actualPwm = speedCalc.calculateRightPwmFromTargetSpeed();
EXPECT_GT(0, actualPwm);
}
Expand All @@ -37,7 +37,7 @@ namespace etrobocon2024_test {
// PWMの初期化
controller.setRightMotorPwm(0.0);
controller.setLeftMotorPwm(0.0);
Speed speedCalc(0.0);
SpeedCalculator speedCalc(0.0);
double actualPwm = speedCalc.calculateRightPwmFromTargetSpeed();
EXPECT_EQ(0, actualPwm);
}
Expand All @@ -48,7 +48,7 @@ namespace etrobocon2024_test {
// PWMの初期化
controller.setRightMotorPwm(0.0);
controller.setLeftMotorPwm(0.0);
Speed speedCalc(300.0);
SpeedCalculator speedCalc(300.0);
double actualPwm = speedCalc.calculateRightPwmFromTargetSpeed();
EXPECT_LT(0, actualPwm);
}
Expand All @@ -59,7 +59,7 @@ namespace etrobocon2024_test {
// PWMの初期化
controller.setRightMotorPwm(0.0);
controller.setLeftMotorPwm(0.0);
Speed speedCalc(-250.7);
SpeedCalculator speedCalc(-250.7);
double actualPwm = speedCalc.calculateLeftPwmFromTargetSpeed();
EXPECT_GT(0, actualPwm);
}
Expand All @@ -70,7 +70,7 @@ namespace etrobocon2024_test {
// PWMの初期化
controller.setRightMotorPwm(0.0);
controller.setLeftMotorPwm(0.0);
Speed speedCalc(0.0);
SpeedCalculator speedCalc(0.0);
double actualPwm = speedCalc.calculateLeftPwmFromTargetSpeed();
EXPECT_EQ(0, actualPwm);
}
Expand All @@ -81,7 +81,7 @@ namespace etrobocon2024_test {
// PWMの初期化
controller.setRightMotorPwm(0.0);
controller.setLeftMotorPwm(0.0);
Speed speedCalc(300.0, -300.0);
SpeedCalculator speedCalc(300.0, -300.0);
double actualRightPwm = speedCalc.calculateRightPwmFromTargetSpeed();
double actualLeftPwm = speedCalc.calculateLeftPwmFromTargetSpeed();
EXPECT_LT(0, actualRightPwm);
Expand All @@ -94,7 +94,7 @@ namespace etrobocon2024_test {
// PWMの初期化
controller.setRightMotorPwm(0.0);
controller.setLeftMotorPwm(0.0);
Speed speedCalc(-250.7, 250.7);
SpeedCalculator speedCalc(-250.7, 250.7);
double actualRightPwm = speedCalc.calculateRightPwmFromTargetSpeed();
double actualLeftPwm = speedCalc.calculateLeftPwmFromTargetSpeed();
EXPECT_GT(0, actualRightPwm);
Expand All @@ -107,7 +107,7 @@ namespace etrobocon2024_test {
// PWMの初期化
controller.setRightMotorPwm(0.0);
controller.setLeftMotorPwm(0.0);
Speed speedCalc(0.0, 250.7);
SpeedCalculator speedCalc(0.0, 250.7);
double actualRightPwm = speedCalc.calculateRightPwmFromTargetSpeed();
double actualLeftPwm = speedCalc.calculateLeftPwmFromTargetSpeed();
EXPECT_EQ(0, actualRightPwm);
Expand All @@ -120,7 +120,7 @@ namespace etrobocon2024_test {
// PWMの初期化
controller.setRightMotorPwm(0.0);
controller.setLeftMotorPwm(0.0);
Speed speedCalc(-300.0, 0.0);
SpeedCalculator speedCalc(-300.0, 0.0);
double actualRightPwm = speedCalc.calculateRightPwmFromTargetSpeed();
double actualLeftPwm = speedCalc.calculateLeftPwmFromTargetSpeed();
EXPECT_GT(0, actualRightPwm);
Expand Down

0 comments on commit 5cd69ba

Please sign in to comment.