|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#4
|
|||
|
|||
|
I'm having a little trouble figuring out where your confused, so I'm going to make two seperate explanations:
a) To get a tolerence of 5% (as in you example setpoint +- 5.0) you would pass in a tolerence of 5.0; the math converts the percentage as a value from 0 to 100 to a value of 1.00 to 0.00, and uses that for the computation. The percentage is literally a percentage value, 100 = 100%, 1.0 = 1%. It's exactly the opposite of what I expected it would be (especially in an engineering setting like this); also, to make matters worse, theres an extra unnecessary floating point division to taking place in the OnTarget function (this division should take place in the set tolerence function instead, but oh well)... b) The reason OnTarget uses the Min/Max input is fairly good actually (I actually thought at first it worked the other way, and it added a lot of complexity to this scenario) If you consider a turret, which autotargets the hoop and uses a gyro to determine it's rotation, you will frequently changing the setpoint to the angle you need to turn; however you need to be within 1deg of the hoop... If the tolerence were based on the setpoint, a 10% tolerence and a setpoint of 10deg, your target would be 10deg +-1deg, for a setpoint of 20deg, your tolerence would be 20deg+-2deg. So, in that scenario, if you wanted a 1 deg error, you would have to compute the % error based on the setpoint you chose each time it changed. Conclusion: The whole thing would be much simpler (and function the same) if tolerence simply took in a float for the acceptable error value rather than percentage. (ex SetTolerence(1.0); //Tolerence of 1 degree). Also, a word of caution... On target will return true if (m_error == 0), so you have to be sure the calculate function has run at least once after each enable before you make any action based on OnTarget(). |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|