Virtual Instructors and Brains
Let's start by explaining the differences between Virtual Instructors (VI) and Brains. The most basic explanation is that Virtual Instructors should be used on Controlled Entities whereas Brains should be used on Uncontrolled Entities. An easy way to remember this is that if you want to teach somebody, you should use a Virtual Instructor but if you want them to think for themselves, you should use a Brain.
The major difference (technically speaking) is:
1. VI will not run on uncontrolled entities 2. Brains may use only a subset of VI capabilities.
It should also be noted that an entity can contain both a VI and a Brain. This is particularly useful in scenarios where multiple entities can be controlled by different users over a network. You can set each controllable entity to have both so that the scenario can run correctly (i.e. they will each carry out their missions) whether they are controlled or not, switching between VI and Brain as they become controlled.
Here we will create a scenario that uses both. In the scenario, we will have a Hummer on the runway controlled by a Brain. The Trainee will be controlling a Cessna and will be instructed by the Virtual Instructor to wait for the Hummer to leave the runway before taking off.
1. Create a new session with a controlled Cessna and an uncontrolled Hummer1. Right click in the Knowledge Center white space > New > Session.
2. Once in Scenario Editor, right click on the map > New > Cessna. (Perform the same step to add Hummer1. If this entity is not in the list, right click on the map > New > More > Physical > Moving > Ground > Vehicle > Commercial > Hummer > Hummer H1.)
3. Make sure the Cessna is lined up for takeoff and the Hummer is in its line of sight. Also, make sure that your Cessna is on the ground by checking it's Entity Settings as follows: click to highlight the Cessna and go to the Entity Settings window (double click the Cessna entity to bring up the Entity Settings window if it is not already on the screen). Go to the General tab and change the Use AGL height to True and AGL Height to 0.
4. Now with the Cessna still selected, select the Agents tab. Right click in the white box of the Agents tab and select New > Virtual Instructor. We are using a Virtual Instructor here because the Cessna will be our Controlled Entity.
5. Now select the Hummer, go to the Agents tab, right click in the white box of the Agents tab and select New > Brain. We are using a Brain here because the Hummer is an uncontrolled entity.
6. We want to make the Hummer H1 move off the runway when the Cessna sets the parking brake. To add this action to the agent Brain right click on Instructions > Advanced > Call Action > select ACTION_PATH_FOLLOWER_SET_SPEED (check Show hidden tokens box) and set the Value to 0. This way the Hummer will move, just not as soon as the session starts. It will wait to move until the Cessna sets the parking brakes.
7. Create a new step to monitor an attribute on the Cessna. Set this new step to a Traced Entity. Right click on Step 2 > Set Traced Entity and select the Cessna from the list. This is saying that the second step in this agent looks for the Cessna and doesn't actually apply to the Hummer whatsoever. The Cessna will have to satisfy the condition we set before the Hummer H1 agent Brain can move on.
8. Right click on Instructions > Add Flow Control > Continue. Right click on Status > Add Attribute and choose the attribute ATT_AC_ARE_PARKING_BRAKE_ON (check Show hidden tokens box) setting the value to 1 (TRUE) (right click the attribute > Edit). This will check to make sure the Cessna has put on the parking brakes.
The agent should look something like this:
9. Finally we'll add a new step to tell the Hummer to move again. Copy the first step and paste it below the Traced Entity step, changing the value in the action to 20, therefore telling the Hummer to move. Select Step 1 and press Ctrl+C to copy, then select Step 2 and press Ctrl+V to paste a copy of Step 1 below Step 2.
The agent should look something like this:
10. Next we should set a route for the Hummer that will look something like below the picture below. With the Hummer H1 selected, go to the General tab of the Entity Settings window. Click on the blank box next to Route and select <New> from the drop down menu. The Route Editor tool will appear and the cursor will change to the Route Editor. Click on the map to set the Route. When you have finished creating a route that looks like the one below, click the Close button on the Route Editor window.
Route of Hummer H1 1 1 should now show in the box next to Route:
11. Now go back to the Cessna's Virtual Instructor and right click Instructions > Instructional Aids > VI Guidance and enter dialogue telling the trainee to enable their parking brakes. Make sure to check the "Display Continuously" box so that they see the message until they complete it.
12. Next we want to monitor whether the trainee has enabled the brake. Right click on Instructions > Add Flow Control > Continue. Then right click on Status > Add Attribute and choose the attribute ATT_AC_ARE_PARKING_BRAKE_ON (check Show hidden tokens box) setting the value to 1 (right click attribute > Edit).
13. Now right click Continue and add another VI Guidance after the brakes have been set, commending the trainee for the action and telling them to wait for the Hummer to clear the runway before takeoff.
The VI in the Cessna should look something like this:
14. Since we're waiting for the Hummer to leave the runway, we need to monitor an attribute on the Hummer so we'll create a new step and set it to a Traced Entity. Right click on the new step > Set Traced Entity and select the Hummer from the list. As we saw earlier, this step looks for the Hummer and doesn't do anything within the Cessna, just holding the agent until the condition is satisfied. Once it has been done, the Cessna agent can move on.
15. Right click on Instructions > Add Flow Control > Continue. Right click on Status > Add Attribute and select ATT_CURRENT_WAYPOINT_ID (check Show hidden tokens box). If your waypoints correspond to the ones in the picture above, you should set the Value to 3 (right click on the attribute > Edit). Once the Hummer hits Waypoint 2, it changes it's current waypoint to Waypoint 3, therefore by the time it changes to 3 it will be well clear of the runway.
16. After that, we should create a new step so that once we know the Hummer is out of the way, our instructions go back to the Cessna. Right-click on Instructions > Instructional Aids > VI Guidance and add some dialogue telling the trainee that the runway is now clear for takeoff.
The agent should look something like this:
Preview the scenario to make sure the agents are working properly.