Connecting to STK from Delegates
Overview
You will only be able to fully follow along in this tutorial if you acquired Behavior Execution Engine as part of STK Enterprise.
Behavior Execution Engine uses analysis tool controllers to communicate with external tools like STK. At the start of a simulation, an analysis tool controller instantiates all of the delegates associated with it, injecting dependencies from the external tool into the delegates for them to use. You can implement custom analysis tool controllers for other tools, but since the UAV mission only requires STK, you will just use Behavior Execution Engine's STK controller in this tutorial. In this section, you will set up the STK controller and its STK toolbox dependency, initialize the STK object data, and use a SysML stereotype to configure the simulation to start the STK scenario when the simulation starts.
This section covers the following concepts:
- Behavior Execution Engine delegate module descriptors
- Behavior Execution Engine analysis tool controllers, especially the STK controller
- Behavior Execution Engine's STK toolbox
- Behavior Execution Engine's StkObjectSpatialEntity delegate
- Behavior Execution Engine simulation configuration with stereotypes, especially STK simulation configuration
public UAVDelegate( ...
@InjectByName("stkToolbox") StkToolbox stkToolbox,
@InjectByName("stkEarth") StkEarth stkEarth,
... ) {
super(stkToolbox, stkEarth, timeProvider);
mStkToolbox = stkToolbox;
...
mStkToolbox.sendConnectCommand("Units_SetConnect / Internal");
}
public void initializeStkObject() {
//Attach to the STK object.
this.updateFromStkObject(stkObjectPathProperty().getValue());
mStkUavObject = this.getStkObject();
}
Figure A1: Connecting to an STK object from a delegate
Prerequisites
Prerequisite | Description |
---|---|
Behavior Execution Engine Installation | You must have installed Behavior Execution Engine and have the prerequisites for developing delegates for Behavior Execution Engine. |
STK Installation | You must have installed STK 12.9 or later. |
Tutorial Project |
You must start this section with the UAV Mission simulation project and delegate module project from the previous section. If you did not complete the previous section, you can use the files from the Behavior Execution Engine installation: \documentation\tutorialFiles\03\SignalEvents, but you may still need to configure the delegate module for your environment. You also need the UAV Mission STK scenario from the Behavior Execution Engine installation: \documentation\tutorialFiles\03\UAVMission.vdf. |
Recommended Reading |
Before completing this section, you may want to read the following help topics:
|
Instructions
Replace the analysis tool controller
A delegate provider registers the module with Behavior Execution Engine by providing a delegate module descriptor that contains the analysis tool
controller and the list of delegates.
Since you will be integrating your simulation with STK,
you should replace the BuiltInAnalysisToolController
with the StkController
,
which includes dependencies for interacting with STK in addition to including all of the same built-in dependencies.
-
In the
UAVMissionDelegateProvider
class, remove the following import statement:import com.agi.moxie.api.analysistools.BuiltInAnalysisToolController;
-
Add the following import statement:
import com.agi.moxie.stk.delegates.core.StkController;
-
In the return statement of the
provideDescriptor()
method, replace theBuiltInAnalysisToolController.class
argument withStkController.class
.
Add the STK toolbox dependency
The StkToolbox
dependency is the primary means of interacting with STK from Behavior Execution Engine.
In the next section, you will use this dependency to control the STK scenario.
-
In the
UAVDelegate
class, add the following import statement:import com.agi.moxie.stk.utilities.toolbox.StkToolbox;
-
Add the following private field declaration:
private StkToolbox mStkToolbox;
-
In the constructor,
add the following dependency injection and field initialization:
public UAVDelegate( ...
@InjectByName("stkToolbox") StkToolbox stkToolbox,
... ) {
mStkToolbox = stkToolbox;
...
} -
At the end of the constructor,
add the following code to set the units when using STK Connect commands:
mStkToolbox.sendConnectCommand("Units_SetConnect / Internal");
-
Repeat the previous steps to add the
StkToolbox
dependency to theComputerDelegate
and theSensorPayloadDelegate
.
Add the STK object initialization
Behavior Execution Engine provides the StkObjectSpatialEntity
delegate to facilitate STK object references in your custom delegates.
-
In the
UAVDelegate
class, add the following import statements:import agi.stkobjects.IAgStkObject;
import com.agi.moxie.stk.delegates.core.StkEarth;
import com.agi.moxie.stk.delegates.core.StkObjectSpatialEntity; -
In the class declaration,
add
extends StkObjectSpatialEntity
as follows:public abstract class UAVDelegate extends StkObjectSpatialEntity implements UAV
-
Add the following private field declaration:
private IAgStkObject mStkUavObject;
-
In the constructor,
add the following dependency injection and parent constructor call:
public UAVDelegate( ...
@InjectByName("stkEarth") StkEarth stkEarth,
... ) {
super(stkToolbox, stkEarth, timeProvider);
...
} -
In the
initializeStkObject()
method, add the following code to attach to the STK object://Attach to the STK object.
this.updateFromStkObject(stkObjectPathProperty().getValue());
mStkUavObject = this.getStkObject(); -
Repeat the previous steps to initialize the STK object data in the
SensorPayloadDelegate
, but replacemStkUavObject
withmStkSensorObject
in the private field declaration and theinitializeStkObject()
method.
Add an STK simulation configuration
Behavior Execution Engine provides several SysML stereotypes that enable you to configure how your simulation runs. You can use one of these stereotypes to automatically launch the STK scenario for the UAV Mission when the simulation starts.
- Copy the STK delegate module (\delegates\com.agi.moxie.stk) from the Behavior Execution Engine installation into your delegate module home directory (e.g., C:\BehaviorExecutionEngine\DelegateHome\com.agi.moxie.stk).
- Open the UAVMission.mdzip project from the previous section.
- In your No Magic modeling tool, select Options > Project Usages and click .
- In the Use Project dialog box shown in Figure B1, select From file system. If you copied the BEE model libraries to the No Magic modeling tool folders as part of installing BEE, you may find the libraries there by selecting From predefined location.
- In the Paths to used projects box, navigate to your BEE installation directory and select <BEE_Install>\modelDependencies.
-
In the list of MDZIP files,
select Moxie-STK.mdzip
and click .
Figure B1: Importing the Behavior Execution Engine STK stereotypes
- Close the Used Projects window.
- In the Containment Tree, double-click the Simulation > simulation instance specification.
- Click the cell to the right of Applied Stereotype and then click the button in the upper-right corner of the cell.
-
Search for and select
MoxieStkScenarioFromFile
and then click . -
Select Tags from the left pane of the specification window,
select the
scenarioFilePath
from the center pane, and click . -
Enter the path to the STK scenario specified in the prerequisites for this section (e.g.,
..\UAVMission.vdf
) and click . - Save your work and reinstall the delegate module.
- Execute the simulation
and observe that the STK scenario starts up alongside the SysML simulation
and that the scenario time advances as the simulation time does.
Notice that the UAV in the scenario takes off immediately instead of waiting for the startup procedures in the SysML. You will fix this in the next section by syncing the UAV's behavior between the SysML and STK.
- Close STK without saving.
Next Section >