Authoring Expression Triggers

Revision as of 16:43, 24 February 2017 by Anna Dizack (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

ISAT User's Guide Table of Contents

◄PREVIOUS NEXT►

Authoring Expression Triggers

NADs scenario control, and by extension ISAT, uses a recursive descent parser for supporting a simple expression language. The two main uses for the expression parser are for the expression trigger, and the time to arrival trigger. The expression trigger fires (predicate is true) whenever the expression evaluates to a value greater than 0; The Time To Arrival trigger uses the expression parser to calculate an arrival time. This is required in instances where the timing constraints for an event are too complex to use a static value for a time to arrival.

Syntax Overview

The NADS expression syntax uses a simple infix notation (i.e. a+b,not a b +). Currently the parser does have some short comings, such as it is not possible to embed one function call inside another so cos(sin(x) ), would not be legal

Operators

These operators can be used to make expressions, which will cause the desired object to perform actions, such as accelerate at a certain rate or maintain a varying distance form another object.

String

‘ ; ‘some string’

Grouping

( ); (a)

Multiplication

  •  ; a * b

Division

/ ; a/b

Addition

+ ; a + b

Subtraction

- ; a - b

Note: ISAT expression parser does not handle negation, so in order to express a

TOP Value such as -5, a subtraction operation must be used. So negative 5 can be expressed as: (0-5)

Greater than

>; a > b

Less than

<; a 3

Function: CellEquals

Name -description CellEquals – Cell Equals Synopsis CellEquals(string name, int index, float value)

Description

The Cell Equals function is similar to the ReadCell function, except it takes in an additional value to compare the cell value to. Like ReadCell, name specifies the name of the cell, index specifies the index into the array (use 0 for single value cells).

Available Cells:

  • LogStreams : Array of 5 floats. Logstreams are a set of values the scenario author can write to through “write to logstream” actions.
  • AccelPedalPos : Single Value. The current position of the accelerator pedal
  • CruiseControl: Single Value. The current cruise control position. (values are cab/platform specific)
  • TurnSignal: Single Value. The current position of the turn signal (values are cab/platform specific)

Return Value 1 if the cell value is equal to the passed in value, otherwise 0.

TOP

Function: GetObjVel

Name -description GetObjVel – Get Object Velocity

Synopsis GetObjVel(string name)

Description The GetObjVel gets the velocity in meters per second of the first dynamic object with the name specified by the ‘name’ argument.

Return Value The speed in meters per second of the specified dynamic object, if no object is found 0 is returned

Example GetObjVel(‘PullOutVeh’) > 15.4


TOP

Function: GetObjYtcToOv

Name -description

GetObjTtcToOv –Get Object Time To Collision to Own Vehicle

Synopsis GetObjTtcToOv(string name)

Description GetObjTtcToOv, gets the time to collision from the dynamic object specified by the name parameter, to the own vehicle. 0 is returned if no object can be found

Return Value Time to collision from the dynamic object specified by the name parameter, in seconds to the own vehicle. 0 is returned if no object can be found


TOP

Function: GetObjDistPow2

Name -description GetObjDistPow2 – Get Object Distance Squared

Synopsis GetObjDistPow2(string name)

Description GetObjDistPow2 returns the distance squared between the participant and the dynamic object specified by the ‘name’ parameter. The distance is in feet as measured from the eye position of the driver to the centroid of the dynamic object. Distance squared is used to having to perform an expensive square root calculation every frame. If the specified object cannot be found a value larger than 100 million is returned.

Return GetObjDistPow2 returns the distance squared between the participant and a specified dynamic object in feet. If the specified object cannot be found a value larger than 100 million is returned

Example GetObjDistPow2(‘OncomeCar1’)<2500

TOP

Forced Velocity expr Option

The expr option of the forced velocity dial, set the forced velocity based on a expression. The is useful when trying to create a following event in which the lead vehicle has what would seem to the participant a random speed but would be easily described by a relatively simple equation.

The forced velocity dial has its own syntax, that which is described elsewhere. In the example below, expr denotes the dial is a expression forced velocity, “-1” denotes the length of time is infinite for the expression, and the “%” signs denote the beginning and end of the expression.

expr -1 % 60.0 + ( (3.7 * sin( 50 ) ) + ( 1.85 * sin( 11 ) ) ) %

The expression parser used to parse the expression portion of the forced velocity action is the same as used in the expression trigger, except functions are different. The functions used for the forced velocity are for signal generation. The operators function the same as with the expression trigger.

TOP

Function: sin

Name -description

sin –sine

Synopsis

sin(float period)

sin(float period, float phase_offset)

Description

The sin function a value base of the following equation:

sin( (timeSinceStart + phase_offset )* 3.141592654 * 1/period )

Where timesSinceStart is the time since the forced velocity action became active in seconds. If the phase_offset is not passed in the value is assumed to be 0.

Return Value The sin function returns a value between -1 and 1.

TOP

Function: FadeIn

Name -description FadeIn –Fade In

Synopsis FadeIn(float period)

FadeIn(float period, float offset)

Description The FadeIn function is a simple ramp function that goes from 0 to 1 in a linear manner in the time given by period. When the time since the dial became active exceeds the passed in value period (time is seconds), FadeIn will return 0. The offset parameter sets a delay in seconds of when to begin the slope.

Return Value The FadeIn function returns a value between 0 and 1.


TOP

Function: FadeOut

Name -description FadeIn –Fade Out

Synopsis'

FadeOut(float period)

FadeOut(float period, float offset)

Description

The FadeOut function is a simple ramp function that goes from 1 to 0 in a linear manner in the time given by period. This function is the opposite of the FadeIn function. When the time since the dial became active exceeds the passed in value period (time is seconds), FadeOut will return 1. The offset parameter sets a delay in seconds of when to begin the slope.

Return Value

The FadeOut function returns a value between 0 and 1.

TOP

◄PREVIOUS NEXT►