Skip to content

Commit

Permalink
update gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingJonas committed Jan 8, 2018
2 parents d153d2c + 707d257 commit 52d5946
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 61 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@
# Jonas added that
*.depend
*-bin
export/*
.torcs.rc
src/libs/txml/gennmtab/gennmtab
2 changes: 1 addition & 1 deletion Make-config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
##############################################################################

SHELL = /bin/sh
SHELL = /bin/bash

srcdir = .
top_srcdir = ${TORCS_BASE}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/torcsdoc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ FULL_PATH_NAMES = YES
# relative paths, which will be relative from the directory where doxygen is
# started.

STRIP_FROM_PATH = /home/jonas/torcs-1.3.7/
STRIP_FROM_PATH = /home/michaelheinrich/github/torcs-1.3.7/

# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
# the path mentioned in the documentation of a class, which tells
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##############################################################################
#
# file : Makefile
# created : Do 2. Nov 08:49:38 CET 2017
# created : Mo 8. Jan 00:39:15 CET 2018
# copyright : (C) 2002 Jonas Natzer, Michael Heinrich
#
##############################################################################
Expand All @@ -13,17 +13,17 @@
#
##############################################################################

ROBOT = test_bot
ROBOT = hemic
MODULE = ${ROBOT}.so
MODULEDIR = drivers/${ROBOT}
SOURCES = ${ROBOT}.cpp optimal_line.cpp Trajectory.cpp TrackData.cpp
SOURCES = ${ROBOT}.cpp TrackData.cpp Trajectory.cpp optimal_line.cpp

SHIPDIR = drivers/${ROBOT}
SHIP = ${ROBOT}.xml 155-DTM.rgb logo.rgb
SHIPSUBDIRS =

PKGSUBDIRS = ${SHIPSUBDIRS}
src-robots-test_bot_PKGFILES = $(shell find * -maxdepth 0 -type f -print)
src-robots-test_bot_PKGDIR = ${PACKAGE}-${VERSION}/$(subst ${TORCS_BASE},,$(shell pwd))
src-robots-hemic_PKGFILES = $(shell find * -maxdepth 0 -type f -print)
src-robots-hemic_PKGDIR = ${PACKAGE}-${VERSION}/$(subst ${TORCS_BASE},,$(shell pwd))

include ${MAKE_DEFAULT}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#endif


#include "test_bot.h"
#include "hemic.h"


static void initTrack(int index, tTrack* track, void *carHandle, void **carParmHandle, tSituation *s);
Expand All @@ -32,11 +32,16 @@ static int InitFuncPt(int index, void *pt);

static tBot bots[NBBOTS];


void openPositionLog(tBot *bot);
void writePositionLog(tBot *bot, float x, float y);
void closePositionLog(tBot *bot);

/*
* Module entry point
*/
extern "C" int
test_bot(tModInfo *modInfo)
hemic(tModInfo *modInfo)
{
memset(modInfo, 0, NBBOTS * sizeof (tModInfo));

Expand Down Expand Up @@ -101,7 +106,7 @@ initTrack(int index, tTrack* track, void *carHandle, void **carParmHandle, tSitu
static void
newrace(int index, tCarElt* car, tSituation *s)
{
std::cout << "test_bot.cpp: Version 0.07\n";
std::cout << "hemic.cpp: Version 0.08\n";


if (index < 1 || index > NBBOTS)
Expand All @@ -119,6 +124,8 @@ newrace(int index, tCarElt* car, tSituation *s)
bot->hasLaunched = false;
bot->slipDist = 0;
bot->throttlingI = THROTTLING_I_INIT;

openPositionLog(bot);
}

/* Drive during race. */
Expand All @@ -141,7 +148,7 @@ drive(int index, tCarElt* car, tSituation *s)
const float SC = 1.0;

tCarElt *closestOponent = 0x00;
float closestOpDist = 100;
float closestOpDist = 1e9f;
int ncars = s->raceInfo.ncars;

tdble cX, cY, oX, oY;
Expand Down Expand Up @@ -450,6 +457,8 @@ drive(int index, tCarElt* car, tSituation *s)
//std::ofstream logfile;
//logfile.open ("~/test_bot.log", std::ofstream::out | std::ofstream::app);

/*
std::cout << std::showpos << std::setprecision(3) << std::fixed
<< "off=" << std::setw(3) << offset
<< std::noshowpos
Expand All @@ -467,6 +476,7 @@ drive(int index, tCarElt* car, tSituation *s)
//<< ", friction=" << car->_trkPos.seg->surface->kFriction
<< "\n";
*/

bot->lastManeuver = maneuver;

Expand All @@ -491,8 +501,8 @@ drive(int index, tCarElt* car, tSituation *s)
othCt = c->race.curTime;
othBL = c->race.timeBehindLeader;
}
if(ownCt == 0)

if (ownCt == 0)
{
bot->otherTime = othCt;
bot->ownTime = othCt + car->race.timeBehindLeader;
Expand All @@ -502,7 +512,40 @@ drive(int index, tCarElt* car, tSituation *s)
bot->ownTime = ownCt;
bot->otherTime = ownCt + othBL;
}


if (closestOponent != NULL)
{
float diffX = 0, diffY = 0;

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

RtTrackLocal2Global(&opPos, &opX, &opY, 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;

writePositionLog(bot, diffX, diffY);
}



}



//logfile.close();
}

Expand Down Expand Up @@ -567,11 +610,47 @@ shutdown(int index)
fprintf(
f,
"%f, %f\n",
bots[0].ownTime, bots[0].otherTime
bots[index].ownTime, bots[index].otherTime
);

fclose(f);


closePositionLog(bots + index - 1);
}

void openPositionLog(tBot *bot)
{
if (bot->distanceLog == NULL)
{
//bot->distanceLog = fopen("relative_distance.csv", "a");
std::cout << "Hemic relative position:\n";
std::cout << "xDistance, yDistance\n";
}
}

void writePositionLog(tBot *bot, float x, float y)
{
if (bot->distanceLog != NULL)
{
fprintf(
bot->distanceLog,
"%f, %f\n",
x, y
);
}
else
{
std::cout << x << ", " << y << "\n";
}
}

void closePositionLog(tBot *bot)
{
if (bot->distanceLog != NULL)
{
fclose(bot->distanceLog);
bot->distanceLog = NULL;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;
; file : test_bot.def
; created : Do 2. Nov 08:49:38 CET 2017
; file : hemic.def
; created : Mo 8. Jan 00:39:15 CET 2018
; copyright : (C) 2002 Jonas Natzer, Michael Heinrich
;
;
Expand All @@ -10,10 +10,10 @@
; (at your option) any later version.
;

LIBRARY test_bot
LIBRARY hemic

SECTIONS .data READ WRITE

EXPORTS
test_bot
hemic

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 52d5946

Please sign in to comment.