Robot Instructions:

1. StartLogging() - start recording to Model log
2. LogScriptFilename() - log script file name in log (usually first thing after StartLogging)
3. StopLogging() - stop recording to Model log
4. StartAccelerometer(...) - start accelerometer(s) polling or interrupt
5. StopAccelerometer(...) - stop accelerometer(s) polling or interrupt
6. StartTouchSensor(...) - start touch sensor(s) polling or interrupt
7. StopTouchSensor(...) - stop touch sensor(s) polling or interrupt
8. TurnMotor(MotorName,Strength,Duration)  Turn a motor with a strength (use - for counter clockwise), for Duration (in ms) 
9. MotorAccel(
StartTime,Motor0,InitialStrength,Timeout,(Motor1,InitialStrength,Timeout,)Accel0,XYorZ,TargetAngle,DegreeOffsetPlus,DegreeOffsetMinus,(Accel1,XYorZ,TargetAngle,DegreeOffsetPlus,DegreeOffsetMinus,)FLAGS)
{Note that TargetAngle can be: CurrentAngle, CurrentAngle[VariableToCreate], an earlier defined variable name, CurrentAnglePlus (adds another parameter Offset indicating to use the current angle as the targetangle plus the offset given in the next parameter, then the DegOffPos and DegOffNeg follow as usual).}  
Note that at least a 2 degree target range (Angle,-1,1) is best to make sure the brake does not reach V=0 before reaching the target zone.
FLAGS:
ABORT_ANGLE0=#1 : Abort script if angle of accel0 is greater than #1
ABORT_ANGLE1=#1 : Abort script if angle of accel1 is greater than #1
ABORT_VELOCITY0=#1 : Abort script if velocity of angle associated with accel0 is greater than #1
ABORT_VELOCITY1=#1 : Abort script if velocity of angle associated with accel1 is greater than #1
ABORT_ON_TIMEOUT : Abort script if this instruciton timesout
WAIT_STAGE : instruction continues whether at target or not, until stage is complete
HOLD_ANGLE : instruction seeks to hold target angle (not just reach it),until timeout or end of stage,
HOLD_ANGLE=#1:#2: same as hold angle, but use ThrustVelocityRatio method of opposing motion ***when Velocity is moving away from target angle only*** (ex: HOLD_ANGLE=0.5:0.2 will, when the segment is moving away from target in positive direction, set Thrust=Velocity*0.5 in the direction towards target angle, when the segment is moving away from the target in a negative direction, set Thrust=Velocity*0.2 in the direction toward the target angle). Once segment is moving toward target, regular (incremental feedback) motion code takes over.
MAX_THRUST=#1 : user override of MaxThrust setting on motor-accel association
MAX_REVERSE_THRUST=#1 : user ovveride of MaxReverseThrust (thrust used to brake) on motor-accel assocation
CONSTANT_THRUST : apply a constant thrust to motor (avoid thrust analysis). Uses initial thrust strength as constant thrust strength.
DOUBLE_THRUST- used when two motors to make thrust half
MAINTAIN_THRUST - at the end of a stage Thrust=0, unless this flag is set, then whatever thrust the motor has is maintained (use with caution since motor may still be turning at the end of a stage). 
MAX_VELOCITY=#1: maximum velocity allowed for the body segments associated with both accelerometers 0 and 1
MAX_VELOCITY0=#1: maximum velocity allowed for the body segment associated with accelerometer 0
MAX_VELOCITY1=#1: maximum velocity allowed for the body segment associated with accelerometer 1
MIN_VELOCITY=#1: minumum velocity allowed for the body segments associated with both accelerometers 0 and 1
MIN_VELOCITY0=#1: minimum velocity allowed for the body segment associated with accelerometer 0
MIN_VELOCITY1=#1: minimum velocity allowed for the body segment associated with accelerometer 1
OPPOSE_MOTION - Skip thrust analysis, and simply use ThrustVelocityRatio (TVR) to set thrust in opposite direction as current motion. For example body segment moving with +10dps, and TVR=1.0 set Thrust=10 in opposite direction, if TVR=0.5 set Thrust=5, if TV=2.0 set opposing thrust to 20 (or MaxThrust, whichever is lower). THrust is set to 0 when body segment is not moving (IsMoving=0).
OPPOSE_MOTION_MAINTAIN - same as OPPOSE_MOTION above, but when body segment is not moving, Thrust is not set to 0, for OPPOSE_MOTION without _MAINTAIN, thrust is set to 0 (Thrust=0) when the body segment is not moving. Used to hold a robot segment with a thrust even when segment is not moving.
OPPOSE_MOTION=#1 - user override of TVR for both positive and negative directions (#1=TVR is the same for body segment motion in both posivei and negative directions)
OPPOSE_MOTION=#1:#2 - user override for positive (#1) and negative (#2) TVR  (Thrust=0 when IsMoving=0)
OPPOSE_MOTION_MAINTAIN=#1 - same as above but with thrust maintained (thrust not set to 0) when no motion
OPPOSE_MOTION_MAINTAIN=#1:#1 - same as above but both positive and negative TVR are specified
FUTURE_LOG - record thrust analysis decisions in future log
NO_STOP_ON_TARGET - ignore code that seeks to stop on the target when the target angle is 1000ms away. 
10. StoreAngle(AccelName,AccelDimension,VariableName) : store a current angle into a variable that can be used later. Ex: 0,StoreAngle(ACCEL_LEFT_UPPER_LEG,Z,LULZ0)
11. StartLoop(#,Keyword1,Keyword2)  - start looping all instructions below this inst until the EndLoop inst
# is the number of times to loop -1=indef, 0=none(todo), 1+=number of times to loop. Keyword1 is the key that will end the loop after the last inst in the loop group. Keyword2 is the key(s) that will instantly abort the loop and script. Keywords can be "Any" or "#" where # is the key code in decimal
12. EndLoop- end of instructions to loop. 
13. StartBalancing - not used
14. StopBalancing - not used

