Skip to content

Commit

Permalink
Difference calculate by absolute track distance covered
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-heinrich committed Jan 8, 2018
1 parent efaa747 commit a5d6654
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/drivers/hemic/hemic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,27 +517,23 @@ drive(int index, tCarElt* car, tSituation *s)
{
float diffX = 0, diffY = 0;

if (false)
if (true)
{
tTrackSeg *currentSeg = car->pub.trkPos.seg;
tTrkLocPos opPos = (closestOponent->pub.trkPos);
float opX, opY;
float opX, opY, ownX, ownY;

RtTrackLocal2Global(&opPos, &opX, &opY, 1);
RtTrackGlobal2Local(currentSeg, opX, opY, &opPos, 1);
RtTrackLocal2Global(&car->pub.trkPos, &ownX, &ownY, 1);
//RtTrackGlobal2Local(currentSeg, opX, opY, &opPos, 1);

diffX = car->pub.trkPos.toLeft - opPos.toLeft;
diffY = car->pub.trkPos.toStart - opPos.toStart;

}
else
{
tTrkLocPos *opPos = &(closestOponent->pub.trkPos);

diffX = car->pub.trkPos.toLeft - opPos->toLeft;
diffY = car->pub.trkPos.toStart - opPos->toStart;
diffX = car->pub.trkPos.toLeft - opPos.toLeft;
diffY = RtGetDistFromStart(car) - RtGetDistFromStart(closestOponent);


writePositionLog(bot, diffX, diffY);
//diffX = car->pub.trkPos.toLeft - opPos.toLeft;
//diffY = car->pub.trkPos.toStart - opPos.toStart;

}


Expand Down Expand Up @@ -625,7 +621,7 @@ void openPositionLog(tBot *bot)
{
//bot->distanceLog = fopen("relative_distance.csv", "a");
std::cout << "Hemic relative position:\n";
std::cout << "xDistance, yDistance\n";
std::cout << "distanceX,distanceY\n";
}
}

Expand Down

0 comments on commit a5d6654

Please sign in to comment.