-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2e6149
commit 205bfeb
Showing
12 changed files
with
230 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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,51 @@ | ||
/** | ||
* @file EtRobocon2024.cpp | ||
* @brief 全体を制御するクラス | ||
* @author Negihara | ||
*/ | ||
|
||
#include "EtRobocon2024.h" | ||
// ev3api.hをインクルードしているものは.cppに書く | ||
// #include "ev3api.h" | ||
// #include "ColorSensor.h" | ||
// #include "SonarSensor.h" | ||
// #include "Motor.h" | ||
// #include "Clock.h" | ||
|
||
void EtRobocon2024::start() | ||
{ | ||
// const ePortS colorSensorPort = PORT_2; | ||
// const ePortS sonarSensorPort = PORT_3; | ||
// const ePortM armMotorPort = PORT_A; | ||
// const ePortM rightMotorPort = PORT_B; | ||
// const ePortM leftMotorPort = PORT_C; | ||
|
||
// ev3api::ColorSensor* _colorSensorPtr = new ev3api::ColorSensor(colorSensorPort); | ||
// ev3api::SonarSensor* _sonarSensorPtr = new ev3api::SonarSensor(sonarSensorPort); | ||
// ev3api::Motor* _rightMotorPtr = new ev3api::Motor(rightMotorPort); | ||
// ev3api::Motor* _leftMotorPtr = new ev3api::Motor(leftMotorPort); | ||
// ev3api::Motor* _armMotorPtr = new ev3api::Motor(armMotorPort); | ||
// ev3api::Clock* _clockPtr = new ev3api::Clock(); | ||
|
||
// const int BUF_SIZE = 128; | ||
// char buf[BUF_SIZE]; // log用にメッセージを一時保持する領域 | ||
|
||
// bool isLeftCourse = false; | ||
// bool isLeftEdge = false; | ||
|
||
// // 強制終了(CTRL+C)のシグナルを登録する | ||
// signal(SIGINT, sigint); | ||
|
||
// // キャリブレーションする | ||
|
||
// // 合図を送るまで待機する | ||
|
||
// // スタートのメッセージログを出す | ||
// const char* course = isLeftCourse ? "Left" : "Right"; | ||
// snprintf(buf, BUF_SIZE, "\nRun on the %s Course\n", course); | ||
} | ||
|
||
// void EtRobocon2024::sigint(int _) | ||
// { | ||
// _exit(0); // システムコールで強制終了 | ||
// } |
This file contains 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,26 @@ | ||
/** | ||
* @file EtRobocon2024.h | ||
* @brief 全体を制御するクラス | ||
* @author Negihara | ||
*/ | ||
|
||
#ifndef ETROBOCON2024_H | ||
#define ETROBOCON2024_H | ||
|
||
// ev3api.hを読み込むヘッダは.cppに記述する | ||
#include <signal.h> | ||
#include <unistd.h> | ||
|
||
class EtRobocon2024 { | ||
public: | ||
static void start(); | ||
|
||
private: | ||
/** | ||
* @brief ログファイルを生成して終了するシグナルハンドラ | ||
* @param _ キャッチしたシグナルの値がセットされる(ここでは使用しない) | ||
*/ | ||
static void sigint(int _); | ||
}; | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,21 @@ | ||
/** | ||
* @file EtRobocon2024Test.cpp | ||
* @brief EtRobocon2024クラスのテストケース | ||
* @author aridome222 | ||
*/ | ||
|
||
#include "../module/EtRobocon2024.h" // このヘッダファイルのcppファイルをテスト | ||
#include <gtest/gtest.h> | ||
|
||
namespace etrobocon2024_test { | ||
|
||
class EtRobocon2024Test : public ::testing::Test { | ||
friend class EtRobocon2024; | ||
|
||
protected: | ||
virtual void SetUp() {} | ||
EtRobocon2024 et; | ||
}; | ||
|
||
TEST_F(EtRobocon2024Test, startTest) {} | ||
} // namespace etrobocon2024_test |
This file contains 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,10 @@ | ||
/** | ||
* @file ev3api.h | ||
* @brief Cのヘッダファイルのインクルード(ダミー) | ||
* @author KakinokiKanta | ||
*/ | ||
#pragma once | ||
|
||
#include "ev3api_motor.h" | ||
#include "ev3api_button.h" | ||
#include "ev3api_voltage.h" |
This file contains 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,30 @@ | ||
/** | ||
* @file ev3api_button.cpp | ||
* @brief ボタン関連のダミー | ||
* @author KakinokiKanta | ||
*/ | ||
|
||
#include "ev3api_button.h" | ||
|
||
bool ev3_button_is_pressed(button_t button) | ||
{ | ||
// 左ボタン,右ボタン,中央ボタンがランダムに押される想定 | ||
int num = rand() % 3; | ||
|
||
// 左ボタンが押された時(num=0) | ||
if(button == LEFT_BUTTON && num == 0) return true; | ||
|
||
// 右ボタンが押された時(num=1) | ||
if(button == RIGHT_BUTTON && num == 1) return true; | ||
|
||
// 中央ボタンが押された時(num=2) | ||
if(button == ENTER_BUTTON && num == 2) return true; | ||
|
||
if(button != LEFT_BUTTON && button != RIGHT_BUTTON && button != ENTER_BUTTON) { | ||
printf("\x1b[31m"); // 前景色を赤に | ||
printf("error: Variable \"button\" is an unexpected value"); | ||
printf("\x1b[39m\n"); // 前景色をデフォルトに戻す | ||
} | ||
|
||
return false; | ||
} |
This file contains 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,28 @@ | ||
/** | ||
* @file ev3api_button.h | ||
* @brief ボタン関連のダミー | ||
* @author KakinokiKanta | ||
*/ | ||
|
||
#ifndef EV3API_BUTTON_H | ||
#define EV3API_BUTTON_H | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
/** | ||
* @brief ボタンを表す番号 | ||
*/ | ||
typedef enum { | ||
LEFT_BUTTON = 0, // 左ボタン | ||
RIGHT_BUTTON = 1, // 右ボタン | ||
UP_BUTTON = 2, // Spikeでは使えないけど一応 | ||
DOWN_BUTTON = 3, // Spikeでは使えないけど一応 | ||
ENTER_BUTTON = 4, // 中央ボタン | ||
BACK_BUTTON = 5, // Spikeでは使えないけど一応 | ||
TNUM_BUTTON = 6 // Spikeでは使えないけど一応 | ||
} button_t; | ||
|
||
bool ev3_button_is_pressed(button_t button); | ||
|
||
#endif |
This file contains 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,28 @@ | ||
/** | ||
* @file ev3api_motor.h | ||
* @brief モータ関連の列挙体(ダミー) | ||
* @author KakinokiKanta | ||
*/ | ||
#pragma once | ||
|
||
/** | ||
* @brief モータポートを表す番号 | ||
*/ | ||
typedef enum { | ||
EV3_PORT_A = 0, //ポートA | ||
EV3_PORT_B = 1, //ポートB | ||
EV3_PORT_C = 2, //ポートC | ||
EV3_PORT_D = 3, //ポートD | ||
TNUM_MOTOR_PORT = 4 //モータポートの数 | ||
} motor_port_t; | ||
|
||
/** | ||
* @brief サポートするモータタイプ | ||
*/ | ||
typedef enum { | ||
NONE_MOTOR = 0, //モータ未接続 | ||
MEDIUM_MOTOR, //サーボモータM | ||
LARGE_MOTOR, //サーボモータL | ||
UNREGULATED_MOTOR, //未調整モータ | ||
TNUM_MOTOR_TYPE //モータタイプの数 | ||
} motor_type_t; |
This file contains 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,18 @@ | ||
/** | ||
* @file ev3api_voltage.cpp | ||
* @brief 電圧取得関数のダミー | ||
* @author KakinokiKanta | ||
*/ | ||
|
||
#include "ev3api_voltage.h" | ||
|
||
int ev3_battery_voltage_mV() | ||
{ | ||
int index = rand() % 2; | ||
switch(index) { | ||
case 0: | ||
return 7300; // SPIKEの電圧の標準値[mV] | ||
case 1: | ||
return 4196; // SPIKEの電圧の最大値の半分[mV] | ||
} | ||
} |
This file contains 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,18 @@ | ||
/** | ||
* @file ev3api_voltage.h | ||
* @brief 電圧取得関数のダミー | ||
* @author KakinokiKanta | ||
*/ | ||
|
||
#ifndef EV3API_VOLTAGE_H | ||
#define EV3API_VOLTAGE_H | ||
|
||
#include <stdlib.h> | ||
|
||
/** | ||
* @brief SPIKEの電圧を取得 | ||
* @return SPIKEの電圧[mV] | ||
*/ | ||
int ev3_battery_voltage_mV(); | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.