com.ant-automation.antcity.base.mqttcontroller
v0.0.17
Published
Provides a controller able to receive Agent data through MQTT protocol.
Downloads
36
Readme
AntCity MQTTController
Dependencies
Requirements
- Have an active MQTT message broker (Development was made with Apache ActiveMQ Artemis).
- Have a running MQTT Proxy
- Have an active Spatial Agent Simulation (It can be either a GAMA Pedestrian Simulation or a SUMO Vehicle Simulation)
Usage
- Attach the 'MqttController' script (located in the "/Runtime/Scripts" folder inside the package) to a GameObject.
- Set the Broker's URL in the added component.
- In order to subscribe to a new topic you must call the 'Subscribe()' method, providing the topic name and a CartesianTransform which will transform the simulation coordinates to Unity coordinates (See the GeoUtils Package for more information)
The controller will be processing messages and creating/updating agent information which will be exposed in a public Dictionary called ActiveAgentsPerTopic Each key for this dictionary is one of the subscribed topics and inside contains another dictionary which key is the Agent's Name and the value is that agent's data.
Whenever the MqttController receives new agent data, it will call the 'OnAgentInfoReceived' event with the received agents' info. You can subscribe your components to this event and react to it.
Observations
The JSON deserialization job currently allocates its NativeArrays memory with Allocator.Persistent. Performance could be improved if we can use Allocator.TempJob, but it would require to perform the entire job within 4 frames. It's currently processing it in about 2 to 12 frames (Depending on the message load).