You can see some of the bots driving in this and this YouTube video.
The directory contains a Vagrantfile which is the build script, and a package.box which is the virtual machine image. Vagrant combines these to create and launch an up-to-date virtual machine and launches it in Virtual Box.
- Make sure you install the required software above
- Clone the repo:
git clone https://github.com/UWEcoCAR/UW-Infotainment.git - Download the
package.box(large file) here. Save it in this repo. - You may also want the torcs source code here
cdto this repo- Install the box:
vagrant box add simulator package.box - Run
vagrant up(this will install the latest packages for the dev environment). Vagrant will now start Virtual Box, SSH in and automatically install packages. Hopefully everything updates installs correctly. - The
package.boxfile can now be deleted - The VM is permanently in the Virtual Box's default directory
- Run
vagrant upin the repo directory to open the vm vagrant reloadcan reload a running vm- the
--provisionargument will rerun the install scripts in the above commands - To stop the vm run
vagrant halt - to ssh into vm from your os type
vagrant ssh
- Update Vm:
git pullthis repo for the latestVagrantfile - Run
vagrant up --provisionin theVagrantfiledirectory
- Uninstall Vm:
vagrant destroyin theVM/directory. You will loose you virtual machine, but can reinstall fresh.
- Torcs torcs-1.3.6 source code
- Hardware accelerated OpenGL (usually provided by your Linux distribution)
- GLUT 3.7 or FreeGlut (better than GLUT for full screen support)
- PLIB 1.8.5 version
- OpenAL
- libpng and zlib (usually provided by your Linux distribution)
- FreeALUT
cdinto thetorcs-1.3.6- Configure with by running
./configure - make with
sudo make - install with
sudo make install - add extras with
sudo make datainstall
- Simply type
torcsin a command window - Note, there are command line options to set default settings
- Note that due to my print tweak explained below, in game info is printed to the console
In torcs-1.3.6/src you can tweak the game. Below is a list of files that may be of interest
-
In
/driversyou can edit the different bots. Thehumandriver is useful for changing behavior when a human is playing (using arrow keys)-
I have added a
printfline inhuman.cppso that parameters such as speed, rpm, gear and fuel are printed -
this is the print statement I added :
printf("Speed : %0.2f \tYaw : %0.2f\tRPM : %0.2f\tGear : %d\tFuel : %0.2f\n", 3.6*car->_speed_x,yaw_rel, car->_enginerpm, car->_gear, car->_fuel);
-
-
In
/interfaces/car.hyou can see what a car class is made up of. It has things such ascar->_enginerpmwhich will tell you the RPM of the of the car.
The server allows you to make custom bots to autonomously drive a level. We have a python wrapper for this server that defines simple driver and car control classes to tweak the bots
The server is already included in torcs in this repo, but it can be installed or uninstalled with the patch in the torcs-1.3.6/scr-patch directory.
- source code is in
/python_svr - Run the server by typing
python pyclient.pyin the/python_svrdirectory - The server will wait for a race to start
- the race must have
scr_server_1as a player for the default pyclient to work - Once the race starts, the
scr_server_1should drive on its own
Notes:
- Essentially the
driver.pywill steer to stay in the middle of the road, and increase speed until themax_speedlimit is reached. Once it is reached, the bot will oscillate around this speed. - The steering algorithm is
steer = (angle - dist)/self.steer_lockwhere angle is the cars angle, dist is distance from ideal path and steer_lock is a constant to prevent over steering. - The gear shift algorithm is also in the
driver.py
- Start the python server client by typing
python pyclient.pyin the/python_svrdirectory - Start the game with
torcs - In torcs, start a race and make sure
scr_server_1is a player - The python server should connect and in game information should be printed to console