Data Downlink: Designing a Spacecraft
Creating an Asset
Previously, spacecraft have been spawned in the level using the standard base empty class or one of the default-created ones. This tutorial will cover how to create a new satellite design, with components attached. For this tutorial, we will use a 2U frame. Right-click on the content browser and select Blueprint Class
. Click the dropdown of ‘All Classes’ and search for the spacecraft design to use as a base.
Note
The BP_Spacecraft_Empty_XU
designs are standard X-unit cube satellites that have already been configured with a chassis. Additional components can be added to the child classes. When starting from scratch and wanting to create a new spacecraft, the Spacecraft
base class should be used.
The naming convention for spacecraft is BP_Spacecraft_[NAME]
. In this case, the name of the spacecraft will be BP_Spacecraft_Tutorial_02
. Additionally, it is good practice to put the spacecraft and the demo in the same folder within the content directory.
Navigating the Editor
Opening up the spacecraft design (by double-clicking on the asset in the content browser) will show a new blueprint editor. This editor has many panels that are used for designing components in Unreal. There are five main panels in the blueprint editor:
1. This is the viewport. Here, spacecraft or component designs will be shown with all components added to the spacecraft. Right-clicking this window and using the mouse and WASD keys will allow the user to move around the spacecraft and the view.
2. This is the outliner. Here, all functions, event graphs and variables that are exposed on the spacecraft are shown. Blueprints also have BeginPlay
and Tick
events that can be executed by the simulation. Blueprint code can be written here just as it can be in the level blueprint.
Note
Typically, the demos have all spacecraft code written in the level blueprint. This is not a requirement but rather a standard to have all code in the same place. It is just as valid to write blueprint code related to the spacecraft and its components in the component blueprint instead.
3. This is the toolbar. Several functions appear here, with the most common being the save and the compile buttons. The compile button will turn all the blueprint code into source code and update any variables or functions changed.
4. This is the details panel. All intrinsic variables about the spacecraft or the component selected will be shown here. Note the Nominal Systems
category which will display custom variables that have been exposed for spacecraft simulation. All other variables are Unreal values and will be skipped in these tutorials.
5. This is the compiler log. Any issues with compiling blueprints with errors or warnings will appear in this log. This is useful for fixing issues or determining where code is incorrect.
Adding a Component
Components can be added to the spacecraft by pressing the Add Component
button in the outliner. The component will be added as a child to the component that is currently selected. There are some options for components, most of which are Unreal-specific objects. For standard shapes and meshes, the static mesh component is sufficient. This is the same component type that is present in all child components for displaying the mesh and material of the object. To add another object from the object library, select the chassis as the parent component and add a Child Actor
.
A child actor allows for any created component to be attached to the spacecraft (or object selected). Several pre-configured components can be found in the following directory in the content browser. They have been sorted by category of component type.
Plugins/NominalAssetsSpace/Blueprints/Components
Note
In the file explorer, the NominalAssetsSpace
folder is located in the mods directory under the NominalAssets
folder. This is how Unreal picks up additional files for the content browser. This particular mod includes all space-related assets. The NominalAssetsGround
folder includes any ground-related assets. Additional packs may be included in the future.
Once a child actor is added, select the child actor navigate to the details panel and change the Child Actor Class
to the desired class. This is the object that will be added to the spacecraft.
Adding the Required Components
The first component to add is the reaction wheels, which will drive the attitude guidance system onboard the spacecraft. This will be the same component as the previous tutorial, using the BP_NS_ReactionWheel_Quad
component. With each component, it is good practice to name the component in the components panel. The next component to add is the guidance computer, which will control the software chains and update the reaction wheel commands. This component will be the BP_NS_GuidanceComputer
. The final required component, for now, is the radio transmitter. This will be able to transmit message data over the TT&C system. This component is the BP_NS_Transmitter_1U
.
Components can be reordered by dragging the components around. In this case, all three custom components should be added to the chassis as the parent.
Once the components are added, clicking each of the components will show the transform panel in the details panel. This will show the location, rotation and scale properties relative to the parent. Similar to the previous tutorial, these values are in Unreal coordinates and not using simulation right-handed coordinate systems. For each component, adjust the location such that the components do not intersect and are displayed correctly on the cube satellite.
Exposing Components
Unfortunately, in the level blueprint, when attempting to get a component from the spacecraft that has been added in the blueprint editor, the component name will return a Child Actor Component
type, rather than the correct type. To get the correct type of variable, the child actor of the component needs to be cast to the correct type. To help make this more efficient, functions can be written on the blueprint that returns the correct variable type. All standard spacecraft models implement these functions in the same way. The transmitter component will be required to be exposed from the spacecraft. Create a new function named Get Transmitter (Component)
that will return the transmitter. The child actor can be cast to the correct component type and returned. To create a new output, drag the blue pin to the return node.
Note
It is good practice to cast the object to the lowest level of inheritance when possible. If the blueprint version of the transmitter is not required and no blueprint code exists on the blueprint node, then it is better to use the base C++ class instead (which will not include the standard BP_NS
prefix). This allows easy swapping of the class types without rewriting the code.
Additionally, for these component functions, the function should be marked as pure. A pure function does not require an execution pin and will appear to be green instead of blue in the blueprint editor. To mark a function as pure, select the function name in the outliner and toggle the pure flag.
A function will typically be exposed for each of the added components. For this tutorial, since the guidance computer and reaction wheels will not need to be accessible from the level blueprint, they will not be exposed.
Alternatively, the same functionality can be done with the Cast To [X]
functions that have been created for the Nominal Assets. These take in the child actor component and perform the cast to the appropriate type required. These functions are easier to use and perform the same code as the previous images.
Updating the Guidance Computer
For this tutorial, the NADIR pointing mode will be used on the guidance computer. This will attempt to align the antenna to constantly face towards the centre of the Earth. To adjust the initial state of the guidance computer, select the component in the blueprint spacecraft editor and adjust the value under the Default
category. Change the pointing to NADIR
and the controller to MRP
.
Note
Generally, most variables will be located under the Nominal Systems
category. Variables exposed in the blueprint components may not have a category and will show up under the Default
category.
Updating the Spacecraft Variable
Now that the spacecraft has been designed, returning to the level blueprint, the Spawn Actor
node can change the class. The new class can be selected to BP_Spacecraft_DataDownlink
, as created. Since the original class was Spacecraft
, which is inherited from the custom blueprint, this will not break any blueprint nodes. To change the type to a new spacecraft, select the spacecraft variable and change the type to the new one.
When changing types, this will often prompt with a confirm message for changing the variable type. In this case, clicking confirm will change the type without any issues.
Warning
When changing the object type to a class that inherits from the previous one, there should be very few issues with the blueprint compiling. However, changing to another class may result in blueprint compile errors that may result in needing to change the blueprint nodes. It is best practice to use the lowest level of inheritance when storing variable types, to avoid issues of changing types.
Visualizing the Spacecraft
Running the scenario once the spacecraft has been configured will display the newly configured components onboard the spacecraft.