Resources
Installing
Run the ./configure
and follow up on what’s missing.
Here are the things I installed (sudo apt-get install ...
).
libplib1 libplib-dev libopenal1 libopenal-dev libopenal-data
libalut0 libalut-dev libvorbisfile3 libogg-dev
libvorbis-dev libvorbis-dbg libvorbisenc2 libvorbis0a
libxi-dev libxi6-dbg libxi6
libxmu6 libxmu-dev libxmu6-dbg libxmu-headers
libxxf86vm1 libxxf86vm1-dbg libxxf86vm-dev
libxrender1 libxrender1-dbg libxrender-dev
libxrandr-dev libxrandr2 libxrandr2-dbg
libpng3 libpng\++-dev libpng12-dev
Here’s what I recently had to do on a Debian system.
alias apti='sudo apt-get install '
apti freeglut3 freeglut3-dev
apti g++
apti libalut0 libalut-dev
apti vorbis-tools
apti libvorbis-dev
apti libvorbis0a libvorbisenc2 libvorbisfile3
apti libxi6 libxi-dev
apti libxmu6 libxmu-dev
apti libxxf86vm1 libxxf86vm-dev
apti libxrender1 libxrender-dev
apti libxrandr-dev libxrandr2
Also check out this troubleshooting help.
Installing Elsewhere
It’s quite maze of directories and where they all go is pretty hard to keep track of. I wanted to install Torcs in my local directory as a non root user. Seems reasonable right?
I made some progress by doing this when building Torcs:
./configure --prefix=/home/xed/testy/torcs
Installing SCR Patch
-
First download the TORCS source.
-
Run the
configure
as described above. -
Download the patch from a place like this.
-
Unpack the tar file in the main directory of the TORCS source. There should be a
scr-patch
directory in the same level asdata
,doc
,src
,test
, etc. -
Change to
scr-patch
directory. -
sh ./do_patch.sh
Note that this produces patching error confusion. I answered "Y" (yes) to all questions and the results seemed ok. -
Go back to the main torcs directory (
cd ..
). -
make && make install && make datainstall
2015-05-11 - Just asked the new organizer if they want to use 1.3.4 as was used in 2013 or if they prefer 1.3.6 which is available now. The former has some patch warnings and the later does not compile with the patch at all.
Controls
I find the controls in TORCS to be somewhat confusing. The help screen really only scratches the surface. I’ve tried to figure out the rest by trial and error, but I know I haven’t figured it all out. The trickiest thing is that many keys cycle through several modes of functionality.
F1
-
Help
Cameras
F2
-
Follow Car Closely
-
Follow Car A Car Length Back
-
Windshield View (with mirror)
-
Front Bumper View (with mirror)
F3
-
Follow Car Far
-
Follow Car Very Far
-
Follow Car A Car Length Back Wheel Height
-
Rear Bumper View From A Car That Is Being Followed (backwards)
F4
-
Follow Car With Camera Compass Fixed
F5
-
Police Helicopter
-
Unbotrusive Helicopter
-
Quiet Helicopter
-
Blimp
F6
-
Left Side Noisy Helicopter
F7
-
Jet Plane
-
Jet Plane From Next County SW
-
Jet Plane From Next County NW
-
Jet Plane From Next County NE
-
Jet Plane From Next County SE
F8
-
Fixed Camera Positions Not Zoomed
F9
-
Fixed Camera Positions With Zoom Horizon Pan
F10
-
Low Police Chase Helicopter
F11
-
Camera Points With Long Zoom (director? maybe follows different cars depending on how interesting they are?)
F12
-
Screenshot. This is unlisted on F1 help in sim, but not in help at menus. It creates a screenshot in the sim.
On Screen Information Display
0
Arcade Data Display
1
-
Position/Competitors
-
Fuel
-
Damage
-
Laps/Total
-
Time
-
Lap Time
-
Best Lap
-
Top Speed
-
Position/Competitors
-
Fuel
-
Laps/Total
-
Best Lap
-
Time
2
-
(Tach, Speed), (Fuel, Damage)
-
(Tach, Speed)
3 (lower left)
-
Leaders
-
Laps/Total
-
Leaders
4
-
G-force/Command Graph
5
-
Frames Per Second
m
-
Map - full fixed
-
Map - zoomed car fixed
-
Map - zoomed car oriented
Note there are also map modes with and without other competitors shown. In a single player TT this is why it takes two presses to change the map.
View
-
[
= Split Screen -
]
= Un-Split Screen -
<
= Zoom Out -
>
= Zoom In -
*
= Zoom Default (Is it really *? Or something else?)
Time
-
p
= Pause Race -
.
= Real Time -
+
= Speed Up Time -
-
= Slow Down Time
Details
-
PgUp/PgDn
= Select Next/Previous Car To Focus On (also up and down arrow) -
c
= Movie capture -
F12 =
-
space
= Skip Pre Start -
esc
= Stop Race
Running
TORCS (maybe only the patched version?) can be run from the command line in a non-graphical mode. This seems pretty much limited to testing a bot for how quickly it can get around a particular course. It’s not easy to work with and the data returned is pretty weak. I tried to set up a 1km race, but it did the first full lap after 1km instead. It was easier to just have my client abort after passing distRaced greater than 1000.
To run TORCS in a text only mode from the command line, use -r
.
It is necessary to specify the XML configuration file for your setup
with:
$ torcs -r ${FULLPATH}/customconfig.xml
It’s also possible to
To set things up how they need to be set up, you need to create this configuration file. Start with a copy of:
~/.torcs/config/raceman/quickrace.xml
Then edit this. The following are some things that are useful to customize.
Track selection:
params:Quick Race -> section:Tracks -> section:1
<attstr name="name" val="${TRACKNAME}"/>
<!-- Where TRACKNAME is one of the following:
dirt-1, dirt-2, dirt-3, dirt-4, dirt-5, dirt-6, mixed-1, mixed-2 -->
<attstr name="category" val="dirt"/>
<attstr name="name" val="${TRACKNAME}"/>
<!-- Where TRACKNAME is one of the following:
a-speedway, b-speedway, c-speedway, d-speedway,
e-speedway, e-track-5, f-speedway, g-speedway, michigan -->
<attstr name="category" val="oval"/>
<attstr name="name" val="${TRACKNAME}"/>
<!-- Where TRACKNAME is one of the following:
aalborg, alpine-1, alpine-2, brondehach, corkscrew,
e-track-1, e-track-2, e-track-3, e-track-4, e-track-6,
eroad, forza, g-track-1, g-track-2, g-track-3, ole-road-1,
ruudskogen, spring, street-1, wheel-1, wheel-2 -->
<attstr name="category" val="road"/>
Next you need to select the drivers. These come from:
/usr/local/share/games/torcs/drivers
To select the ones you want to compete in your race, you must edit the correct section of the xml file.
Driver selection:
params:Quick Race -> section:Drivers -> section:${N}
<!-- Where N is driver number. "1" for solo. -->
<attnum name="idx" val="${INDEX}"/>
<attstr name="module" val="${DRIVERNAME}"/>
<!-- Where INDEX is driver number minus one. "0" for solo. -->
<!-- Where DRIVERNAME is driver identification, e.g. "scr_server". -->
The other thing you can set is the length of the race and the results display (though I didn’t notice any different effect).
params:Quick Race
<attnum name="distance" unit="km" val="0"/>
<attnum name="laps" val="2"/>
<!-- Set distance _or_ laps to 0 to use the other. -->
<attstr name="display mode" val="${MODE}"/>
<!-- MODE can be "normal" or "results only" -->
Tracks
The SCR guys have made a program that will autogenerate a novel track. This could be useful for testing bots in the SCR. The trackgen website is here.
I had some trouble getting these tracks to work. Instead it just seemed to kill my version of TORCs and I had to reinstall. :-(
Here’s a video that went very quickly over the part that was important.
UPDATE: I just got it working. Seems that you need to untar the package into this directory:
/usr/local/share/games/torcs/tracks/road
Don’t bother trying to put it into the source distribution and using
the make datainstall
target. That does not work. But just copying
the directory into the tracks/road
directory did.
FAQ
Is there drafting? The source code suggests yes.
See torcs-1.3.4/src/modules/simu/simuv3/aero.cpp
How is damage assessed? I couldn’t tell for sure, but you can find it
in torcs-1.3.4/src/modules/simu/simuv3/collision.cpp
. Looks like the
harder you hit, the more damage, prolonged contact is prolonged
damage. I couldn’t tell if there were sensitive spots on the car, but
there could be. There is a lot of chatter in the code about esoteric
damages to things like the aerodynamics or wheel rotation, etc. That
said, the collision model is a box.
Do I need to use the clutch? From
torcs-1.3.4/src/modules/simu/simuv3/transmission.cpp
:
// If user does not engage clutch, we do it automatically.
SCR - Simulated Car Racing
Contest
-
Noisy sensors will be used. They are off by default. To turn them on use
torcs -noisy
. -
There are some other command line options that can help with an SCR entry. These are
-nodamage
,-nofuel
, and-nolaptime
. This prevents ending a long simulation prematurely due to one of the problems implied by the options. -
Make sure the controller responds within 10ms real time of the sensor update.
-
Use a specific configuration file to host a server which races immediately from the command line:
torcs -r ~/.torcs/config/raceman/quickrace.xml
The config file can be created by the GUI and edited by hand (in theory).
Car
The Competition
-
To run some poor wretch’s horrifying Java mess use this kind of template:
java scr.Client scr.SimpleDriver host:${H} port:${P} id:SCR \ maxEpisodes:${ME} maxSteps:100000 verbose:${V} track:${T} stage:${S}
-
To run a C client:
$ ./client host:${H} port:${P} id:SCR maxEpisodes:${ME} \ maxSteps:100000 track:${T} stage:${S}
-
The stages are:
-
0 = Warm-Up
-
1 = Qualifying
-
2 = Race
-
3 = Unknown (default)
-
-
The
maxEpisodes
is apparently "learning episodes". The default is one and I don’t know what exactly it does. -
I have no idea what the
verbose:
option takes.
Torcs' Bots
The car is the car1-trb1
. Other TORCS bot competitors using the same
car are:
-
tita 3
-
berniw 3
-
lliaw 3
-
olethros 3
-
inferno 3
-
bt 3
Paint Job
I admit that I like playing with the car’s look. If I’m going to be looking at the thing for hours on end getting it working, it better be something I’m happy to look at. Also I find it very helpful to have different paint colors with numbers on them (#3001, #3002, etc) to tell which car is being controlled by which bot.
To modify the cars use the gimp to edit one of the xcf files of this car’s skin. Export to .rgb (default compression) and put in some place like:
/usr/local/share/games/torcs/drivers/scr_server/0/car1-trb1.rgb
One way to try to do that is to put the file in the source tree:
~/torcs-1.3.4/src/drivers/scr_server/0/car1-trb1.rgb
And do a make datainstall
in ~/torcs-1.3.4
. I’ve found that this
doesn’t necessarily work though if the install files are already
present. Probably just easier to copy the desired rgb files to the
target places like the one mentioned.
Sensors
The first column shows the what the server sends in the authentic format including a possible value (these were scooped out of a session).
(angle -1.45539) |
Angle between car and track axis (PI>a>-PI) |
(curLapTime 445.006) |
Seconds since current lap began. |
(damage 7102) |
Damage points. High is bad. |
(distFromStart 3107.23) |
Distance from start line along track in meters. |
(distRaced -491.421) |
|
(fuel 89.2216) |
liters of fuel, uncertain about effect - randomizer? |
(gear -1) |
Current gear. -1=reverse, 0=neutral, 1-6 |
(lastLapTime 0) |
Seconds it took to do last lap. Usually 0 for most updates. |
(opponents 200 …<36 readings>… 200) |
Every 10deg from -180 to 180, dist to nearest opponent. |
(racePos 1) |
Current place in race. |
(rpm 9508.01) |
Current engine speed. |
(speedX -75.2286) |
longitudinal (good) velocity km/h |
(speedY 26.6088) |
lateral (drift) velocity km/h |
(speedZ 0.384483) |
vertical (bumpiness) velocity km/h |
(track -1 …<19 readings> -1) |
Sensors on front half of car every 10deg, dist to edge of track, -1 if off the track |
(trackPos -2.61437) |
% off center of track. >=1 or ⇐-1 mean car is off track. |
(wheelSpinVel -66.4836 -68.8404 -83.6928 -129.728) |
4 wheels speed in rad/s |
(z 0.354934) |
height in m of C.o.G. from track, i.e. jumping |
(focus 5.93827 6.03127 6.12912 6.23214 6.34063) |
Adjustable range finder sensors, -1 when off. |
Are distFromStart
and distRaced
measured by actual car travel or
position closest to center of (or perpendicular to) track where car
is?
The difference between track
and focus
seems subtle. The focus
direction can be set anytime while the track
sensors must be decided
upon before the race. focus
only fire once every second while
track
seem pretty constant.
Note
|
The manual says that the track sensors are every 10 degrees but the client program I used initialized with the following values: |
-90 -75 -60 -45 -30 -20 -15 -10 -5 0 5 10 15 20 30 45 60 75 90
Effectors
(accel 1) |
0=none, 1=full throttle |
(brake 0) |
0=none, 1=full brake |
(gear 1) |
{-1..6} set the gear |
(steer -1.89513) |
-1=full right, 1=full left… WTF is -1.89513? |
(clutch 0) |
0=none, 1=full clutch |
(focus 0) |
The middle of the 5deg fan of focus sensors. -90,90 |
(meta 0) |
0=nothing, 1=ask server to restart the race |