150 likes | 626 Views
2. Programming Unreal . The Unreal Virtual MachineSimilar to Java Virtual MachineComponentsserver, client, rendering engine, and the engine support code.Language: Unreal ScriptThe Tickthe smallest unit of time in which all actors in a level are updatedStatesObject's behaviors managementProg
E N D
1. 1 USARSim Tutorial
2. 2 Programming Unreal The Unreal Virtual Machine
Similar to Java Virtual Machine
Components
server, client, rendering engine, and the engine support code.
Language: Unreal Script
The Tick
the smallest unit of time in which all actors in a level are updated
States
Object’s behaviors management
Program state machine at language lever
3. 3 Programming Unreal (cont.) Network Programming
Replication
The way to communicate between server and client
Types: actors, variables, functions
Quality: reliable or unreliable
Method: conditional replication
Only replicate data to the relevance actors
Simulated function
Function runs both on server and client
Similar to the fork() function in C
Reference
Unreal Networking Architecture http://unreal.epicgames.com/Network.htm
UnrealWiki--Replication http://wiki.beyondunreal.com/wiki/Replication
4. 4 Unreal Script Object oriented language
Language Reference
Unreal Script Reference
http://udn.epicgames.com/Two/UnrealScriptReference
UnrealScript Lessons
http://wiki.beyondunreal.com/wiki/UnrealScript_Lessons
Compile
Compiling With UCC http://wiki.beyondunreal.com/wiki/Compiling_With_UCC
Edit ut2003.ini file
Delete you .u file, then run ‘ucc make’
Debug
UnrealScript Debugger http://udn.epicgames.com/Two/UnrealScriptDebugger
Print out the information you want
5. 5 Sensor Overview
How sensor works
Calculate based on the ground truth database
Add noise and distortion
Build sensor class
Based on Sensor class
Provide sensor
data in plain text
6. 6 Sensor (cont.) The Sensor Class
Attributes
Name & type
Noise & distortion
Mounting info.
Others
Static mesh
Scale
Hidden sensor
Methods
Initialize
setName and mounting
Data
sensor data, sensor type & sensor’s configuration
7. 7 Sensor (cont.) Build Sensor
Extend from sensor class
Specify properties (you may add your own attributes)
Type
Noise & distortion curve (the input-output curve)
Static mash, scale and whether display the mesh etc.
Provide sensor data
Fill the GetData() function
Calculate data
Add noise
Interpolate the input-output curve to distort data
Fill the GetConf() function
Compile the class
8. 8 Sensor (cont.) Example (range finder)
9. 9 Command The mechanism (Gamebots)
BotConnection
Receive data
Parser data
Transfer command
to RemoteBot
RemoteBot
Store commands into variables
Robot
Check the RemoteBot’s variables every tick
Make response to the variable
10. 10 Command (cont.) Add a command
In RemoteBot
Define variable(s) to store the command
Ex. var int speed;
In BotConnection
theBot: the RemoteBot possesses the BotConnection
Add parsing codes in ProcessAction()
Check data type
Parse data
GetArgVal(): get the value of an argument
ParseVector(), ParseRot(): get vector and rotation
Set the variable of thebot (RemoteBot)
Ex. theBot.speed = …;
11. 11 Command (cont.) In Robot class
Controller: the RemoteBot of the robot
Get the command through the controller
Ex. speedCommand = RemoteBot(Controller).speed;
Example
12. 12 Robot The workflow
13. 13 Robot (cont.) Maintain chassis’ state
Method
Tick function: PackState()
Server packs chassis’ state
Event: VehicleStateReceived()
Unpack and calculate chassis’ state
Event: KUpdateState()
Commit chassis’ state
Chassis state (rigid body state)
Position
Direction
Liner velocity
Angular velocity
14. 14 Robot (cont.) Control part(s)
Method
Tick function: PackState()
Server packs part’s state
Server and client update joint’s parameter
torque, max speed, steering angle etc.
Event: VehicleStateReceived()
Unpack and calculate part’s state
Unpack joint’s parameters
Tick function: set joint’s control parameters
Joint control
15. 15 Robot (cont.) Strategy
Absolute control vs. relative control
Position control vs. speed control vs. torque control
State package replication vs. simple variable replication
Example
Chassis state maintain
Rover – Differential(); KUpdateState(); replication expQ;
Part state maintain
P2DX – Tick(); replication steerAng;
Part control
P2AT – ProcessCarInput()