Skip to content

Commit

Permalink
update: モータカウントのオーバーフローを回避するためにリセットを実装
Browse files Browse the repository at this point in the history
  • Loading branch information
miyashita64 committed Oct 18, 2023
1 parent ccd071c commit df337a8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions module/API/Measurer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,31 @@ int Measurer::getLeftCount()
return leftMotor->getCount();
}

// 左モータ角位置更新
void Measurer::setLeftCount(int count)
{
leftMotor->setCount(count);
}

// 右モータ角位置取得
int Measurer::getRightCount()
{
return rightMotor->getCount();
}

// 右モータ角位置更新
void Measurer::setRightCount(int count)
{
rightMotor->setCount(count);
}

// モータ角位置の初期化
void Measurer::resetCount()
{
Measurer::setLeftCount(0);
Measurer::setRightCount(0);
}

// アームモータ角位置取得
int Measurer::getArmMotorCount()
{
Expand Down
17 changes: 17 additions & 0 deletions module/API/Measurer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,29 @@ class Measurer {
*/
static int getLeftCount();

/**
* 左モータ角位置を更新
* @param 左モータ角位置[deg]
*/
static void setLeftCount(int count);

/**
* 右モータ角位置を取得
* @return 右モータ角位置[deg]
*/
static int getRightCount();

/**
* 右モータ角位置を更新
* @param 右モータ角位置[deg]
*/
static void setRightCount(int count);

/**
* モータ角位置を初期化
*/
static void resetCount();

/**
* アームモータ角位置を取得
* @return アームモータ角位置[deg]
Expand Down
1 change: 1 addition & 0 deletions module/AreaMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void AreaMaster::run()

// 各動作を実行する
for(const auto& motion : motionList) {
Measurer::resetCount();
motion->logRunning();
motion->run();
}
Expand Down
1 change: 1 addition & 0 deletions module/AreaMaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <string.h>
#include "MotionParser.h"
#include "Logger.h"
#include "Measurer.h"

// エリア名を持つ列挙型変数(LineTrace = 0, DoubleLoop = 1, BlockDeTreasure = 2)
enum Area { LineTrace, DoubleLoop, BlockDeTreasure };
Expand Down

0 comments on commit df337a8

Please sign in to comment.