Difference between revisions of "Calling Actions in Agents"
|Line 167:||Line 167:|
To speed with an action, the aircraft must be on autopilot (we have turned this on in the previous steps).
Latest revision as of 19:30, 25 April 2013
When calling an action in an agent, you are changing the behavior of the entity in some way. Actions are used to change the behavior in a single entity. Examples include setting the autopilot to on, setting the landing gear down, making the aircraft turn to a certain heading, etc. Below we will briefly outline how to call and action in an agent to change the behavior of an entity.
1. Create a new session with a controlled Cessna. Right click in the Knowledge Center white space > New > Session. Once in Scenario Editor, right click on the map > New > Cessna.
2. Create a new agent for the Cessna. Right click in the white space under the Agents Tab > New > Virtual Instructor.
For this lesson we will have the aircraft perform specific tasks by calling certain actions such as lowering and raising the flaps, switching autopilot on, turning to follow a heading, and decreasing speed.
Lowering and Raising the Flaps
It should be noted that VI Guidance and Timeouts can be added to enhance agent flow and function where they are necessary.
3. To call an action within the agent, right click and select Advanced > Call Action.
4. Select an action that will lower the flaps for you. Type “flaps” in the search text box at the top of the window. Next, make sure that the Show hidden tokens checkbox is marked. Finally, locate the action that will set the flaps down. Select the action and click Add at the bottom of the window.
5. Next, a Do an Action window will appear. For this we don’t have to enter anything in the index or value boxes. Simply press the OK button.
To lower the flaps all the way down, copy and paste this action two more times in the agent. Your agent should look something like this (to add a timeout as shown below right click > Timeout > change duration to a specified time in seconds):
6. Next, to raise the flaps go back to the Select an Action window and select the action to raise the flaps up one step. (Note: “flaps” should already be in the search box, so you won’t have to repeat that step again.)
Again, to raise the flaps all the way up, just copy and paste this action two more times within the agent. It should look something like this:
You can choose to put timeouts between actions, like we have done here, for a smoother transition into the next action. Sometimes the aircraft requires some time to perform the action and a timeout is necessary.
Turn Autopilot On
Next, we would like to turn autopilot on.
7. First, go to the “Select an Action” window and type “ap” in the search box. This will search for all autopilot actions. Make sure that “Show hidden tokens” check box is marked.
8. Locate the action to switch the autopilot on, select it, and click Add at the bottom of the window.
9. When Do an Action window appears, type 1 in the Value box. This is telling the agent to turn the autopilot to True or On. Select OK.
Make the Aircraft Follow a Specific Heading
Now we want to have the aircraft turn toward a specified heading. To do this, first we must know what direction the aircraft is already flying. To view, click on the Entity Settings tab at the bottom of the Agent Editor window, then click on the General tab at the top of the Entity Settings window. Locate the heading information.
To go back to the Agent Editor page, click the tab at the bottom of the window.
10. To make the aircraft follow a certain heading, the autopilot must be set to on (which we have done in the previous steps). Go to the Select and Action window and search for “ap”, making sure the Show hidden tokens check box is marked (however, the window should already have your previous search information saved).
11. Select the action for the autopilot to set the heading. Click Add.
12. In the Do an Action window type your desired heading into the Value box. Let’s have the aircraft turn 180 degrees.
13. Now we have to tell the autopilot to engage in a heading hold. Go back to Select an Action window and select the appropriate action. Again, previous search information should already be entered for you.
14. When the Do an Action window appears, type in 1 in the Value box. This is telling the autopilot to engage in the heading hold. Your agent should look something like this now:
Your agent should look something like this now:
To increase speed with an action, the aircraft must be on autopilot (we have turned this on in the previous steps).
15. Go to Select an Action window, and select the action for the autopilot to set the speed. Again, the window should have your search preferences saved for “ap”.
16. In the Do an Action window, enter the desired speed for the aircraft. From the entity settings we saw earlier, we know we are traveling at 100 knots.
We would like to increase our speed to 110 knots. Enter this in the Value box.
17. Then, as with the heading hold, we want the autopilot to engage in a speed hold. Select the appropriate action from the list and type 1 in the Value box to engage the autopilot in a speed hold.
Your agent should look something like this:
Remember, we only added arbitrary timeouts in between actions. You can choose where to place timeouts and their duration depending on your scenario (for instance, in this scenario, the aircraft will take a long time to reach a speed of 110 knots so we added a long timeout).
18. The final step should be to test your agent by playing it in the Scenario Editor.