Thread Rating:
• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
Reinstate maximum steering angle (PATCH)
06-26-2009, 05:54 AM,
 fudje Member Posts: 87 Threads: 6 Joined: Dec 2007
Reinstate maximum steering angle (PATCH)
This has been missing for the entire "refactor" - and is really annoying (to me at least. Should be to others too).
To reproduce, just drive any car on any track. All cars currently steer to 45Â°, which is both useless and unrealistic.

Patch to fix is very small. I've tried to keep this to the current coding style (header seem to have a lot of implementation code in them - what's with that? It could be driving up compilation times, btw):

Code:
```Index: include/cardynamics.h =================================================================== --- include/cardynamics.h    (revision 2505) +++ include/cardynamics.h    (working copy) @@ -196,7 +196,8 @@     std::vector <CARBRAKE <T> > brake;     std::vector <CARTIRE <T> > tire;     std::vector <CARAERO <T> > aerodynamics; -     +    T maxangle; +     //set at load time     std::list <std::pair <T, MATHVECTOR <T> > > mass_only_particles;     enum @@ -1416,9 +1417,6 @@     ///set the steering angle to "value", where 1.0 is maximum right lock and -1.0 is maximum left lock.     void SetSteering(const T value)     { -        //TODO: load in max steering angle -        T maxangle = 45.0; -                 T steerangle = value * maxangle; //steering angle in degrees                  //ackermann stuff @@ -1448,13 +1446,18 @@         wheel[FRONT_RIGHT].SetSteerAngle(right_wheel_angle);     }      -    //TODO: load in max steering angle     ///Get the maximum steering angle in degrees     T GetMaxSteeringAngle() const     { -        return 45.0; +        return maxangle;     }      +    ///Set the mavimum steering angle in degrees +    void SetMaxSteeringAngle(const T value){ +      maxangle = value; +    } + +         ///get the worldspace engine position     MATHVECTOR <T> GetEnginePosition()     { Index: src/car.cpp =================================================================== --- src/car.cpp    (revision 2505) +++ src/car.cpp    (working copy) @@ -1068,6 +1068,15 @@         }     } +    //load the max steering angle +    { +        float maxangle = 45.0; +        if (!GetConfigfileParam(error_output, c, "steering.max-angle", maxangle)) +            return false; +         +        dynamics.SetMaxSteeringAngle(maxangle); +    } +     //load the driver     {         float mass;```

Compiled and Tested on Ubuntu Karmic with gcc 4.4.0 - The bits I've added should compile on any C++ compiler ever made though

Cheers,
fudje
06-26-2009, 11:40 PM,
 joevenzon Administrator Posts: 2,678 Threads: 52 Joined: Jun 2005
Re: Reinstate maximum steering angle (PATCH)
fudje Wrote:I've tried to keep this to the current coding style (header seem to have a lot of implementation code in them - what's with that? It could be driving up compilation times, btw)

The cardynamics.h file defines a templated CARDYNAMICS class. The only reason I made it a template was so I could easily switch between floats and doubles as the primary "real" type, but this would have been much better served with a typedef instead of a template (woops, poor design on my part). As a result the implementation of the class is in the header since that's the easiest way to do template classes. Of course, there are fairly simple ways to separate out the implementation and header with template functions, and even better I could just refactor to use a typedef, but I haven't bothered yet. If you're interested in doing this let me know and I'll set you up with SVN access (the patch looks good and I'm applying it now).
06-27-2009, 12:13 AM,
 joevenzon Administrator Posts: 2,678 Threads: 52 Joined: Jun 2005

OK, your patch is in R2506. Thanks!
06-27-2009, 01:46 AM,
 fudje Member Posts: 87 Threads: 6 Joined: Dec 2007

Ah, of course, the templating.
I don't really understand C++ templates enough to do anything much about it at this point (though I fear I am going to have to learn) - mostly what I know is they're much more hackish than in, say, Java or C#.

You're very welcome to have the patch. Thanks for applying to SVN

Forum Jump:

Users browsing this thread: 1 Guest(s)