Table of Contents
Example: Behavior Developer - Realizing Tasks
This tutorial explains how a behavior developer models task plots. Task plots are independent from a particular robot and they can be executed with any robot that possesses the required skills. The tutorial explains the role of the behavior developer by the example of box transportation by a mobile robot.
Basic Information
Level | Beginner |
---|---|
Role | behavior developer |
Assumptions | You know how to develop a software component |
System Requirements | Virtual Appliance installed, see ready-to-go virtual appliance |
You will learn | - how to … - how to … - how to … |
Options | - … |
Introduction
Tasks describe via which steps (what: the ordering of steps) and in which manner (how: the kind of execution) to accomplish a particular job. This is done in abstract manner independent from a particular robot as tasks refer to skills for their grounding. Behavior developer models the task plots and ground them in domain-specific skill definitions. Task plots are modeled by a behavior developer in a behavior project. The link between tasks/skills and skills/components instances on the robot are setup by the system builder in the system project.
In this tutorial, we show how to create a behavior project and how to realize the tasks. Finally, we walk you through the tasks realized in the behavior project BehaviorRobotinoBoxTransportationTasks.
Implementing Tasks in a Behavior Project
Part 1: Creating a Behavior Project
For working with behavior projects, we first need to open the Behavior Developer (Tier 3) view.
Start by clicking on File → New → Behavior Project (Tier 3).
Now click Create Folder.
Enter BehaviorExampleProject as the folder name and click Create.
Select the created folder.
Verify the project name and the location of the behavior project. If it is fine, press Finish.
Now you can see the newly created behavior project in the workspace.
Part 2: Realizing the Tasks
The steps included in the task realization are as following:
Step 1: Import the Required Domain Models
We need to import the required domain models into the behavior project. Right-click on the imports folder and select Manage Project Imports.
Now you see the set of domain models that are available in your workspace. Select the required domains as indicated in the figure below:
Step 2: List the Required Coordination Modules
Required coordination modules have to be listed in the taskRealization
file and instantiated abstractly. Abstract instantiation because we use the skills defined in the coordination modules and behavior developer doesn't have to know details about the skill realization.
Example taskRealization
file of BehaviorRobotinoBoxTransportationTasks is shown below:
In task realization, skills available in the coordination modules are accessed using the names for abstract coordination module instances. For example, we call the skill approachLocation defined in CommNavigationObjects.NavigationModule like navigation.approachLocation where navigation is the abstract instance of CommNavigationObjects.NavigationModule.
Note: In the editor, press Ctrl + Space to view the possible keywords and also for auto completion. The keyword Name-ID indicates that user have to give an identifier name.
Step 3: Realize the Tasks
Tasks are realized in smartTcl
files using the task coordination language SmartTCL. Tasks are realized as task coordination blocks using realize-tcb. These task blocks plan the appropriate action depending on the current context of the situation.
Tasks can also update the current context information with the results from skills.
You can organize your realizations into multiple smartTcl
files.
Below figure shows the realization of tasks driveToStation and dockToMPSStation in the BehaviorRobotinoBoxTransportationTasks
.
Task Realization by the Example of BehaviorRobotinoBoxTransportationTasks
Behavior for the following scenario is implemented in BehaviorRobotinoBoxTransportationTasks
.
Scenario:
- Robot drives and docks to any station.
- Robot delivers/collects a box to/from the station.
- Robot undocks from the station after delivery/collecting robot.
Details about robot and stations
- Robot is equipped with a conveyor belt and can carry a small load carrier box.
- MPS stations are equipped with conveyor belt and have OPCUA communication interface.
- Passive stations can only receive box from robot with out any communication.
This scenario is implemented in system project SystemWebotsNavMpsDockingOPCUA. This system implements the mentioned scenario in webots. You can run this system to check the behavior in live.
Step 1: Import the Required Domain Models
As you can see in the below figure, the four domain models CommBasicObjects, CommLocalizationObjects, CommNavigationObjects, CommRobotinoObjects are imported into BehaviorRobotinoBoxTransportationTasks
project.
Step 2: List the Required Coordination Modules
Below code lists the BehaviorRobotinoBoxTransportationTasks.taskRealization
file. It shows the coordination modules and their abstract instances.
TaskRealizationModel BehaviorRobotinoBoxTransportationTasks { AbstractCoordinationModuleInstance navigation coordModuleDef CommNavigationObjects.NavigationModule AbstractCoordinationModuleInstance kbModInst coordModuleDef CommBasicObjects.KBModule AbstractCoordinationModuleInstance localizationModInst coordModuleDef CommLocalizationObjects.LocalizationModule AbstractCoordinationModuleInstance base coordModuleDef CommNavigationObjects.MobileBaseModule AbstractCoordinationModuleInstance MPS coordModuleDef CommRobotinoObjects.MPSModule }
BehaviorRobotinoBoxTransportationTasks uses skills available from the 5 listed coordination modules. Here navigation is the abstract instance of the coordination module CommNavigationObjects.NavigationModule. MPSModule provides the skills related docking and conveyor belt.
Step 3: Realize the Tasks
As mentioned before, task realizations are done in smartTcl
files. Here we have three smartTcl
files.
BehaviorRobotinoBoxTransportationTasks.smartTcl
contains the task realizations driveToStation, dockToMPSStation, unloadTo, undockFromMPSStationkb.smartTcl
contains the knowledge base updates, that is updates about the location of stations and their attributes like station type and docking type.startUp.smartTcl
displays the available tasks via a menu and prompts the user for selection and executes the selected tasks.
The following code listings shows the different tasks realized in BehaviorRobotinoBoxTransportationTasks.smartTcl
.
Below code listing shows the task deliverBoxToStation. It takes the station id, belt id as input and calls sequentially the tasks driveToStation, dockToMPSStation, unloadTo, undockFromMPSStation.
;;----------------------------------------------------------------------------------------------------- ;; deliverBoxToStation ;; input<number, number > 0> ;;----------------------------------------------------------------------------------------------------- (realize-tcb (deliverBoxToStation ?stationId ?beltId) (action ( (format t "deliverBoxToStation: stationId, betlId ~s, ~s ~%" '?stationId '?beltId) )) (plan ( (driveToStation ?stationId) (dockToMPSStation ?stationId ?beltId) (unloadTo ?stationId) (undockFromMPSStation) )) )
Below code listing shows the task collectBoxFromStation. It takes the station id, belt id as input and and calls sequentially the tasks driveToStation, dockToMPSStation, loadFrom, undockFromMPSStation.
;;----------------------------------------------------------------------------------------------------- ;; collectBoxFromStation ;; ;; input<number, number > 0> ;;----------------------------------------------------------------------------------------------------- (realize-tcb (collectBoxFromStation ?stationId ?beltId) (action ( (format t "collectBoxFromStation: stationId, betlId ~s, ~s ~%" '?stationId '?beltId) )) (plan ( (driveToStation ?stationId) (dockToMPSStation ?stationId ?beltId) (loadFrom ?stationId) (undockFromMPSStation) )) )
Below code listing shows the task driveToStation. It takes the station id as input and queries the knowledge about the approach location of the station and drives robot to the station by using the skills from navigation and localization modules.
(realize-tcb (driveToStation ?stationId) (action ( (format t "driveToStation ~s ~%" '?stationId) (let* ( (station (tcl-kb-query :key '(is-a id) :value '( (is-a station) (id ?stationId)))) (goal (get-value station 'approach-location)) ) (format t "goal name ~s ~%" goal) (tcl-push-back-plan :plan `( (localizationModInst.tcb-activate-localization) (navigation.approachLocation ,goal) (localizationModInst.tcb-deactivate-localization) ) ) ) )) )
Below code listing shows the tasks dockToMPSStation and undockFromMPSStation. Both these tasks use the skills from MPS module to dock and undock from station.
;; task dockToMPSStation (realize-tcb (dockToMPSStation ?stationId ?beltId) (action ( (format t "dockToMPSStation: stationId, betlId ~s, ~s ~%" '?stationId '?beltId) )) (plan ( (MPS.tcb-mps-station-dock ?stationId ?beltId) )) ) ;; task undockFromMPSStation (realize-tcb (undockFromMPSStation) (action ( (format t "undockFromMPSStation~%") )) (plan ( (MPS.tcb-mps-station-undock-mps) )) )
Below code listing show the tasks unloadTo and loadfrom which uses the skills from MPS module to control conveyor belt.
;; task unloadTo (realize-tcb (unloadTo ?stationId) (action ( (format t "unloadTo ~s~%" '?stationId) )) (plan ( (MPS.tcb-mps-station-unload-belts ?stationId) )) ) ;; task loadFrom (realize-tcb (loadFrom ?stationId) (action ( (format t "loadFrom ~s~%" '?stationId) )) (plan ( (MPS.tcb-mps-station-load-belts ?stationId) )) )
What to do next?
«to be added»