C# Class vvRobotBase, VirtualVEX

Base class for all robots in VirtualVEX. vvRobotBase handles the loading of user code from a precompiled DLL file. This loaded code is used in the control of all inherited classes. Other functions common to all robots are also implemented in this base class. These include a timer function that keeps track of the current time and, if applicable, stops the robot at the time limit. The Physics Window and User Code window are also implemented here. vvRobotBase also contains definitions for the VirtualVEX developer API functions. These functions allow developers to easily configure their own robots.
Inheritance: MonoBehaviour
显示文件 Open project: jpwchang/VirtualVEX

Public Properties

Property Type Description
skin UnityEngine.GUISkin
timer GameObject

Protected Properties

Property Type Description
ErrorString_ string
SensorValue float[]
WWW_ WWW
assemblyURL_ string
complete_ bool
lMotorPowerPrev_ float
motor float[]
owner Field,
rMotorPowerPrev_ float
retried_ bool
robotID_ string
text_ string
tracker_ GameObject

Public Methods

Method Description
OnGUI ( ) : void
ReloadAssembly ( string url ) : void
Start ( ) : void
Update ( ) : void
physWinFunc ( int windowId ) : void
setMotor ( GameObject motor, float powerLevel, MovementMode applyMode = MovementMode.DIRECT_VERTICAL ) : void

Assign a given power level to a motor on the virtual robot. This allows components of your robot other than the drivebase to move. This method is designed for moving parts that do not have an actual simulated motor. One example of such a part is a linear slider. This method simulates motor power by directly adding a force to the given component, or GameObject. As a result, you must specify a movement type. This tells the program what direction the component will be moving in and whether the motion is linear or rotational. There are 3 available movement types for linear motion:

LINEAR_VERTICAL: Straight up and down.

LINEAR_HORIZONTAL: Straight forward and backward.

LINEAR_SIDEWAYS: Straight left and right.

For compatibility reasons, this method also enables angular motion for arms. However, this method of angular motion is obsolete and the hinge joint version of setMotor should be used instead. For compatibility, the following angulat movement types are allowed:

DIRECT_VERTICAL: Rotational, up and down, facing forward (or backward). Perfect for arms.

DIRECT_HORIZONTAL: Rotational, side to side. Perfect for claws.

DIRECT_SIDEWAYS: Rotational, up and down, facing left or right.

All directions are relative to the robot. The default direction is DIRECT_VERTICAL.

setMotor ( GameObject motor, float velocity, float powerLevel ) : void

Assign a given power level to a motor on the virtual robot. This allows components of your robot other than the drivebase to move. This version of setMotor is designed for parts that rotate, such as arms and claws. The part must have a HingeJoint component (representing the motor axle) for this method to work. The orientation of the HingeJoint automatically determines the axis of rotation.

setMotor ( WheelCollider motor, float powerLevel ) : void

Assign a given power level to a wheel. This allows you to move the robot's drive base. A common use for this method is in driver control, passing in a joystick axis as the power level. This method can only be used on wheel colliders (usually found on drivebases). For a version that applies to other motor placements, see the overloaded version: setMotor(GameObject, float, int).

setMotors ( WheelCollider motor1, WheelCollider motor2, float powerLevel ) : void

Set two drive motors to the same power level. Useful for 4-wheel drivebases.

Protected Methods

Method Description
LoadAssembly ( ) : Assembly

Private Methods

Method Description
updateSensors ( float step ) : void

Method Details

LoadAssembly() protected method

protected LoadAssembly ( ) : Assembly
return Assembly

OnGUI() public method

public OnGUI ( ) : void
return void

ReloadAssembly() public method

public ReloadAssembly ( string url ) : void
url string
return void

Start() public method

public Start ( ) : void
return void

Update() public method

public Update ( ) : void
return void

physWinFunc() public method

public physWinFunc ( int windowId ) : void
windowId int
return void

setMotor() public method

Assign a given power level to a motor on the virtual robot. This allows components of your robot other than the drivebase to move. This method is designed for moving parts that do not have an actual simulated motor. One example of such a part is a linear slider. This method simulates motor power by directly adding a force to the given component, or GameObject. As a result, you must specify a movement type. This tells the program what direction the component will be moving in and whether the motion is linear or rotational. There are 3 available movement types for linear motion:

LINEAR_VERTICAL: Straight up and down.

LINEAR_HORIZONTAL: Straight forward and backward.

LINEAR_SIDEWAYS: Straight left and right.

For compatibility reasons, this method also enables angular motion for arms. However, this method of angular motion is obsolete and the hinge joint version of setMotor should be used instead. For compatibility, the following angulat movement types are allowed:

DIRECT_VERTICAL: Rotational, up and down, facing forward (or backward). Perfect for arms.

DIRECT_HORIZONTAL: Rotational, side to side. Perfect for claws.

DIRECT_SIDEWAYS: Rotational, up and down, facing left or right.

All directions are relative to the robot. The default direction is DIRECT_VERTICAL.
public setMotor ( GameObject motor, float powerLevel, MovementMode applyMode = MovementMode.DIRECT_VERTICAL ) : void
motor GameObject Which motor to apply this to
powerLevel float The power to supply to this motor
applyMode MovementMode The direction this power should be applied in
return void

setMotor() public method

Assign a given power level to a motor on the virtual robot. This allows components of your robot other than the drivebase to move. This version of setMotor is designed for parts that rotate, such as arms and claws. The part must have a HingeJoint component (representing the motor axle) for this method to work. The orientation of the HingeJoint automatically determines the axis of rotation.
public setMotor ( GameObject motor, float velocity, float powerLevel ) : void
motor GameObject Which motor to apply this to
velocity float The motor's target velocity
powerLevel float How much power the motor gets
return void

setMotor() public method

Assign a given power level to a wheel. This allows you to move the robot's drive base. A common use for this method is in driver control, passing in a joystick axis as the power level. This method can only be used on wheel colliders (usually found on drivebases). For a version that applies to other motor placements, see the overloaded version: setMotor(GameObject, float, int).
public setMotor ( WheelCollider motor, float powerLevel ) : void
motor WheelCollider Which motor to apply this to
powerLevel float The power to supply to this motor
return void

setMotors() public method

Set two drive motors to the same power level. Useful for 4-wheel drivebases.
public setMotors ( WheelCollider motor1, WheelCollider motor2, float powerLevel ) : void
motor1 WheelCollider The first affected motor
motor2 WheelCollider The second affected motor
powerLevel float The power to supply to both motors
return void

Property Details

ErrorString_ protected_oe property

protected string ErrorString_
return string

SensorValue protected_oe property

protected float[] SensorValue
return float[]

WWW_ protected_oe property

protected WWW WWW_
return WWW

assemblyURL_ protected_oe property

protected string assemblyURL_
return string

complete_ protected_oe property

protected bool complete_
return bool

lMotorPowerPrev_ protected_oe property

protected float lMotorPowerPrev_
return float

motor protected_oe property

protected float[] motor
return float[]

owner protected_oe property

protected Field, owner
return Field,

rMotorPowerPrev_ protected_oe property

protected float rMotorPowerPrev_
return float

retried_ protected_oe property

protected bool retried_
return bool

robotID_ protected_oe property

protected string robotID_
return string

skin public_oe property

public GUISkin,UnityEngine skin
return UnityEngine.GUISkin

text_ protected_oe property

protected string text_
return string

timer public_oe property

public GameObject timer
return GameObject

tracker_ protected_oe property

protected GameObject tracker_
return GameObject