Package edu.tufts.hrilab.unity
Class UnityComponent
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.unity.UnityComponent
Provides a socket-based connection to Unity for message passing
from and to TRADE services.
-
Field Summary
Fields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, shouldRunExecutionLoop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<org.apache.commons.cli.Option>Override this method to define command line options available in sub-class.protected voidThis is where any code that needs to be called repeatedly in a dedicated thread should live.getResponse(Message msg) protected voidinit()Perform any component initialization.voidMethod for passing messages received from the Unity socket server to all Unity agents which register TRADE services for receiving messages.protected voidparseArgs(org.apache.commons.cli.CommandLine cmdLine) Override this method to parse command line args in the sub-class.parseMessage(String str) Parse JSON from string to Message type.protected voidproxyMessage(Message msg, String tradeServiceName) Method for proxying Message to specified TRADE service.booleanTRADE service which allows agent to speak within Unity.voidsendMessage(Message msg) Send message via local socket client.unityGetResponse(Message msg) Exposes getResponse() to TRADE.booleanunitySendMessage(Message msg) Exposes sendMessage() to TRADE.Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
createInstance, createInstance, createInstance, createInstance, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, main, shutdown, shutdownComponent
-
Constructor Details
-
UnityComponent
public UnityComponent()
-
-
Method Details
-
init
protected void init()Description copied from class:DiarcComponentPerform any component initialization. This should not be used for setting local fields to default values as was the case in DIARC. This method is called after the constructor, and after parseArgs. Setting default values should be done in field declaration or in the constructor.- Overrides:
initin classDiarcComponent
-
additionalUsageInfo
Description copied from class:DiarcComponentOverride this method to define command line options available in sub-class. This should be paired with a parseArgs implementation.- Overrides:
additionalUsageInfoin classDiarcComponent- Returns:
-
parseArgs
protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine) Description copied from class:DiarcComponentOverride this method to parse command line args in the sub-class. Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.- Overrides:
parseArgsin classDiarcComponent
-
executionLoop
protected void executionLoop()Description copied from class:DiarcComponentThis is where any code that needs to be called repeatedly in a dedicated thread should live. It is not called by default and you must set shouldRunExecutionLoop to true in your constructor.- Overrides:
executionLoopin classDiarcComponent
-
onReceive
Method for passing messages received from the Unity socket server to all Unity agents which register TRADE services for receiving messages.- Parameters:
msg- - Message received from Unity.
-
proxyMessage
Method for proxying Message to specified TRADE service.- Parameters:
msg- - Message from Unity to proxy.tradeServiceName- - TRADE service to receive message.
-
parseMessage
Parse JSON from string to Message type.- Parameters:
str- - Serialized string of JSON originating from Unity.
-
sendMessage
Send message via local socket client.- Parameters:
msg- - Message to send to Unity.
-
getResponse
-
unitySendMessage
Exposes sendMessage() to TRADE.- Parameters:
msg- - Message to send to Unity.
-
unityGetResponse
Exposes getResponse() to TRADE.- Parameters:
msg- - Message to send to Unity.
-
sayText
TRADE service which allows agent to speak within Unity. Uses as Unity-based TTS to synthesize speech in simulation.- Parameters:
text- - String of message for agent to speak in Unity
-