@@ -810,6 +810,7 @@ int main(int argc, char** argv)
810810 if (pathRange < minPathRange) pathRange = minPathRange;
811811 float relativeGoalDis = adjacentRange;
812812
813+ int preSelectedGroupID = -1 ;
813814 if (autonomyMode) {
814815 float relativeGoalX = ((goalX - vehicleX) * cosVehicleYaw + (goalY - vehicleY) * sinVehicleYaw);
815816 float relativeGoalY = (-(goalX - vehicleX) * sinVehicleYaw + (goalY - vehicleY) * cosVehicleYaw);
@@ -854,8 +855,13 @@ int main(int argc, char** argv)
854855 }
855856
856857 if (!twoWayDrive) {
857- if (joyDir > 95.0 ) joyDir = 95.0 ;
858- else if (joyDir < -95.0 ) joyDir = -95.0 ;
858+ if (joyDir > 95.0 ) {
859+ joyDir = 95.0 ;
860+ preSelectedGroupID = 0 ;
861+ } else if (joyDir < -95.0 ) {
862+ joyDir = -95.0 ;
863+ preSelectedGroupID = 6 ;
864+ }
859865 }
860866 }
861867 } else {
@@ -981,17 +987,21 @@ int main(int argc, char** argv)
981987 }
982988 }
983989
984- float maxScore = 0 ;
985990 int selectedGroupID = -1 ;
986- for (int i = 0 ; i < 36 * groupNum; i++) {
987- int rotDir = int (i / groupNum);
988- float rotAng = (10.0 * rotDir - 180.0 ) * PI / 180 ;
989- float rotDeg = 10.0 * rotDir;
990- if (rotDeg > 180.0 ) rotDeg -= 360.0 ;
991- if (maxScore < clearPathPerGroupScore[i] && ((rotAng * 180.0 / PI > minObsAngCW && rotAng * 180.0 / PI < minObsAngCCW) ||
992- (rotDeg > minObsAngCW && rotDeg < minObsAngCCW && twoWayDrive) || !checkRotObstacle)) {
993- maxScore = clearPathPerGroupScore[i];
994- selectedGroupID = i;
991+ if (preSelectedGroupID >= 0 ) {
992+ selectedGroupID = preSelectedGroupID;
993+ } else {
994+ float maxScore = 0 ;
995+ for (int i = 0 ; i < 36 * groupNum; i++) {
996+ int rotDir = int (i / groupNum);
997+ float rotAng = (10.0 * rotDir - 180.0 ) * PI / 180 ;
998+ float rotDeg = 10.0 * rotDir;
999+ if (rotDeg > 180.0 ) rotDeg -= 360.0 ;
1000+ if (maxScore < clearPathPerGroupScore[i] && ((rotAng * 180.0 / PI > minObsAngCW && rotAng * 180.0 / PI < minObsAngCCW) ||
1001+ (rotDeg > minObsAngCW && rotDeg < minObsAngCCW && twoWayDrive) || !checkRotObstacle)) {
1002+ maxScore = clearPathPerGroupScore[i];
1003+ selectedGroupID = i;
1004+ }
9951005 }
9961006 }
9971007
0 commit comments