Almost a complete waste of time
-
I've spent the last couple of days working on some physics simulation for a car but I was having problems with stability, the car would kind of slide away very slowly and handling was, to put it lightly 'poor' The problem I found, was to do with the removal of angular velocity from the wheels (excluding the velocity around the axle). The code in question was this:
if(lambda1 > EPSILON)
{
//remove velocity around axis
}
if(lambda2 > EPSILON)
{
//remove velocity around axis
}Where lambda1 and lambda2 are the velocities around the two axis we don't want movement around, and checking against epsilon to avoid diving by zero. Shockingly I missed 50% of the cases where the velocities could be negative :doh: Two days I've spent wondering why the thing kept sliding off, two bloody days.
if(FAbs(lambda1) > EPSILON)
{
//remove velocity around axis
}
if(FAbs(lambda2) > EPSILON)
{
//remove velocity around axis
}Still, it's not all bad. In my quest to find the problem I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect. Now all that's left to do is tidy up the huge mess of code I've made.
My current favourite word is: Smooth!
-SK Genius
-
I've spent the last couple of days working on some physics simulation for a car but I was having problems with stability, the car would kind of slide away very slowly and handling was, to put it lightly 'poor' The problem I found, was to do with the removal of angular velocity from the wheels (excluding the velocity around the axle). The code in question was this:
if(lambda1 > EPSILON)
{
//remove velocity around axis
}
if(lambda2 > EPSILON)
{
//remove velocity around axis
}Where lambda1 and lambda2 are the velocities around the two axis we don't want movement around, and checking against epsilon to avoid diving by zero. Shockingly I missed 50% of the cases where the velocities could be negative :doh: Two days I've spent wondering why the thing kept sliding off, two bloody days.
if(FAbs(lambda1) > EPSILON)
{
//remove velocity around axis
}
if(FAbs(lambda2) > EPSILON)
{
//remove velocity around axis
}Still, it's not all bad. In my quest to find the problem I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect. Now all that's left to do is tidy up the huge mess of code I've made.
My current favourite word is: Smooth!
-SK Genius
Maybe that is one reason why when testing always pick the upper and lower bounds for the data type in question, helps quickly find things like this! I was on a Factory Acceptance Test for a oil platform controls and shutdown system a few years back, the lead engineer on the project thought i was taking the pi$$ when i asked him to start pumping in random extreme values. Comments like, 'Operator would do that would they?', and they got back comments like 'Wouldn't they?[in a sarcastic tone]' and 'What about typo errors when entering values under pressure?'
Dave Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.com -
I've spent the last couple of days working on some physics simulation for a car but I was having problems with stability, the car would kind of slide away very slowly and handling was, to put it lightly 'poor' The problem I found, was to do with the removal of angular velocity from the wheels (excluding the velocity around the axle). The code in question was this:
if(lambda1 > EPSILON)
{
//remove velocity around axis
}
if(lambda2 > EPSILON)
{
//remove velocity around axis
}Where lambda1 and lambda2 are the velocities around the two axis we don't want movement around, and checking against epsilon to avoid diving by zero. Shockingly I missed 50% of the cases where the velocities could be negative :doh: Two days I've spent wondering why the thing kept sliding off, two bloody days.
if(FAbs(lambda1) > EPSILON)
{
//remove velocity around axis
}
if(FAbs(lambda2) > EPSILON)
{
//remove velocity around axis
}Still, it's not all bad. In my quest to find the problem I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect. Now all that's left to do is tidy up the huge mess of code I've made.
My current favourite word is: Smooth!
-SK Genius
I spotted that one in a second :laugh: (but I have a trained eye in this field). Why not remove velocity if smaller or equal to epsilon? Does it make sense if a value other than zero remains?
Wout
-
I spotted that one in a second :laugh: (but I have a trained eye in this field). Why not remove velocity if smaller or equal to epsilon? Does it make sense if a value other than zero remains?
Wout
Well it's easy for you to spot it here, there isn't any other code to distract you! It's a royal PITA to find the causes of problems in this thing, you can see the problem on the screen but finding what is actually causing it is an entirely different matter. Still, it was because I was dividing by the values shortly after and you know what happens when you divide by zero. I actually trimmed back a lot of the code that was there, and as it happens I don't even need those checks any more. ;P
My current favourite word is: Smooth!
-SK Genius
-
Maybe that is one reason why when testing always pick the upper and lower bounds for the data type in question, helps quickly find things like this! I was on a Factory Acceptance Test for a oil platform controls and shutdown system a few years back, the lead engineer on the project thought i was taking the pi$$ when i asked him to start pumping in random extreme values. Comments like, 'Operator would do that would they?', and they got back comments like 'Wouldn't they?[in a sarcastic tone]' and 'What about typo errors when entering values under pressure?'
Dave Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.comdaveauld wrote:
Maybe that is one reason why when testing always pick the upper and lower bounds for the data type in question, helps quickly find things like this!
That's why when we write data oriented tests, we write Boundary Value test cases first (known as Boundary Value Analysis in testing).
Regards,
Manoj Kumar
Blog:ManojKumar.me | Twitter:TheManojKumar | Facebook:TheManojKumar
"No me, no life; Know me, know life." -
I've spent the last couple of days working on some physics simulation for a car but I was having problems with stability, the car would kind of slide away very slowly and handling was, to put it lightly 'poor' The problem I found, was to do with the removal of angular velocity from the wheels (excluding the velocity around the axle). The code in question was this:
if(lambda1 > EPSILON)
{
//remove velocity around axis
}
if(lambda2 > EPSILON)
{
//remove velocity around axis
}Where lambda1 and lambda2 are the velocities around the two axis we don't want movement around, and checking against epsilon to avoid diving by zero. Shockingly I missed 50% of the cases where the velocities could be negative :doh: Two days I've spent wondering why the thing kept sliding off, two bloody days.
if(FAbs(lambda1) > EPSILON)
{
//remove velocity around axis
}
if(FAbs(lambda2) > EPSILON)
{
//remove velocity around axis
}Still, it's not all bad. In my quest to find the problem I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect. Now all that's left to do is tidy up the huge mess of code I've made.
My current favourite word is: Smooth!
-SK Genius
SK Genius wrote:
I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect
You mean: is a little stiff at first, with a bad rattle at the driver's rear wheel you can never find, then gradually the front shocks fade leaving the front end crazy floaty while the entire rear end sags like a granny's wotsit? I'll admit, I may have had a different experience with rebuilding suspension than you...
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
Maybe that is one reason why when testing always pick the upper and lower bounds for the data type in question, helps quickly find things like this! I was on a Factory Acceptance Test for a oil platform controls and shutdown system a few years back, the lead engineer on the project thought i was taking the pi$$ when i asked him to start pumping in random extreme values. Comments like, 'Operator would do that would they?', and they got back comments like 'Wouldn't they?[in a sarcastic tone]' and 'What about typo errors when entering values under pressure?'
Dave Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.comdaveauld wrote:
I was on a Factory Acceptance Test for a oil platform controls and shutdown system a few years back, the lead engineer on the project thought i was taking the pi$$ when i asked him to start pumping in random extreme values. Comments like, 'Operator would do that would they?', and they got back comments like 'Wouldn't they?[in a sarcastic tone]' and 'What about typo errors when entering values under pressure?'
Umm, this wouldn't have been a contract for BP, would it?
He said, "Boy I'm just old and lonely, But thank you for your concern, Here's wishing you a Happy New Year." I wished him one back in return.
-
I've spent the last couple of days working on some physics simulation for a car but I was having problems with stability, the car would kind of slide away very slowly and handling was, to put it lightly 'poor' The problem I found, was to do with the removal of angular velocity from the wheels (excluding the velocity around the axle). The code in question was this:
if(lambda1 > EPSILON)
{
//remove velocity around axis
}
if(lambda2 > EPSILON)
{
//remove velocity around axis
}Where lambda1 and lambda2 are the velocities around the two axis we don't want movement around, and checking against epsilon to avoid diving by zero. Shockingly I missed 50% of the cases where the velocities could be negative :doh: Two days I've spent wondering why the thing kept sliding off, two bloody days.
if(FAbs(lambda1) > EPSILON)
{
//remove velocity around axis
}
if(FAbs(lambda2) > EPSILON)
{
//remove velocity around axis
}Still, it's not all bad. In my quest to find the problem I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect. Now all that's left to do is tidy up the huge mess of code I've made.
My current favourite word is: Smooth!
-SK Genius