File tree Expand file tree Collapse file tree 10 files changed +164
-4
lines changed
Expand file tree Collapse file tree 10 files changed +164
-4
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ set(INCLUDE_DIRS
3838 ${PROJECT_MODULE_DIR} /CameraCapture
3939 ${PROJECT_MODULE_DIR} /calculators
4040 ${PROJECT_MODULE_DIR} /common
41+ ${PROJECT_MODULE_DIR} /motions
4142 ${PROJECT_MODULE_DIR} /API
4243 ${PROJECT_TEST_DIR}
4344 ${PROJECT_TEST_DIR} /dummy
@@ -50,6 +51,7 @@ file(GLOB_RECURSE PROJECT_SOURCES
5051 "${PROJECT_MODULE_DIR} /*.cpp"
5152 "${PROJECT_MODULE_DIR} /CameraCapture/*.cpp"
5253 "${PROJECT_MODULE_DIR} /calculators/*.cpp"
54+ "${PROJECT_MODULE_DIR} /motions/*.cpp"
5355 "${PROJECT_TEST_DIR} /helpers/*.cpp"
5456)
5557
Original file line number Diff line number Diff line change @@ -16,14 +16,17 @@ APPL_DIRS += \
1616 $(mkfile_path ) modules/API\
1717 $(mkfile_path ) modules/calculators\
1818 $(mkfile_path ) modules/common\
19+ $(mkfile_path ) modules/motions\
1920 $(mkfile_path ) modules/CameraCapture
2021
2122INCLUDES += \
2223 -I$(mkfile_path ) modules\
2324 -I$(mkfile_path ) modules/API\
2425 -I$(mkfile_path ) modules/calculators\
2526 -I$(mkfile_path ) modules/common\
27+ -I$(mkfile_path ) modules/motions\
2628 -I$(mkfile_path ) modules/CameraCapture \
29+ -I$(mkfile_path ) ../../common/library/libcpp-spike/include \
2730 -I/usr/include/opencv4
2831
2932APPL_LIBS += $(shell pkg-config --libs opencv4)
Original file line number Diff line number Diff line change 1- version : ' 3.8'
2-
31services :
42 etrobocon :
53 image : chihayataku/kat_etrobo2025:arm64
Original file line number Diff line number Diff line change 11/* *
22 * @file EtRobocon2025.cpp
33 * @brief 全体を制御するクラス
4- * @author takahashitom
4+ * @author takahashitom takuchi17
55 */
66
77#include " EtRobocon2025.h"
88
9+ Robot EtRobocon2025::robot; // Robotインスタンス
10+
911void EtRobocon2025::start ()
1012{
1113 std::cout << " Hello KATLAB" << std::endl;
Original file line number Diff line number Diff line change 11/* *
22 * @file EtRobocon2025.h
33 * @brief 全体を制御するクラス
4- * @author takahashitom
4+ * @author takahashitom takuchi17
55 */
66
77#ifndef ETROBOCON2025_H
88#define ETROBOCON2025_H
99
1010#include < iostream>
11+ #include " Robot.h"
1112
1213class EtRobocon2025 {
1314 public:
1415 static void start ();
16+
17+ private:
18+ static Robot robot; // Robotインスタンス
1519};
1620
1721#endif
Original file line number Diff line number Diff line change 1+ /* *
2+ * @file Robot.cpp
3+ * @brief 外部リソースのインスタンスを管理するクラス
4+ * @author takuchi17
5+ */
6+
7+ #include " Robot.h"
8+
9+ Robot::Robot () : motorController(), cameraCapture() /* , colorSensor(EPort::PORT_E)*/ {}
10+
11+ MotorController& Robot::getMotorControllerInstance ()
12+ {
13+ return motorController;
14+ }
15+
16+ CameraCapture& Robot::getCameraCaptureInstance ()
17+ {
18+ return cameraCapture;
19+ }
20+
21+ // spikeapi::ColorSensor& Robot::getColorSensorInstance()
22+ // {
23+ // return colorSensor;
24+ // }
Original file line number Diff line number Diff line change 1+ /* *
2+ * @file Robot.h
3+ * @brief 外部リソースのインスタンスを管理するクラス
4+ * @author takuchi17
5+ */
6+
7+ #ifndef ROBOT_H
8+ #define ROBOT_H
9+
10+ #include " spikeapi.h"
11+ #include " MotorController.h"
12+ #include " CameraCapture.h"
13+ // #include "ColorSensor.h"
14+
15+ class Robot {
16+ public:
17+ /* *
18+ * コンストラクタ
19+ * @brief 外部リソースのインスタンスを初期化する
20+ */
21+ Robot ();
22+
23+ /* *
24+ * @brief MotorControllerのインスタンスの参照を返す
25+ * @return メンバ変数motorController(MotorControllerのインスタンス)の参照
26+ */
27+ MotorController& getMotorControllerInstance ();
28+
29+ /* *
30+ * @brief CameraCaptureのインスタンスの参照を返す
31+ * @return メンバ変数cameraCapture(CameraCaptureのインスタンス)の参照
32+ */
33+ CameraCapture& getCameraCaptureInstance ();
34+
35+ // /**
36+ // * @brief ColorSensorのインスタンスの参照を返す
37+ // * @return メンバ変数colorSensor(ColorSensorのインスタンス)の参照
38+ // */
39+ // spikeapi::ColorSensor& getColorSensorInstance();
40+
41+ private:
42+ MotorController motorController; // MotorControllerインスタンス
43+ CameraCapture cameraCapture; // CameraCaptureインスタンス
44+ // spikeapi::ColorSensor colorSensor; // ColorSensorインスタンス
45+ };
46+
47+ #endif
Original file line number Diff line number Diff line change 1+ /* *
2+ * @file Motion.cpp
3+ * @brief 動作の親クラス
4+ * @author takuchi17
5+ */
6+
7+ #include " Motion.h"
8+
9+ Motion::Motion (Robot& _robot) : robot(_robot) {}
Original file line number Diff line number Diff line change 1+ /* *
2+ * @file Motion.h
3+ * @brief 動作の親クラス
4+ * @author takuchi17
5+ */
6+
7+ #ifndef MOTION_H
8+ #define MOTION_H
9+
10+ #include " Robot.h"
11+
12+ class Motion {
13+ public:
14+ /* *
15+ * コンストラクタ
16+ * @brief 外部リソースのインスタンスを初期化する
17+ */
18+ Motion (Robot& _robot);
19+
20+ /* *
21+ * @brief 動作を実行する純粋仮想関数
22+ */
23+ virtual void run () = 0;
24+
25+ protected:
26+ Robot& robot; // Robotインスタンスの参照
27+ };
28+
29+ #endif
Original file line number Diff line number Diff line change 1+ /* *
2+ * @file RobotTest.cpp
3+ * @brief Robotクラスのテスト
4+ * @author takuchi17
5+ */
6+
7+ #include < gtest/gtest.h>
8+ #include " Robot.h"
9+
10+ namespace etrobocon2025_test {
11+
12+ // ゲッターで取得したMotorControllerインスタンスが等しいか確認するテスト
13+ TEST (RobotTest, GetMotorControllerInstanceReturnsReference)
14+ {
15+ Robot robot;
16+ MotorController& motorRef1 = robot.getMotorControllerInstance ();
17+ MotorController& motorRef2 = robot.getMotorControllerInstance ();
18+
19+ EXPECT_EQ (&motorRef1, &motorRef2);
20+ }
21+
22+ // ゲッターで取得したCameraCaptureインスタンスが等しいか確認するテスト
23+ TEST (RobotTest, GetCameraCaptureInstanceReturnsReference)
24+ {
25+ Robot robot;
26+ CameraCapture& cameraRef1 = robot.getCameraCaptureInstance ();
27+ CameraCapture& cameraRef2 = robot.getCameraCaptureInstance ();
28+
29+ EXPECT_EQ (&cameraRef1, &cameraRef2);
30+ }
31+
32+ // ゲッターで取得したColorSensorインスタンスが等しいか確認するテスト
33+ // TEST(RobotTest, GetColorSensorInstanceReturnsReference)
34+ // {
35+ // Robot robot;
36+ // spikeapi::ColorSensor& colorSensorRef1 = robot.getColorSensorInstance();
37+ // spikeapi::ColorSensor& colorSensorRef2 = robot.getColorSensorInstance();
38+
39+ // EXPECT_EQ(&colorSensorRef1, &colorSensorRef2);
40+ // }
41+
42+ } // namespace etrobocon2025_test
You can’t perform that action at this time.
0 commit comments