> For the complete documentation index, see [llms.txt](https://support.robominds.de/manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.robominds.de/manual/robobrain.skills/lab-automation/sample-tube-detection-skill.md).

# Sample Tube Detection Skill

Medical Sample Tube Handling

## Overview <a href="#user-content-overview" id="user-content-overview"></a>

This skill enables the detection and sorting of sample tubes standing in a rack according to size and color. It uses a two-finger parallel gripper so that it can grip the sample tubes properly. This information needs to be stored in the skill, because the collision analysis with the corresponding tubes is examined. This ensures that no damage occurs to other tubes when samples are picked up. The optimal gripping candidate is displayed with a blue axis in the image - further candidates are drawn in yellow on the tube and detected collisions are marked with a red line. The selected gripping axis of the AI Skill is displayed next to the detected cap color (marked with a circle), as well as the position and orientation are displayed as usual in the Web GUI. This information can be used during process development to sort the tubes by color and/or cap diameter. A very clear application example can be found on the [application](https://support.robominds.de/robobrain-applications/medical-applications/sample-tube-handling) page.

<table data-card-size="large" data-view="cards"><thead><tr><th></th></tr></thead><tbody><tr><td><img src="https://1459495663-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzRF3SV87vu3nkNgfjyt7%2Fuploads%2FPyhFnyt3VWG4dsagkQiG%2FBildschirm%C2%ADfoto%202022-11-29%20um%2015.44.24.png?alt=media&amp;token=dbd6f486-280d-4e9f-8d6c-874bfc9212a6" alt="" data-size="original"></td></tr><tr><td></td></tr><tr><td></td></tr></tbody></table>

## Skill Result Information

| *<mark style="color:blue;">**Position**</mark>*                                                                                                                     | Position of the grasp point relative to the robot’s coordinate system *(in m)* |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| <mark style="color:blue;">**Orientation**</mark>                                                                                                                    | Rotation of the grasp point relative to the robot’s coordinate system *(in m)* |
| <mark style="color:blue;">**Width**</mark>                                                                                                                          | Determined grip width *(in m)*                                                 |
| <p><mark style="color:blue;"><strong>Color Information</strong></mark> </p><p><mark style="color:blue;">(Red, Pink, Blue, Yellow, Purple, Orange, Green)</mark></p> | Indicates the number of detected samples by color.                             |

## Specifications

<table data-view="cards"><thead><tr><th align="center"></th><th></th><th></th><th></th><th></th><th data-type="files"></th></tr></thead><tbody><tr><td align="center"><mark style="color:blue;"><strong>Conditions</strong></mark></td><td><p><strong>Camera mount:</strong> </p><ul><li>Dynamic</li><li>Static</li></ul></td><td><p><strong>Supported colors:</strong> </p><ul><li>Blue</li><li>Orange</li><li>Green</li><li>Pink</li><li>Yellow</li><li>Purple</li><li>Red</li><li>colors can be adjusted</li></ul></td><td></td><td></td><td></td></tr><tr><td align="center"><mark style="color:blue;"><strong>Specs</strong></mark></td><td><p><strong>Avg. recognition time:</strong></p><p>&#x3C; 2 seconds</p></td><td><p></p><p><strong>Supported grippers:</strong></p><ul><li>Parallel</li></ul><p></p></td><td></td><td></td><td></td></tr><tr><td align="center"><mark style="color:blue;"><strong>Features</strong></mark></td><td><ul><li>Measures</li><li>Collision detection</li><li>Multiple instance recognition</li><li>Color detection</li></ul></td><td></td><td></td><td></td><td></td></tr></tbody></table>

## Technical Parameter Description <a href="#user-content-parameters" id="user-content-parameters"></a>

### Parameter

{% tabs %}
{% tab title="Basic" %}

<table data-view="cards"><thead><tr><th>Name</th><th>Parameter</th><th>Type</th><th>Description </th></tr></thead><tbody><tr><td><mark style="color:blue;"><strong>Minimum instance quality</strong></mark></td><td><code>min_score</code></td><td><code>float</code></td><td>Minimum allowed quality score for detected masks, allows to filter out detections with poor confidence. The impact of this parameter can differ between AI models.</td></tr><tr><td><mark style="color:blue;"><strong>Finger dimensions along grasp axis</strong></mark></td><td><code>finger_on_axis</code></td><td><code>float</code></td><td>The finger dimension along the grasp axis. This value should be adapted to the geometry of the gripper.</td></tr><tr><td><mark style="color:blue;"><strong>Finger dimensions perpendicular to grasp axis</strong></mark></td><td><code>finger_off_axis</code></td><td><code>float</code></td><td> The finger dimension perpendicular the grasp axis. This value should be adapted to the geometry of the gripper.</td></tr></tbody></table>
{% endtab %}

{% tab title="Advanced" %}

<table data-view="cards"><thead><tr><th>Name</th><th>Parameter</th><th>Type</th><th>Description </th></tr></thead><tbody><tr><td><mark style="color:blue;"><strong>Selection of the class ID for detections</strong></mark></td><td><code>det_cls</code></td><td><code>int</code></td><td>Used to select a specific class ID for detections, detections with other class IDs are rejected. Valid IDs differ between models. The default value of -1 enables all classes.</td></tr><tr><td><mark style="color:blue;"><strong>Z offset</strong></mark></td><td><code>grasp_depth</code></td><td><code>float</code></td><td>Offset for the z-component of the pick position</td></tr><tr><td><mark style="color:blue;"><strong>Grasp safety</strong></mark></td><td><code>grasp_safety</code></td><td><code>float</code></td><td>An offset for the grasp to avoid collisions between the gripper and the detected item.</td></tr><tr><td></td><td><code>depth_safety</code></td><td><code>float</code></td><td>The minimum distance between gripper fingers and items below. This parameter is used to improve the robustness of collision detection.</td></tr></tbody></table>
{% endtab %}

{% tab title="Expert" %}

<table data-view="cards"><thead><tr><th>Name</th><th>Parameter</th><th>Type</th><th>Description </th></tr></thead><tbody><tr><td><mark style="color:blue;"><strong>Optimize gripper orientation</strong></mark></td><td><code>orientation_optimization</code></td><td><code>boolean</code></td><td>Enables the optimization of the gripper orientation. If enabled the pick pose might be rotated by 180° around the approach axis to minimize the robot rotation between the capture and pick pose.</td></tr><tr><td><mark style="color:blue;"><strong>Enforce GPU usage</strong></mark></td><td><code>force_gpu</code></td><td><code>boolean</code></td><td>Enforces GPU usage for this skill (could disable GPU usage for other skills or cause performance problems.)</td></tr></tbody></table>

{% endtab %}
{% endtabs %}

### Detections <a href="#user-content-detections" id="user-content-detections"></a>

{% tabs %}
{% tab title="Detection Data" %}

<table data-view="cards"><thead><tr><th>Type</th><th>Description </th></tr></thead><tbody><tr><td><code>pose (Transformation)</code></td><td>Pick pose for the gripper</td></tr><tr><td><code>name (str)</code></td><td>Color name for the detected test tube</td></tr><tr><td><code>width (float)</code></td><td>Grasp width in meters</td></tr><tr><td><code>optimization_angle (float)</code></td><td><p>Only present if the parameter <code>optimization_orientation</code> is set to <code>true</code>. The parameter represents the rotation angle in radians that was applied to the original pick pose during the orientation-optimization step.</p><p></p></td></tr></tbody></table>
{% endtab %}

{% tab title="Detection Example" %}

```json
{
   "detections":[
      {
         "pose":{
            "x":0.6145409329603989,
            "y":0.09682438372366545,
            "z":0.10360639091658985,
            "rx":2.2222372377952695,
            "ry":-2.214357666997158,
            "rz":-0.004698571812545857
         },
         "name":"yellow",
         "width":0.015374991561322313,
         "optimization_angle":3.141592653589793
      },
      {
         "pose":{
            "x":0.554295630508419,
            "y":0.09012328001514235,
            "z":0.10321849191189486,
            "rx":3.140556914653469,
            "ry":0.0055777552572537584,
            "rz":-0.008253606361946325
         },
         "name":"yellow",
         "width":0.014528973723174538,
         "optimization_angle":0
      },
      {
         "pose":{
            "x":0.6302398797015747,
            "y":0.17146716163043885,
            "z":0.10264205621904898,
            "rx":2.2222372377952695,
            "ry":-2.214357666997158,
            "rz":-0.004698571812545857
         },
         "name":"yellow",
         "width":0.014747326767504957,
         "optimization_angle":3.141592653589793
      },
      {
         "pose":{
            "x":0.6022476212609216,
            "y":0.2236774987646027,
            "z":0.10273539505829354,
            "rx":1.2053719651687358,
            "ry":-2.8954695356147706,
            "rz":-0.0016765806551285582
         },
         "name":"yellow",
         "width":0.01499004842430013,
         "optimization_angle":3.141592653589793
      },
      {
         "pose":{
            "x":0.6019005622736526,
            "y":0.012039303373761953,
            "z":0.1028196777604114,
            "rx":2.2222372377952695,
            "ry":-2.214357666997158,
            "rz":-0.004698571812545857
         },
         "name":"yellow",
         "width":0.015892630577808962,
         "optimization_angle":3.141592653589793
      },
      {
         "pose":{
            "x":0.5555925616315368,
            "y":0.14272252821836318,
            "z":0.10284453732413362,
            "rx":2.2222372377952695,
            "ry":-2.214357666997158,
            "rz":-0.004698571812545857
         },
         "name":"yellow",
         "width":0.014663657207579457,
         "optimization_angle":3.141592653589793
      },
      {
         "pose":{
            "x":0.5066171778962555,
            "y":0.2240279069153301,
            "z":0.1016165267518,
            "rx":2.2222372377952695,
            "ry":-2.214357666997158,
            "rz":-0.004698571812545857
         },
         "name":"yellow",
         "width":0.014876680311358317,
         "optimization_angle":3.141592653589793
      },
      {
         "pose":{
            "x":0.555308754649743,
            "y":0.19740507048815037,
            "z":0.10128248533337159,
            "rx":2.2222372377952695,
            "ry":-2.214357666997158,
            "rz":-0.004698571812545857
         },
         "name":"yellow",
         "width":0.014899894792458119,
         "optimization_angle":3.141592653589793
      },
      {
         "pose":{
            "x":0.5068095330084937,
            "y":0.01185610293564375,
            "z":0.1013969234446887,
            "rx":2.2222372377952695,
            "ry":-2.214357666997158,
            "rz":-0.004698571812545857
         },
         "name":"yellow",
         "width":0.015083496103425707,
         "optimization_angle":3.141592653589793
      },
      {
         "pose":{
            "x":0.5552590444181779,
            "y":0.03712797867170671,
            "z":0.10105548803688441,
            "rx":3.140556914653469,
            "ry":0.0055777552572537584,
            "rz":-0.008253606361946325
         },
         "name":"yellow",
         "width":0.014684994767743908,
         "optimization_angle":0
      },
      {
         "pose":{
            "x":0.5066545621296945,
            "y":0.0637386343473891,
            "z":0.10117793585113916,
            "rx":2.2222372377952695,
            "ry":-2.214357666997158,
            "rz":-0.004698571812545857
         },
         "name":"yellow",
         "width":0.014914755964477305,
         "optimization_angle":3.141592653589793
      },
      {
         "pose":{
            "x":0.5064709823987816,
            "y":0.1715223530991371,
            "z":0.10083676982876999,
            "rx":2.2222372377952695,
            "ry":-2.214357666997158,
            "rz":-0.004698571812545857
         },
         "name":"yellow",
         "width":0.015295681895334753,
         "optimization_angle":3.141592653589793
      }
   ]
}
```

{% endtab %}
{% endtabs %}
