Editor: Configuring Simulations with MQTT
The inclusion of various external integration protocols within Nominal Editor allows for bi-directional data flow with external entities. This also enables the creation of simulation levels that are configured by these external sources. This tutorial focuses on the use of MQTT to configure a planetary imaging spacecraft. Specifics of the simulation system, the spacecraft's orbit, and the camera payload can be configured. The captured image data is then sent out over MQTT whenever the camera payload captures an image. At the end of the desired simulation duration, the simulation resets, pending new configuration data. The MQTT Configured Camera
Nominal Editor demo is referenced in this guide and is a provided example of configuring a simulation from MQTT.
Configuring the Simulation
As the simulation breaks from the usual structure of Nominal Editor simulations, the first step is to create and connect the MQTT Client. The provided Nominal Editor demo also has the capability of acting as the MQTT Broker/Server. Therefore, if using an external MQTT Broker, only the client needs to be connected.
Note
The Connect
function of the MQTT client will need to be updated for the selected external broker if used.
Once connected, the next step is to subscribe to the required MQTT Topics. As shown in the provided Nominal Editor demo, there are three MQTT Topics used to configure the simulation, that are appended to the topic prefix NominalSystems\MQTTConfigedSimDemo\
:
- Simulation: This topic needs to contain the starting epoch and the duration of the simulation.
- Spacecraft: This topic includes the Classical elements of the spacecraft’s orbit and the orbiting body for the spacecraft.
- Camera: Used to configure the
File Type
,Sample Rate
andField of View
of the camera payload on the spacecraft. - ImageOut [OPTIONAL]: This topic isn’t used to configure the simulation. The demo can be configured to save the image data that is published on the ImageOut Topic and therefore needs to subscribe to it. This feature of the demo is enabled by setting
SaveMQTTImages
to True.
Ticking the Simulation
The simulation level will only start ticking the simulation once one of each of these topics has been received and the UI has been configured. To track this, boolean variables were created for each topic. Once data for one of the above topics have been received and processed to configure the simulation, the matching boolean is set to true.
Once all three booleans are true, the simulation starts ticking. Whilst ticking the simulation, whenever a new image has been captured based on the configured sample rate, the byte array data of that image is published over the fourth MQTT Topic.
When the specified simulation duration has been reached, the simulation level pauses to ensure all data has been exported over MQTT before resetting itself for a new set of simulation parameters.
The referenced MQTT Configured Camera
Nominal Editor demo does include an option to configure itself by sending predefined simulation parameters over the three configurations of MQTT topics for demo purposes. The demo can also be configured to run in a local host deployment and to save the exported images locally. The locally saved images, if enabled, can be found in the Saved/NominalSystems
folder of Nominal Editor.
Example Result
The default simulation settings result in a 7,000-second-long simulation of a spacecraft orbiting Neptune that is imaged every 300 seconds by a 90-degree FOV camera payload once the payload is pointing at Neptune. The Image data is then exported to the localhost MQTT Broker on the ImageOut
Topic as a JPEG.