diff --git a/src/drivers/pid_driver/155-DTM.rgb b/src/drivers/pid_driver/155-DTM.rgb new file mode 100644 index 0000000..a670020 Binary files /dev/null and b/src/drivers/pid_driver/155-DTM.rgb differ diff --git a/src/drivers/pid_driver/Makefile b/src/drivers/pid_driver/Makefile new file mode 100644 index 0000000..6787298 --- /dev/null +++ b/src/drivers/pid_driver/Makefile @@ -0,0 +1,33 @@ +############################################################################## +# +# file : Makefile +# created : Sat Nov 4 20:28:35 CET 2017 +# copyright : (C) 2002 Jonas Natzer +# +############################################################################## +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +############################################################################## + +# I need those environment variables +# export TORCS_BASE=~/torcs-1.3.7 +# export MAKE_DEFAULT=${TORCS_BASE}/Make-default.mk + +ROBOT = pid_driver +MODULE = ${ROBOT}.so +MODULEDIR = drivers/${ROBOT} +SOURCES = ${ROBOT}.cpp + +SHIPDIR = drivers/${ROBOT} +SHIP = ${ROBOT}.xml 155-DTM.rgb logo.rgb +SHIPSUBDIRS = + +PKGSUBDIRS = ${SHIPSUBDIRS} +src-robots-pid_driver_PKGFILES = $(shell find * -maxdepth 0 -type f -print) +src-robots-pid_driver_PKGDIR = ${PACKAGE}-${VERSION}/$(subst ${TORCS_BASE},,$(shell pwd)) + +include ${MAKE_DEFAULT} diff --git a/src/drivers/pid_driver/logo.rgb b/src/drivers/pid_driver/logo.rgb new file mode 100644 index 0000000..036f1e2 Binary files /dev/null and b/src/drivers/pid_driver/logo.rgb differ diff --git a/src/drivers/pid_driver/pid_driver.cpp b/src/drivers/pid_driver/pid_driver.cpp new file mode 100644 index 0000000..15f327c --- /dev/null +++ b/src/drivers/pid_driver/pid_driver.cpp @@ -0,0 +1,124 @@ +/*************************************************************************** + + file : pid_driver.cpp + created : Sat Nov 4 20:28:35 CET 2017 + copyright : (C) 2002 Jonas Natzer + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifdef _WIN32 +#include +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +static tTrack *curTrack; + +static void initTrack(int index, tTrack* track, void *carHandle, void **carParmHandle, tSituation *s); +static void newrace(int index, tCarElt* car, tSituation *s); +static void drive(int index, tCarElt* car, tSituation *s); +static void endrace(int index, tCarElt *car, tSituation *s); +static void shutdown(int index); +static int InitFuncPt(int index, void *pt); + + +/* + * Module entry point + */ +extern "C" int +pid_driver(tModInfo *modInfo) +{ + memset(modInfo, 0, 10*sizeof(tModInfo)); + + modInfo->name = strdup("pid_driver"); /* name of the module (short) */ + modInfo->desc = strdup(""); /* description of the module (can be long) */ + modInfo->fctInit = InitFuncPt; /* init function */ + modInfo->gfId = ROB_IDENT; /* supported framework version */ + modInfo->index = 1; + + return 0; +} + +/* Module interface initialization. */ +static int +InitFuncPt(int index, void *pt) +{ + tRobotItf *itf = (tRobotItf *)pt; + + itf->rbNewTrack = initTrack; /* Give the robot the track view called */ + /* for every track change or new race */ + itf->rbNewRace = newrace; /* Start a new race */ + itf->rbDrive = drive; /* Drive during race */ + itf->rbPitCmd = NULL; + itf->rbEndRace = endrace; /* End of the current race */ + itf->rbShutdown = shutdown; /* Called before the module is unloaded */ + itf->index = index; /* Index used if multiple interfaces */ + return 0; +} + +/* Called for every track change or new race. */ +static void +initTrack(int index, tTrack* track, void *carHandle, void **carParmHandle, tSituation *s) +{ + curTrack = track; + *carParmHandle = NULL; +} + +/* Start a new race. */ +static void +newrace(int index, tCarElt* car, tSituation *s) +{ +} + +/* Drive during race. */ +static void +drive(int index, tCarElt* car, tSituation *s) +{ + memset((void *)&car->ctrl, 0, sizeof(tCarCtrl)); + car->ctrl.brakeCmd = 1.0; /* all brakes on ... */ + + float angle; + const float SC = 1.0; + + angle = RtTrackSideTgAngleL(&(car->_trkPos)) - car->_yaw; + NORM_PI_PI(angle); // put the angle back in the range from -PI to PI + angle -= SC*car->_trkPos.toMiddle/car->_trkPos.seg->width; + + // set up the values to return + car->ctrl.steer = angle / car->_steerLock; + car->ctrl.gear = 1; // first gear + car->ctrl.accelCmd = 0.3; // 30% accelerator pedal + car->ctrl.brakeCmd = 0.0; // no brakes +} + +/* End of the current race */ +static void +endrace(int index, tCarElt *car, tSituation *s) +{ +} + +/* Called before the module is unloaded */ +static void +shutdown(int index) +{ +} + diff --git a/src/drivers/pid_driver/pid_driver.def b/src/drivers/pid_driver/pid_driver.def new file mode 100644 index 0000000..f0ffcfc --- /dev/null +++ b/src/drivers/pid_driver/pid_driver.def @@ -0,0 +1,19 @@ +; +; file : pid_driver.def +; created : Sat Nov 4 20:28:35 CET 2017 +; copyright : (C) 2002 Jonas Natzer +; +; +; This program is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation; either version 2 of the License, or +; (at your option) any later version. +; + +LIBRARY pid_driver + +SECTIONS .data READ WRITE + +EXPORTS + pid_driver + diff --git a/src/drivers/pid_driver/pid_driver.dsp b/src/drivers/pid_driver/pid_driver.dsp new file mode 100644 index 0000000..fd624e6 --- /dev/null +++ b/src/drivers/pid_driver/pid_driver.dsp @@ -0,0 +1,238 @@ +# Microsoft Developer Studio Project File - Name="pid_driver" - Package Owner=<4> + +# Microsoft Developer Studio Generated Build File, Format Version 6.00 + +# ** DO NOT EDIT ** + + + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + + + +CFG=pid_driver - Win32 Debug + +!MESSAGE This is not a valid makefile. To build this project using NMAKE, + +!MESSAGE use the Export Makefile command and run + +!MESSAGE + +!MESSAGE NMAKE /f "pid_driver.mak". + +!MESSAGE + +!MESSAGE You can specify a configuration when running NMAKE + +!MESSAGE by defining the macro CFG on the command line. For example: + +!MESSAGE + +!MESSAGE NMAKE /f "pid_driver.mak" CFG="pid_driver - Win32 Debug" + +!MESSAGE + +!MESSAGE Possible choices for configuration are: + +!MESSAGE + +!MESSAGE "pid_driver - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") + +!MESSAGE "pid_driver - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") + +!MESSAGE + + + +# Begin Project + +# PROP AllowPerConfigDependencies 0 + +# PROP Scc_ProjName "" + +# PROP Scc_LocalPath "" + +CPP=cl.exe + +MTL=midl.exe + +RSC=rc.exe + + + +!IF "$(CFG)" == "pid_driver - Win32 Release" + + + +# PROP BASE Use_MFC 0 + +# PROP BASE Use_Debug_Libraries 0 + +# PROP BASE Output_Dir "Release" + +# PROP BASE Intermediate_Dir "Release" + +# PROP BASE Target_Dir "" + +# PROP Use_MFC 0 + +# PROP Use_Debug_Libraries 0 + +# PROP Output_Dir "Release" + +# PROP Intermediate_Dir "Release" + +# PROP Ignore_Export_Lib 1 + +# PROP Target_Dir "" + +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PID_DRIVER_EXPORTS" /YX /FD /c + +# ADD CPP /nologo /G5 /W3 /GX /O2 /I "../../../export/include" /I "../../windows/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PID_DRIVER_EXPORTS" /YX /FD /c + +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 + +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 + +# ADD BASE RSC /l 0x40c /d "NDEBUG" + +# ADD RSC /l 0x40c /d "NDEBUG" + +BSC32=bscmake.exe + +# ADD BASE BSC32 /nologo + +# ADD BSC32 /nologo + +LINK32=link.exe + +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 + +# ADD LINK32 tgf.lib robottools.lib sg.lib ul.lib /nologo /dll /map /machine:I386 /nodefaultlib:"LIBCD" /libpath:"../../../export/lib" /libpath:"../../windows/lib" + +# Begin Special Build Tool + +WkspDir=. + +TargetDir=.\Release + +SOURCE="$(InputPath)" + +PostBuild_Cmds=copy $(TargetDir)\*.dll $(WkspDir)\runtime\drivers\pid_driver + +# End Special Build Tool + + + +!ELSEIF "$(CFG)" == "pid_driver - Win32 Debug" + + + +# PROP BASE Use_MFC 0 + +# PROP BASE Use_Debug_Libraries 1 + +# PROP BASE Output_Dir "Debug" + +# PROP BASE Intermediate_Dir "Debug" + +# PROP BASE Target_Dir "" + +# PROP Use_MFC 0 + +# PROP Use_Debug_Libraries 1 + +# PROP Output_Dir "Debug" + +# PROP Intermediate_Dir "Debug" + +# PROP Ignore_Export_Lib 1 + +# PROP Target_Dir "" + +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PID_DRIVER_EXPORTS" /YX /FD /GZ /c + +# ADD CPP /nologo /G5 /W3 /Gm /GX /ZI /Od /I "../../../export/include" /I "../../windows/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PID_DRIVER_EXPORTS" /YX /FD /GZ /c + +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 + +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 + +# ADD BASE RSC /l 0x40c /d "_DEBUG" + +# ADD RSC /l 0x40c /d "_DEBUG" + +BSC32=bscmake.exe + +# ADD BASE BSC32 /nologo + +# ADD BSC32 /nologo + +LINK32=link.exe + +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept + +# ADD LINK32 robottools.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib sg.lib ul.lib /nologo /dll /map /debug /machine:I386 /pdbtype:sept /libpath:"../../../export/libd" /libpath:"../../windows/lib" + +# Begin Special Build Tool + +WkspDir=. + +TargetDir=.\Debug + +SOURCE="$(InputPath)" + +PostBuild_Cmds=copy $(TargetDir)\*.dll $(WkspDir)\runtimed\drivers\pid_driver + +# End Special Build Tool + + + +!ENDIF + + + +# Begin Target + + + +# Name "pid_driver - Win32 Release" + +# Name "pid_driver - Win32 Debug" + +# Begin Group "Source Files" + + + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" + +# Begin Source File + + + +SOURCE=.\pid_driver.cpp + +# End Source File + +# Begin Source File + + + +SOURCE=.\pid_driver.def + +# End Source File + +# End Group + +# Begin Group "Header Files" + + + +# PROP Default_Filter "h;hpp;hxx;hm;inl" + +# End Group + +# End Target + +# End Project + diff --git a/src/drivers/pid_driver/pid_driver.xml b/src/drivers/pid_driver/pid_driver.xml new file mode 100644 index 0000000..ab0739c --- /dev/null +++ b/src/drivers/pid_driver/pid_driver.xml @@ -0,0 +1,31 @@ + + + + + + + + + + +
+
+
+ + + + + + + + + + +
+
+
+