Notices

VBOX Setup - math channels

Thread Tools
 
Search this Thread
 
Old 09-09-2016, 03:30 PM
  #1  
boxer-11
Rennlist Member
Thread Starter
 
boxer-11's Avatar
 
Join Date: Sep 2013
Location: Olympia, WA
Posts: 451
Received 54 Likes on 37 Posts
Default VBOX Setup - math channels

In case this helps others I thought I'd post a few things that I have discovered about math channels. I need to acknowledge Bryan Cowles at Racelogic for patiently answering my questions about this topic.

First, while the user manual for VBOX Setup only lists the available operators and functions bu name there _is_ more help available in for the form of tooltips. Hover over the function you are interested in and that will appear.



I'm told that the available list of functions and operators comes from a standard library implementation that comes with Microsoft development tools. That's a pretty big clue as to how these work since it implies that C or C++ language semantics probably apply. And indeed if you look at the tooltips for operators like "&" and ">>" for example what it tells you is that these are bitwise operators, like you'd get in C.

I picked Heaviside() to hover in the above example because it's the one I wasn't sure of just by looking at it. Most of the others seem to do just what you'd expect if you are familiar with C/C++.

Perhaps less obvious is how the comparison operators should be used. These are things like "<" for "less than" and so on. Normally in C/C++ you'd use that with conditional flow "if" statements or loop controls. The VBOX Setup equation editor doesn't have such flow control at all though.

However, with a bit of algebra you can get the same effect.

Taking steering as an example. What the CAN bus signals deliver are StrWhlAngle (which is just the magnitude of turn from center) and StrWhlDirection (which tells you left or right...a little experimentation shows that "1" means left and "0" means right).

The key here is that the comparison operators result in a "0" value for any evaluation that is false and "1" for any evaluation that is true. Those result values can be plugged into any equation to affect the calculation of the final value a channel will take.

So for example, "(StrWheelDirection > 0)" will result in a "1" when turning left and "0" when turning right.

Multiply any value by 1 and the result is the original value unchanged.

Multiply any value by 0 and the result becomes zero.

In a normal programming if-then-else statement the two expressions are mutually exclusive -- only one is ever evaluated depending on the conditional expression. You can get the same effect in a math expression without if-then-else syntax by using two comparison sub-expressions that evaluate to one and zero in an exclusive fashion.

It's probably easiest to see this from an example:



In the above, what you end up with is a single value for steering angle that runs from negative max (left) to positive max (right) either side of zero as the datum for wheels straight ahead.

Using two mutually exclusive comparison expressions guarantees that only one side can evaluate to "1" while the other always evaluates to "0". That allows you to sum ("+" in the middle) the two sides and know that you either get a result that is -StrWhlAngle (left) or StrWhlAngle (right).

I've seen scene files that have left and right as separate channels. That works fine although it makes you use two elements to show steering if you are using those to populate on your video overlay. The nice part about building a single math expression for this is that if you happen to be channel limited, this approach can save you a channel.
Old 09-09-2016, 09:27 PM
  #2  
ProCoach
Rennlist
Basic Site Sponsor
 
ProCoach's Avatar
 
Join Date: Jun 2008
Location: Durham, NC and Virginia International Raceway
Posts: 19,097
Received 3,270 Likes on 1,865 Posts
Default

__________________
-Peter Krause
www.peterkrause.net
www.gofasternow.com
"Combining the Art and Science of Driving Fast!"
Specializing in Professional, Private Driver Performance Evaluation and Optimization
Consultation Available Remotely and at VIRginia International Raceway






















Old 09-09-2016, 10:07 PM
  #3  
Slakker
Race Car
 
Slakker's Avatar
 
Join Date: Dec 2013
Location: Edmond, OK
Posts: 4,775
Received 270 Likes on 124 Posts
Default

Great info! Thanks for sharing.



Quick Reply: VBOX Setup - math channels



All times are GMT -3. The time now is 08:17 PM.