Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ set(INCLUDE_DIRS
${PROJECT_MODULE_DIR}/CameraCapture
${PROJECT_MODULE_DIR}/calculators
${PROJECT_MODULE_DIR}/common
${PROJECT_MODULE_DIR}/motions
${PROJECT_MODULE_DIR}/API
${PROJECT_TEST_DIR}
${PROJECT_TEST_DIR}/dummy
Expand All @@ -50,6 +51,7 @@ file(GLOB_RECURSE PROJECT_SOURCES
"${PROJECT_MODULE_DIR}/*.cpp"
"${PROJECT_MODULE_DIR}/CameraCapture/*.cpp"
"${PROJECT_MODULE_DIR}/calculators/*.cpp"
"${PROJECT_MODULE_DIR}/motions/*.cpp"
"${PROJECT_TEST_DIR}/helpers/*.cpp"
)

Expand Down
3 changes: 3 additions & 0 deletions Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ APPL_DIRS += \
$(mkfile_path)modules/API\
$(mkfile_path)modules/calculators\
$(mkfile_path)modules/common\
$(mkfile_path)modules/motions\
$(mkfile_path)modules/CameraCapture

INCLUDES += \
-I$(mkfile_path)modules\
-I$(mkfile_path)modules/API\
-I$(mkfile_path)modules/calculators\
-I$(mkfile_path)modules/common\
-I$(mkfile_path)modules/motions\
-I$(mkfile_path)modules/CameraCapture \
-I$(mkfile_path)../../common/library/libcpp-spike/include \
-I/usr/include/opencv4

APPL_LIBS += $(shell pkg-config --libs opencv4)
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yaml → compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
etrobocon:
image: chihayataku/kat_etrobo2025:arm64
Expand Down
4 changes: 3 additions & 1 deletion modules/EtRobocon2025.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/**
* @file EtRobocon2025.cpp
* @brief 全体を制御するクラス
* @author takahashitom
* @author takahashitom takuchi17
*/

#include "EtRobocon2025.h"

Robot EtRobocon2025::robot; // Robotインスタンス

void EtRobocon2025::start()
{
std::cout << "Hello KATLAB" << std::endl;
Expand Down
6 changes: 5 additions & 1 deletion modules/EtRobocon2025.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
/**
* @file EtRobocon2025.h
* @brief 全体を制御するクラス
* @author takahashitom
* @author takahashitom takuchi17
*/

#ifndef ETROBOCON2025_H
#define ETROBOCON2025_H

#include <iostream>
#include "Robot.h"

class EtRobocon2025 {
public:
static void start();

private:
static Robot robot; // Robotインスタンス
};

#endif
24 changes: 24 additions & 0 deletions modules/Robot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @file Robot.cpp
* @brief 外部リソースのインスタンスを管理するクラス
* @author takuchi17
*/

#include "Robot.h"

Robot::Robot() : motorController(), cameraCapture() /*, colorSensor(EPort::PORT_E)*/ {}

MotorController& Robot::getMotorControllerInstance()
{
return motorController;
}

CameraCapture& Robot::getCameraCaptureInstance()
{
return cameraCapture;
}

// spikeapi::ColorSensor& Robot::getColorSensorInstance()
// {
// return colorSensor;
// }
47 changes: 47 additions & 0 deletions modules/Robot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @file Robot.h
* @brief 外部リソースのインスタンスを管理するクラス
* @author takuchi17
*/

#ifndef ROBOT_H
#define ROBOT_H

#include "spikeapi.h"
#include "MotorController.h"
#include "CameraCapture.h"
// #include "ColorSensor.h"

class Robot {
public:
/**
* コンストラクタ
* @brief 外部リソースのインスタンスを初期化する
*/
Robot();

/**
* @brief MotorControllerのインスタンスの参照を返す
* @return メンバ変数motorController(MotorControllerのインスタンス)の参照
*/
MotorController& getMotorControllerInstance();

/**
* @brief CameraCaptureのインスタンスの参照を返す
* @return メンバ変数cameraCapture(CameraCaptureのインスタンス)の参照
*/
CameraCapture& getCameraCaptureInstance();

// /**
// * @brief ColorSensorのインスタンスの参照を返す
// * @return メンバ変数colorSensor(ColorSensorのインスタンス)の参照
// */
// spikeapi::ColorSensor& getColorSensorInstance();

private:
MotorController motorController; // MotorControllerインスタンス
CameraCapture cameraCapture; // CameraCaptureインスタンス
// spikeapi::ColorSensor colorSensor; // ColorSensorインスタンス
};

#endif
9 changes: 9 additions & 0 deletions modules/motions/Motion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @file Motion.cpp
* @brief 動作の親クラス
* @author takuchi17
*/

#include "Motion.h"

Motion::Motion(Robot& _robot) : robot(_robot) {}
29 changes: 29 additions & 0 deletions modules/motions/Motion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @file Motion.h
* @brief 動作の親クラス
* @author takuchi17
*/

#ifndef MOTION_H
#define MOTION_H

#include "Robot.h"

class Motion {
public:
/**
* コンストラクタ
* @brief 外部リソースのインスタンスを初期化する
*/
Motion(Robot& _robot);

/**
* @brief 動作を実行する純粋仮想関数
*/
virtual void run() = 0;

protected:
Robot& robot; // Robotインスタンスの参照
};

#endif
42 changes: 42 additions & 0 deletions tests/RobotTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @file RobotTest.cpp
* @brief Robotクラスのテスト
* @author takuchi17
*/

#include <gtest/gtest.h>
#include "Robot.h"

namespace etrobocon2025_test {

// ゲッターで取得したMotorControllerインスタンスが等しいか確認するテスト
TEST(RobotTest, GetMotorControllerInstanceReturnsReference)
{
Robot robot;
MotorController& motorRef1 = robot.getMotorControllerInstance();
MotorController& motorRef2 = robot.getMotorControllerInstance();

EXPECT_EQ(&motorRef1, &motorRef2);
}

// ゲッターで取得したCameraCaptureインスタンスが等しいか確認するテスト
TEST(RobotTest, GetCameraCaptureInstanceReturnsReference)
{
Robot robot;
CameraCapture& cameraRef1 = robot.getCameraCaptureInstance();
CameraCapture& cameraRef2 = robot.getCameraCaptureInstance();

EXPECT_EQ(&cameraRef1, &cameraRef2);
}

// ゲッターで取得したColorSensorインスタンスが等しいか確認するテスト
// TEST(RobotTest, GetColorSensorInstanceReturnsReference)
// {
// Robot robot;
// spikeapi::ColorSensor& colorSensorRef1 = robot.getColorSensorInstance();
// spikeapi::ColorSensor& colorSensorRef2 = robot.getColorSensorInstance();

// EXPECT_EQ(&colorSensorRef1, &colorSensorRef2);
// }

} // namespace etrobocon2025_test