tutorials:tier-3-behavior-developer-tasks:start

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.

  1. TaskRealizationModel BehaviorRobotinoBoxTransportationTasks {
  2. AbstractCoordinationModuleInstance navigation coordModuleDef CommNavigationObjects.NavigationModule
  3. AbstractCoordinationModuleInstance kbModInst coordModuleDef CommBasicObjects.KBModule
  4. AbstractCoordinationModuleInstance localizationModInst coordModuleDef CommLocalizationObjects.LocalizationModule
  5. AbstractCoordinationModuleInstance base coordModuleDef CommNavigationObjects.MobileBaseModule
  6. AbstractCoordinationModuleInstance MPS coordModuleDef CommRobotinoObjects.MPSModule
  7. }

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, undockFromMPSStation
  • kb.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.

  1. ;;-----------------------------------------------------------------------------------------------------
  2. ;; deliverBoxToStation
  3. ;; input<number, number > 0>
  4. ;;-----------------------------------------------------------------------------------------------------
  5. (realize-tcb (deliverBoxToStation ?stationId ?beltId)
  6. (action (
  7. (format t "deliverBoxToStation: stationId, betlId ~s, ~s ~%" '?stationId '?beltId)
  8. ))
  9. (plan (
  10. (driveToStation ?stationId)
  11. (dockToMPSStation ?stationId ?beltId)
  12. (unloadTo ?stationId)
  13. (undockFromMPSStation)
  14. ))
  15. )

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.

  1. ;;-----------------------------------------------------------------------------------------------------
  2. ;; collectBoxFromStation
  3. ;; ;; input<number, number > 0>
  4. ;;-----------------------------------------------------------------------------------------------------
  5. (realize-tcb (collectBoxFromStation ?stationId ?beltId)
  6. (action (
  7. (format t "collectBoxFromStation: stationId, betlId ~s, ~s ~%" '?stationId '?beltId)
  8. ))
  9. (plan (
  10. (driveToStation ?stationId)
  11. (dockToMPSStation ?stationId ?beltId)
  12. (loadFrom ?stationId)
  13. (undockFromMPSStation)
  14. ))
  15. )

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.

  1. (realize-tcb (driveToStation ?stationId)
  2. (action (
  3. (format t "driveToStation ~s ~%" '?stationId)
  4.  
  5. (let* (
  6. (station (tcl-kb-query :key '(is-a id) :value '( (is-a station) (id ?stationId))))
  7. (goal (get-value station 'approach-location))
  8. )
  9.  
  10. (format t "goal name ~s ~%" goal)
  11.  
  12. (tcl-push-back-plan :plan
  13. `(
  14. (localizationModInst.tcb-activate-localization)
  15. (navigation.approachLocation ,goal)
  16. (localizationModInst.tcb-deactivate-localization)
  17. )
  18. )
  19. )
  20. ))
  21. )

Below code listing shows the tasks dockToMPSStation and undockFromMPSStation. Both these tasks use the skills from MPS module to dock and undock from station.

  1. ;; task dockToMPSStation
  2. (realize-tcb (dockToMPSStation ?stationId ?beltId)
  3. (action (
  4. (format t "dockToMPSStation: stationId, betlId ~s, ~s ~%" '?stationId '?beltId)
  5. ))
  6. (plan (
  7. (MPS.tcb-mps-station-dock ?stationId ?beltId)
  8. ))
  9. )
  10.  
  11. ;; task undockFromMPSStation
  12. (realize-tcb (undockFromMPSStation)
  13. (action (
  14. (format t "undockFromMPSStation~%")
  15. ))
  16. (plan (
  17. (MPS.tcb-mps-station-undock-mps)
  18. ))
  19. )

Below code listing show the tasks unloadTo and loadfrom which uses the skills from MPS module to control conveyor belt.

  1. ;; task unloadTo
  2. (realize-tcb (unloadTo ?stationId)
  3. (action (
  4. (format t "unloadTo ~s~%" '?stationId)
  5. ))
  6. (plan (
  7. (MPS.tcb-mps-station-unload-belts ?stationId)
  8. ))
  9. )
  10.  
  11. ;; task loadFrom
  12. (realize-tcb (loadFrom ?stationId)
  13. (action (
  14. (format t "loadFrom ~s~%" '?stationId)
  15. ))
  16. (plan (
  17. (MPS.tcb-mps-station-load-belts ?stationId)
  18. ))
  19. )

What to do next?

:!: «to be added»

Acknowledgements

tutorials/tier-3-behavior-developer-tasks/start.txt · Last modified: 2022/12/23 11:06 by 127.0.0.1

DokuWiki Appliance - Powered by TurnKey Linux