-
Notifications
You must be signed in to change notification settings - Fork 0
#KL25-29 Robotクラスを作る+Motion クラスを作る #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
240a095
add: 外部リソースを管理するRobotクラスを作成
takuchi17 649f7cf
add: 動作クラスの親クラスであるMotionクラスを作成
takuchi17 cf15fb2
refactor: RobotTestにnamespaceを指定
takuchi17 dda0c37
fix: 公式APIのインクルードパスの修正.テストは通らないが,実機でAPIが使えるか確認するためのコミット
takuchi17 cff8ece
update: docker-compose.yamlが非推奨なためcompose.yamlに変更
takuchi17 64bcdfe
Merge branch 'main' into ticket-KL25-29
takuchi17 3b2d707
update: Motionクラスのメンバrobotの型をポインタから参照に変更
takuchi17 5980b67
refactor: コメントの修正
takuchi17 74da307
refactor: コメントの誤字の修正
takuchi17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| version: '3.8' | ||
|
|
||
| services: | ||
| etrobocon: | ||
| image: chihayataku/kat_etrobo2025:arm64 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| // } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.