# How to create a new task?

Please read the iTaSC_Manual first, to get acquainted with the iTaSC terminology and structure. A task is the combination of a virtual_kinematic_chain and a constraint/controller. In the iTaSC software, it is a (ROS-)package that contains:

• src/ containing the source code of the components (C++)
• VKC_taskname.hpp/cpp
• CC_taskname.hpp/cpp
• cpf/ containing the property files for the components and FSM's
• scripts/ containing the FSM's and components in a LUA implementation
• taskname_supervisor.lua: the supervisor orocos-component, containing the Orocos specific code, eg. ports to recieve/send events on...
• taskname_fsm.lua: the finite-state machine containing the actual Skill
• running_taskname_coordination.lua: the sub-finite-state machine of the running state of the task, containing the coordination part of the task, it determines what the task part of the iTaSC algorithm should do and in which order
• running_taskname_fsm.lua: the sub-finite-state machine machine of the running state of the task, determining the actual actions of the task (when to enable the task, when to change weights...)
• launch/ containing eventual ROS launch files

The running_taskname_coordination.lua and running_taskname_fsm.lua, are sub-FSM's of the running state of the task (defined in taskname_fsm.lua). They are executed sequentially, first the coordination part, then the FSM part.

## Getting started

A tasks consists of a Virtual Kinematic Chain (VKC) (except for constraints on joints only) and a Constraint Controller (CC).

### Virtual Kinematic Chain (VKC)

A VKC inherits from VirtualKinematicChain.hpp in the itasc_core unary stack, which serves as a basic template.

Important are the expected reference frames and points for the data on following ports. (o1=object 1, o2= object 2)

• Inputs
• $T_{o1}^{o2}$ = RelPose(o2|o2,o1|o1,o1) = pose of o2 on body o2 wrt. o1 on body o1 expressed in o1
• $_{o1}^{o1}t_{o2}^{o1}$ = RelTwist(o1|o1,o1,o2) = twist with ref.point o1 on object o1 expressed in o1
• Outputs
• $T_{o1}^{o2}$ = RelPose(o2|o2,o1|o1,o1) = pose of o2 on body o2 wrt. o1 on body o1 expressed in o1
• $J_{u}\chi_{u}$ =
• $_{o1}^{o2}J_{f o1}^{o1}$ = Jacobian(o1|o2,o1,o1) = ref.point o1 on object o2 expressed in o1

The expected references are also mentioned as comments in the files

### Constraint/Controller (CC)

A Constraint/Controller inherits from ConstraintController.hpp in the itasc_core unary stack, which serves as a basic template. task_layout

A full template will be made available soon... At the moment, start from an example... Have a look at the keep_distance task-package (in the itasc_comanipulation_demo stack) as a good example of a task. Special cases are:

• cartesian_motion: This task, defines a virtual kinematic chain with in stead of feature coordinates x,y,z,roll, pitch, yaw, the full pose (KDL::Frame), to enhance efficiency of the code (and prevent singularity problems).A separate port, the ChifT port transfers this data from the VKC to the CC, which should be connected manually at the moment!. ChifT = RelPose(o2|o2,o1|o1,o1) = pose of o2 on body o2 wrt. o1 on body o1 expressed in w
• joint_motion: This task has no virtual kinematic chain, because its output equation is y=q. It constrains only the joint coordinates.

## Conventions

To automate the majority of the scripting, the following conventions are taken into account in the examples, which is recommended to do for new tasks too:
• the components and scripts have the task name in their names, eg. for cartesian_motion
• package name: cartesian_motion
• component names: VKC_cartesian_motion.hpp
• script names: cartesian_motion_supervisor.lua
• For conformity it is advised to use lower case names with underscores to separate words