Behavior
Script
Only set a value other than 0 when the behavior needs to be run regardless of input changes. Consider that the step_time can be changed during runtime so it can change value for a period of time or under some circumstances and then be reset again, like in the example below.
step_time = 0.01 if velocity != 0.0 else 0.0
Note
Variable names need to be valid python identifiers! Use names that easily relate to the elements they are connected to, for example replacing “.” by ‘“_”. I.e. X1_voltage to refer X1.voltage
Double check the variables with the attribute public=”true”, reserved to parametrize the behavior or provide significant output information.
Do not use behavior variables for internal logic variables (cleanup debugging variables), declare them internally in the script. Any variable that is not either connected to an element, or needs to be public, can be defined internally.
Use the helper methods to work with Euler angles and quaternions:
# Convert from quaternion to Euler
output_origin = [0.0, 0.0, 0.024, 0.7071, 0.0, 0.0, 0.7071]
[x, y, z, R, P, Y] = Transform2Euler(output_origin)
# Modify the angles
P = -numpy.pi/2 + numpy.pi * aperture
# Convert back to quaternion and update output
output_origin = Transform2Quat([x, y, z, R, P, Y])