Table of Contents

MQTT Communication: Triggering Actions

Description

The event's panel also enables particular actions to be executed. These actions are specific to the component and not all components have actions. An action could be one of the following and is dependent on the component being used.

  • Solar Panel: Deploy and Retract the panels (for the Deployable one only)
  • Guidance Computer: Change the guidance pointing modes between SUN, NADIR, VELOCITY, etc.
  • Camera: Capture an image and display the output
  • Thruster: Fire the thruster for a few seconds
Note

Currently, there are a limited number of actions that can be triggered on events. This will be improved upon in future releases with more events and parameters exposed. Each event currently contains no data that can be triggered alongside the event.

All events can be executed via MQTT when a specific message on a topic is subscribed to. In this tutorial, the deployable solar panel will be used and will be deployed and retracted via MQTT.


Configuring the Action

Returning to the spacecraft, the Solar Panel 3U XY Deployable component needs to be attached to the spacecraft. This is the only solar panel that has a deployment mechanism. Currently, the deployment of the panel is a simple animation and does not change the physics of the solar panel or the sunlight direction factor.

Untitled

Once the solar panel is added, select the solar panel and find the events tab in the properties panel. This is the same panel that was used in the previous tutorial. Create another event using the Add Event button at the top of the panel. In this case, select the solar panel as the component. As the event type, this time select MQTT. This will enable the event to be triggered from an MQTT call. There are two options for the actions:

  • If the Message is Action is disabled, a particular action must be selected and must have a dedicated topic associated with it.
  • If the Message is Action is enabled, the data within the topic is associated with the action.

In this case, the Message is Action should be enabled, which means the data that is published on the MQTT topic must be the action that will be triggered; either Deploy or Retract in this case.

Note

When publishing the data on the topic that defines the action to trigger, the action must be spelt the same and be case-sensitive. Any invalid event calls will result in no events being triggered.

The topic is the topic that will be subscribed to when listening for this component’s actions. The default topic can be edited but will include a unique name associated with the client ID and the component being used. For simplicity, in this tutorial, the topic name SolarPanelDeploy will be used, but note that this is a public topic.

Untitled


Executing the Event

Once the event is configured, start the simulation and return to the public broker interface. Using the topic publish panel, enter SolarPanelDeploy as the topic and in the message, publish either Deploy or Retract. In the simulation, watching the spacecraft, the solar panel will perform the action when the message is received.

Untitled

When the Deploy or Retract commands are parsed, the solar panel will execute those actions as expected. This same system will work with any component that has actions available.

Untitled

Note

When calling MQTT events, the MQTT client must have been configured already. Failure to configure the client during the Studio session will result in no event being triggered.