Package eu.iv4xr.framework.environments
Class W3DEnvironment
java.lang.Object
nl.uu.cs.aplib.mainConcepts.Environment
eu.iv4xr.framework.mainConcepts.Iv4xrEnvironment
eu.iv4xr.framework.environments.W3DEnvironment
- All Implemented Interfaces:
IW3DEnvironment
An extension of
Iv4xrEnvironment
. It adds
methods typical for interacting with a 3D-virtual-world environment. Examples
of such an environment are 3D games or simulators.
This class provides only a partial implementation of Iv4xrEnvironment.
You still need to implement the method sendCommand_(EnvOperation)
.- Author:
- Wish
-
Nested Class Summary
Nested classes/interfaces inherited from class nl.uu.cs.aplib.mainConcepts.Environment
Environment.EnvironmentInstrumenter, Environment.EnvOperation
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
static String
static String
protected Mesh
A polygon-mesh describing the navigable surface of the 3D-world represented by this environment.Fields inherited from class nl.uu.cs.aplib.mainConcepts.Environment
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionExecute an interaction of the specified type on the given target entity in the real environment.void
Send a command to the real environment that should cause it to send over the navigation-mesh of its 3D world.moveToward(String agentId, Vec3 agentLocation, Vec3 targetLocation)
A command to instruct an agent to move a small distance towards the given target location.Send a command to the real environment that will cause it to send back what the agent of the given id observes in the real environment.protected Object
You need to implement this method.Return the polygon-mesh describing the navigable surface of the 3D-world represented by this environment.Methods inherited from class nl.uu.cs.aplib.mainConcepts.Environment
getLastOperation, instrument, registerInstrumenter, removeInstrumenter, resetAndInstrument, resetWorker, sendCommand, sendCommand, turnOffDebugInstrumentation, turnOnDebugInstrumentation
-
Field Details
-
LOADWORLD_CMDNAME
-
OBSERVE_CMDNAME
-
MOVETOWARD_CMDNAME
-
-
Constructor Details
-
W3DEnvironment
public W3DEnvironment()
-
-
Method Details
-
interact
Execute an interaction of the specified type on the given target entity in the real environment. The parameter interactionType is a string specifying the name of the interaction to do, e.g. "Open" or "TurnOn". This string should not be the same command names that are already pre-defined by this class, such as OBSERVE_CMDNAME. This method has no further argument to send to the real environment. The method should return a new observation by the specified agent, sampled after the interaction.- Specified by:
interact
in interfaceIW3DEnvironment
- Parameters:
agentId
- The id of the agent that does the interaction.targetId
- The id of the entity that is the target of the interaction.
-
observe
Send a command to the real environment that will cause it to send back what the agent of the given id observes in the real environment. The observation will be parsed into an instance ofWorldModel
.- Overrides:
observe
in classIv4xrEnvironment
- Parameters:
agentId
- The id of the agent whose observation is requested.- Returns:
- An instance of WorldModel representing what the specified agent observes.
-
moveToward
A command to instruct an agent to move a small distance towards the given target location. How far the agent actually moves depends on the real environment. Typically, the calling agent will execute interactions/commands in update cycles. Then it depends on how fast time proceeds in the real environment as we advance from one agent's update-cycle to the next. A possible setup is to make the real environment to run in sync with the agent's cycles and to fix the simulated time between cycles, e.g. 1/30-th second. In this case, the agent will then move to some distance of the specified velocity/30. The method should return a new observation, sampled at the end of its movement.- Specified by:
moveToward
in interfaceIW3DEnvironment
-
loadWorld
public void loadWorld()Send a command to the real environment that should cause it to send over the navigation-mesh of its 3D world. This mesh is assumed to be static (does not change through out the agents' runs).- Specified by:
loadWorld
in interfaceIW3DEnvironment
-
sendCommand_
You need to implement this method. There are a number of pre-defined command names, namely: cmd.command is LOADWORLD_CMDNAME: this should ask the real-environment to send back an navigation-mesh. This method should package it as an instance of Mesh and return it. cmd.command is OBSERVE_CMDNAME: this should ask the real-environment to send over the observation of agent cmd.invokerId. This method should package the result as an instance of WorldModel and return it. cmd.command is MOVETOWARD_CMDNAME: this should ask the real-environment to move its entity/agent cmd.invokerId in the direction specified by cmd.arg. This method should also obtain the observation of the said agent at the end of the move, and package the observation as an instance of WorldModel and return it. cmd.command has other values: this should ask the real-environment to apply an interaction by the agent cmd.invokerId on the entity specified by cmd.targetId, and with interaction type specified by cmd.command (e.g. "OPEN" or "CLOSE"). This method should also obtain the observation of the said agent at the end of the interaction, and package the observation as an instance of WorldModel and return it.- Overrides:
sendCommand_
in classEnvironment
- Parameters:
cmd
- representing the command to send to the real environment.- Returns:
- an object that the real environment sends back as the result of the command, if any. If the cmd specifies what the expected type of the returned object, then this method should guarantee that the returned object is indeed an instance of the specified type.