# Tasks

AlignPlus tasks are automatically generated by configuration wizard based on configurations of calibration, feature finder, and alignment components. Here is an example of configuration wizard and its generated tasks.

- configuration wizard Configuration

- Tasks generated by configuration above

Each component in configuration wizard will result in the generation of one or more tasks after configuration wizard finishes running. The names of those tasks have certain relationships with their corresponding component names.

Component | Generated Task | Task Example | Task Function | Task Trigger Mode
--- | --- | --- | --- | ---
hand-eye calibration | <Calibration Name>_Loop | HECalib_Loop | The purpose of this task is to generate various motion device poses for the purpose of hand-eye calibration, and at each pose to call the <Calibration Name>_ComputeCalibResults task. This task is only generated when Vision System Guided option is checked on in the stage device in configuration wizard | Manually or by external command
<Calibration Name>_ComptueCalibResults | HECalib_ComptueCalibResults | Move the motion device if necessary, capture images, extract features and accumulate features of calibration target at each stage pose and finally run calibration calculation. | Manually, by external command, or by hand-eye calibration loop task.
General Calibration( Manual Calibration, Checkerboard Calibration , or Cross Calibration) | <Calibration Name> | CrossCalib | Capture images at each acquisition position, and then extract features and run calibration. | Manually, by external command
Finder | <Finder Name>_<Connected Calibration Name> | Features0_CrossCalib | This task captures all the images needed to find the features on a part and locates all the features by running feature finders. This task can run during train time or run time. | Manually, by external command
Alignment | <Alignment Name> | Alignment0 | Compute the alignment pose for the motion device to achieve the desired assembly characteristics. This task is executed after the tasks that locate the features on the part are executed. | Manually, by external command
Hand-eye Calibration | <Calibration Name>_MotionAnalysisPoseGenerator | HECalib_MotionAnalysisPoseGenerator | Motion analysis tasks are used to conduct various tests of the motion device. The purpose of this task is to generate the various motion device poses for the purpose of testing, and at each pose to call the <Calibration Name>_MotionAnalysis task. | Manually
<Calibration Name>_MotionAnalysis | HECalib_MotionAnalysis | This task moves the motion devices, acquires the images, extracts and accumulates features and stage poses, and computes the results using the accumulated data. | Called by Motion Analysis Pose Generator task

Note: When an application that controls the motion device during calibration is generated by selecting the Vision System Guided option, during hand-eye calibration, the PLC has to send commands that execute the tasks that perform "looping". This task calls the <Calibration Name>_ComputeCalibResults task. If the Vision System Guided option is not selected, the PLC has to send commands that execute the <Calibration Name>_ComputeCalibResults task. This condition also applies to tasks that perform motion analysis.

## Task Execution Mode

The various vision tasks in the application serve various purposes. Vision tasks can be generated to perform hand-eye calibration, cross-calibration, extract features on parts, to compute alignment parameters, etc. Each task can be executed to perform specific type of actions. Tasks can be executed in various modes. For example, in application that employ a single camera to capture two images of non-overlapping image regions on a single part, the task can be executed to acquire images of a part at a first position, and then it can be executed to acquire images of the part at a second position and to use both the images to locate features. Largely each vision task can be executed in three modes.

- Acquire Only
- Acquire and Process
- Process Image.

The execution mode is defined in the command string that external device sends to the vision system.

## StepID

StepIDs are automatically defined when the application is generated by the configuration wizard. They can be found at the top of CommandHandler script.

For sample application above, the automatically generated StepIDs are as follow:

- Hand-eye calibration loop task's step ID is 0
- Hand-eye calibration ComputeCalibResult task's step ID is 1
- Cross calibration task has three StepIDs since it has three different image acquisition positions. Accordingly, external devices should call this task three times with different StepIDs and different execution modes to finish cross calibration process.
- Features0 has two StepIDs since it acquires images at two different positions. It should be called two times with different StepIDs during train-time and run-time.
- Alignment0 has one StepID, 7
- Motion analysis tasks have stepIDs 8 and 9.

### EncodedID

EncodedID is part of command string that external device sends to the vision system to run a task. It contains StepID of requested task, as well as the task execution mode:

1. Acquire Only

In this mode, EncodedID = StepID + 1000.

2. Acquire and Process

In this mode, EncodedID = StepID

3. Process Only

In this mode, EncodedID = StepID + 2000.

This table summarizes the various vision tasks that can be performed by the sample application:

Category | Task | StepID | Action | EncodedID
--- | --- | --- | --- | ---
Calibration | HECalib_Loop | 0 | Only one command with Process Image action to trigger hand-eye calibration loop, then the loop will take control the rest of process | 2000
CrossCalib | 2 | First command to Acquire Image at position 0 | 1002
3 | Second command to Acquire Image at position 1 | 1003
4 | Third command to Acquire Image and Process at position 2 | 4
Train Time | Features0_CrossCalib | 5 | First command to Acquire Image at position 0 | 1005
6 | Second command to Acquire Image and Process at position 1 | 6
Run Time | Features0_CrossCalib | 5 | First command to Acquire Image at position 0 | 1005
6 | Second command to Acquire Image and Process at position 1 | 6
Alignment0 | 7 | One command to Process Image | 2007