Skip to content

Commit 46a92bd

Browse files
committed
Merge branch 'work-KL25-143' into ticket-KL25-143
2 parents 4a94e16 + ddbd830 commit 46a92bd

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

datafiles/commands/SmartCarryLeft.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ DCL,800.0,400.0,200,0.002,0.0005,0.001,35,50,50,85,255,255,0,0,600,600,800,600
1111
IMUR,55,70.0,clockwise,0.036,0.012,0.03
1212
DCL,700.0,300.0,280,0.002,0.0005,0.001,0,0,0,179,255,30,0,0,600,600,800,600
1313
DCL,300.0,300.0,400,0.002,0.0005,0.001,0,0,0,179,255,30,300,0,500,600,800,600
14-
CDCL,BLUE,400.0,350.0,400,0.002,0.0005,0.001,100,50,50,130,255,255,0,0,700,600,800,600
14+
CDCL,BLUE,400.0,350.0,400,0.002,0.0005,0.001,100,50,50,130,255,255,0,0,700,600,800,600

modules/MotionParser.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ vector<Motion*> MotionParser::createMotions(Robot& robot, string& commandFilePat
476476
// 角度[deg] [9]:double 回転パワー [10-12]:double udclのPIDゲイン(kp, ki, kd), [13-18]:int
477477
// HSV値(lowerH,lowerS,lowerV,upperH,upperS,upperV), [19-22]:int ROI座標[px]
478478
// ([19]左上隅のx座標, [20]左上隅のy座標, [21]幅, [22]高さ), [23-24]int 解像度[px]
479-
// ([23]幅,[24]高さ) 補足:ROI(Region of Interest:
479+
// ([23]幅,[24]高さ), [25]:int PCIDS用ROI狭め値[px](オプション)
480+
// 補足:ROI(Region of Interest:
480481
// ライントレース用の画像内注目領域(四角形))
481482
case COMMAND::BTCA: {
482483
CameraServer::BoundingBoxDetectorRequest detectionRequest;
@@ -489,8 +490,15 @@ vector<Motion*> MotionParser::createMotions(Robot& robot, string& commandFilePat
489490
detectionRequest.upperHSV
490491
= cv::Scalar(stoi(params[16]), stoi(params[17]), stoi(params[18]));
491492

493+
int roiShrinkValue = 0; // ROI狭め値のデフォルト値
494+
492495
// パラメータ配列のサイズによってROIと解像度を設定
493-
if(params.size() > 24) {
496+
if(params.size() > 25) {
497+
detectionRequest.roi
498+
= cv::Rect(stoi(params[19]), stoi(params[20]), stoi(params[21]), stoi(params[22]));
499+
detectionRequest.resolution = cv::Size(stoi(params[23]), stoi(params[24]));
500+
roiShrinkValue = stoi(params[25]);
501+
} else if(params.size() > 24) {
494502
detectionRequest.roi
495503
= cv::Rect(stoi(params[19]), stoi(params[20]), stoi(params[21]), stoi(params[22]));
496504
detectionRequest.resolution = cv::Size(stoi(params[23]), stoi(params[24]));
@@ -507,7 +515,8 @@ vector<Motion*> MotionParser::createMotions(Robot& robot, string& commandFilePat
507515
robot, stod(params[1]), stod(params[2]),
508516
PidGain(stod(params[3]), stod(params[4]), stod(params[5])), stod(params[6]),
509517
stod(params[7]), stod(params[8]), stod(params[9]),
510-
PidGain(stod(params[10]), stod(params[11]), stod(params[12])), detectionRequest);
518+
PidGain(stod(params[10]), stod(params[11]), stod(params[12])), detectionRequest,
519+
roiShrinkValue);
511520
motionList.push_back(btca);
512521
break;
513522
}

modules/motions/BottleTwoCatchAction.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
BottleTwoCatchAction::BottleTwoCatchAction(
1111
Robot& _robot, double _forwardDistance, double _idsSpeed, const PidGain& _idsPidGain,
1212
double _ultrasonicDistance, double _udclSpeed, double _angle, double _rotatePower,
13-
const PidGain& _udclPidGain, const CameraServer::BoundingBoxDetectorRequest& _detectionRequest)
13+
const PidGain& _udclPidGain, const CameraServer::BoundingBoxDetectorRequest& _detectionRequest,
14+
int _roiShrinkValue)
1415
: CompositeMotion(_robot),
1516
forwardDistance(_forwardDistance),
1617
idsSpeed(_idsSpeed),
@@ -20,7 +21,8 @@ BottleTwoCatchAction::BottleTwoCatchAction(
2021
angle(_angle),
2122
rotatePower(_rotatePower),
2223
udclPidGain(_udclPidGain),
23-
detectionRequest(_detectionRequest)
24+
detectionRequest(_detectionRequest),
25+
roiShrinkValue(_roiShrinkValue)
2426
{
2527
}
2628

@@ -31,9 +33,16 @@ void BottleTwoCatchAction::run()
3133
double initialLeftMotorCount = robot.getMotorControllerInstance().getLeftMotorCount();
3234
double initialDistance = Mileage::calculateMileage(initialRightMotorCount, initialLeftMotorCount);
3335

36+
// PCIDS用にROIを狭める
37+
CameraServer::BoundingBoxDetectorRequest pcidsDetectionRequest = detectionRequest;
38+
pcidsDetectionRequest.roi.x += roiShrinkValue;
39+
pcidsDetectionRequest.roi.y += roiShrinkValue;
40+
pcidsDetectionRequest.roi.width -= roiShrinkValue * 2;
41+
pcidsDetectionRequest.roi.height -= roiShrinkValue * 2;
42+
3443
// PCIDSを動かす。ボトル探索。
3544
PictureColorDistanceStraight pcids(robot, forwardDistance, idsSpeed, idsPidGain,
36-
detectionRequest);
45+
pcidsDetectionRequest);
3746
pcids.run();
3847

3948
UltrasonicDistanceCameraLineTrace udcl(robot, ultrasonicDistance, forwardDistance, udclSpeed, 400,

modules/motions/BottleTwoCatchAction.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ class BottleTwoCatchAction : public CompositeMotion {
3030
* @param _rotatePower 回頭パワー
3131
* @param _udclPidGain udclのPIDゲイン
3232
* @param _detectionRequest 検出リクエスト
33+
* @param _roiShrinkValue PCIDS用のROIを狭める値[px] (デフォルト: 0)
3334
*/
3435
BottleTwoCatchAction(Robot& _robot, double _forwardDistance, double _idsSpeed,
3536
const PidGain& _idsPidGain, double _ultrasonicDistance, double _udclSpeed,
3637
double _angle, double _rotatePower, const PidGain& _udclPidGain,
37-
const CameraServer::BoundingBoxDetectorRequest& _detectionRequest);
38+
const CameraServer::BoundingBoxDetectorRequest& _detectionRequest,
39+
int _roiShrinkValue = 0);
3840

3941
/**
4042
* @brief 2本目のボトルのキャッチ動作を行う
@@ -51,6 +53,7 @@ class BottleTwoCatchAction : public CompositeMotion {
5153
double angle; // 回頭角度[度]
5254
double rotatePower; // 回頭パワー
5355
PidGain udclPidGain; // udclのPIDゲイン
56+
int roiShrinkValue; // PCIDS用のROIを狭める値[px]
5457
};
5558

5659
#endif

0 commit comments

Comments
 (0)