Re: Help Please For Linux

David Savinkoff <[email protected]> Sat, 6 Feb 2016 15:33:46 -0700 (MST)
Newsgroups gmane.games.torcs.general
Message-ID <1855922249.18685402.1454798026180.JavaMail.zimbra@mailid.telus.net>
----- David Kalyn wrote:
> Hello,
> 
> Am a new user of Linux and recently installed Linux Mint Cinnamon 17.2
> 64-bit.
> I know nothing of programing or writing code or Terminal computer
> language.
> I am a simple computer user trying to escape Windows.
> 
> Installed Torcs 1.3.3 from the Linux Package Manager games list. 
> Torcs seemed to install ok, graphics fine and seems everything worked
> except for the Logitech F310 gamepad which i'd like to use instead of
> the keyboard.
> The joystick axis 0-0 would not work - only the four buttons on the
> right side of the gamepad seem mappable.

Use the Mouse, it is better than a joystick.

> Have tried numerous times to re-install Torcs but no luck in getting
> the gamepad to work properly. Finally gave up and removed Torcs
> completely.
> 
> Next i tried to download and install Torcs 1.3.6 Tar.bz2 program from
> the web site directly.
> Managed to unzip and extract game folder OK and attempted to follow
> the instructions as per web site to install Torcs.
> That is to say, typed into the Terminal: cd torcs-1.3.6 but got a
> message saying that the file didn't exist. Tried putting the extracted
> folder into the usr/local/bin position, still no luck.
> Had a look inside the extracted Torcs folder and noticed all sorts of
> things for Windows32 and developer stuff, none of which i want or
> need. I simply want to try playing the racing game.
> 
> Sooo, the big question:
> Is there a basic Torcs version without all the programmer and Windows
> stuff for Linux Mint Cinnamon 17.2 that will actual work and is simple
> to install - basic, easy to follow, step-by-step instructions?
> 
> Have tried to read and follow numerous help documents but get lost and
> confused with all the code talk. Many articles also do not recommend
> installing programs from "tar balls" into Linux.
> I'm an old retired geezer and just can't understand all the computer
> programming lingo. My apologies for being old and stupid.
> 
> Regards,
> Kalyn
> 

****** To compile TORCS in Linux home directory for experimenting *****

1) Install C/C++ development software (some hints here):
https://help.ubuntu.com/community/InstallingCompilers

Use this command in a GUI Terminal window:

 sudo apt-get install build-essential

(or find a GUI method for installing 'build-essential' )

Note: I don't use Ubuntu or derivatives so I can't be specific.

2)
Create a directory called TORCS somewhere (home directory is good).
Put:
torcs-1.3.6.tar.bz2
and this enclosed patch for better traction physics:
wheel.cpp.2016jan14.diff
in this directory

3)
Extract torcs-1.3.6.tar.bz2 in this directory... if you highlight
torcs-1.3.6.tar.bz2 with your mouse, you may (I'm not Ubuntu sure)
be able to extract it.

Otherwise do the following in the terminal window opened in the
appropriate directory:
 tar -xjf torcs-1.3.6.tar.bz2
Then press enter to execute the command.

To get the benefit of the patch do:
 patch -p0 < wheel.cpp.2016jan14.diff

4)
If you are using the terminal (please use), type
 cd torcs-1.3.6
to enter the torcs tarball directory you extracted.

5)
Type the following (note **USER NAME HERE):

./configure --prefix="/home/**USER NAME HERE/opt/torcs" --x-libraries=/usr/lib/ CXXFLAGS="-march=native -mtune=native -O3 -pipe" LDFLAGS="-Wl,--no-add-needed,--strip-all"

6)
Type the following:
make && make install && make datainstall

7)
Go to this directory to execute TORCS:
/home/**USER NAME HERE/opt/torcs/bin/torcs 

8)
Set steer sensitivity: 0.55
Calibrate mouse (mouse is better than joystick)
Play


*****
The TORCS directory is not needed after TORCS is compiled,
you may delete some, none or all of it, OR you may experiment.

*****
The hidden .torcs directory in your home directory contains your
TORCS settings and preferences. Delete this if you want to
reset your preferences

*****
opt/torcs (in your home directory) contains the /torcs directory
with enclosed executables. Delete this to uninstall TORCS

*****

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140

_______________________________________________
Torcs-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/torcs-users
wheel.cpp.2016jan14.diff (text/x-patch, 4 KB)
--- torcs-1.3.6/src/modules/simu/simuv2/wheel.cpp	2013-08-29 06:01:32.000000000 -0700
+++ torcs-1.3.6/src/modules/simu/simuv2/wheel.cpp	2016-01-13 18:30:51.976507851 -0800
@@ -174,12 +174,12 @@
 {
 	tWheel *wheel = &(car->wheel[index]);
 	tdble axleFz = wheel->axleFz;
-	tdble vt, v, v2, wrl; // wheel related velocity
+	tdble vt, vn, v, v2, wrl, slip_magnitude; // wheel related velocity
 	tdble Fn, Ft;
 	tdble waz;
-	tdble CosA, SinA;
-	tdble s, sa, sx, sy; // slip vector
-	tdble stmp, F, Bx;
+	double CosA, SinA;
+	tdble s, sx, sy; // slip vector
+	tdble F, Bx;
 	tdble mu;
 	wheel->state = 0;
 
@@ -215,46 +215,39 @@
 
 	// tangent velocity.
 	vt = wheel->bodyVel.x * CosA + wheel->bodyVel.y * SinA;
+	vn = wheel->bodyVel.y * CosA - wheel->bodyVel.x * SinA;
 	v2 = wheel->bodyVel.x * wheel->bodyVel.x + wheel->bodyVel.y * wheel->bodyVel.y;
-	v = sqrt(v2);
-
-	// slip angle
-	if (v < 0.000001f) {
-		sa = 0.0f;
-	} else {
-		sa = atan2(wheel->bodyVel.y, wheel->bodyVel.x) - waz;
-	}
-	NORM_PI_PI(sa);
+	v = sqrtf(v2);
 
 	wrl = wheel->spinVel * wheel->radius;
+
 	if ((wheel->state & SIM_WH_ONAIR) != 0) {
 		sx = sy = 0.0f;
-	} else if (v < 0.000001f) {
-		sx = wrl;
-		sy = 0.0f;
 	} else {
-		sx = (vt - wrl) / fabs(vt);
-		sy = sin(sa);
+		// Normalize the friction circle to get normalized vector components (sx, sy) while
+		// braking (vt), accelerating (wrl), or wheel counter spin (vt - wrl) for any angle.
+		// Softening factor 0.3 added to slip_magnitude affects low velocities and divide by zero.
+		slip_magnitude = 0.3f + sqrt( MAX(MAX((v2), (vn*vn + wrl*wrl)), (vn*vn + (vt - wrl)*(vt - wrl))) );
+		sx = (vt - wrl) / slip_magnitude;
+		sy = vn / slip_magnitude;
 	}
 
-	Ft = 0.0f;
-	Fn = 0.0f;
-	s = sqrt(sx*sx+sy*sy);
+	s = sqrtf(sx*sx+sy*sy);
 
 	{
-		// calculate _skid and _reaction for sound.
-		if (v < 2.0f) {
+		// calculate _skid and _reaction for sound (importantly; affects traction also).
+		if ((v < 0.01f) || (zforce < 0.0002f)) {
 			car->carElt->_skid[index] = 0.0f;
 		} else {
-			car->carElt->_skid[index] =  MIN(1.0f, (s*zforce*0.0002f));
+			// skid energy :: F*d :: v*v :: s*s ... the empirical equation:
+			// n*(s*s + s) is represented in Damped Simple Harmonic Motion
+			car->carElt->_skid[index] = (s*s+s);
 		}
 	}
 
-	stmp = MIN(s, 1.5f);
-	
 	// MAGIC FORMULA
-	Bx = wheel->mfB * stmp;
-	F = sin(wheel->mfC * atan(Bx * (1.0f - wheel->mfE) + wheel->mfE * atan(Bx))) * (1.0f + stmp * simSkidFactor[car->carElt->_skillLevel]);
+	Bx = wheel->mfB * s;
+	F = sin(wheel->mfC * atan(Bx * (1.0f - wheel->mfE) + wheel->mfE * atan(Bx))) * (1.0f + s * simSkidFactor[car->carElt->_skillLevel]);
 
 	// load sensitivity
 	mu = wheel->mu * (wheel->lfMin + (wheel->lfMax - wheel->lfMin) * exp(wheel->lfK * zforce / wheel->opLoad));
@@ -264,29 +257,26 @@
 	wheel->rollRes = zforce * wheel->trkPos.seg->surface->kRollRes;
     car->carElt->priv.wheel[index].rollRes = wheel->rollRes;
 
-	if (s > 0.000001f) {
-		// wheel axis based
-		Ft -= F * sx / s;
-		Fn -= F * sy / s;
-	}
-
-	RELAXATION2(Fn, wheel->preFn, 50.0f);
-	RELAXATION2(Ft, wheel->preFt, 50.0f);
+	// wheel axis based
+	F = -F; // make F into a reaction force
+	s += 0.000001f; // stable divide by zero avoidance.
+	Ft = F * sx/s;
+	Fn = F * sy/s;
 
 	wheel->relPos.az = waz;
 
 	wheel->forces.x = Ft * CosA - Fn * SinA;
 	wheel->forces.y = Ft * SinA + Fn * CosA;
 	wheel->spinTq = Ft * wheel->radius;
-	wheel->sa = sa;
+	wheel->sa = asin(sy/s);
 	wheel->sx = sx;
 
 	wheel->feedBack.spinVel = wheel->spinVel;
 	wheel->feedBack.Tq = wheel->spinTq;
 	wheel->feedBack.brkTq = wheel->brake.Tq;
 
-	car->carElt->_wheelSlipSide(index) = sy*v;
-	car->carElt->_wheelSlipAccel(index) = sx*v;
+	car->carElt->_wheelSlipSide(index) = vn;
+	car->carElt->_wheelSlipAccel(index) = vt-wrl;
 	car->carElt->_reaction[index] = zforce;
 }
 
@@ -301,8 +291,6 @@
 		wheel = &(car->wheel[i]);
 		wheel->spinVel = wheel->in.spinVel;
 
-		RELAXATION2(wheel->spinVel, wheel->prespinVel, 50.0f);
-
 		wheel->relPos.ay += wheel->spinVel * SimDeltaTime;
 		NORM_PI_PI(wheel->relPos.ay);
 		car->carElt->_wheelSpinVel(i) = wheel->spinVel;