プログラム例 5.1

例タイプ:
平面プラットフォーム - PF_Feederコールバック関数での振動制御

構成

  • ロボットの数:1
  • フィーダーの数:1
  • フィーダー上のパーツの種類数:1
  • 配置場所の数:1
  • プラットフォーム種類: 平面
  • ピックエリア:領域 B
  • カメラの向き:固定下向きカメラ


解説
この例では、標準の平面プラットフォームが使用されています。平面プラットフォームを使用する場合、通常はメニュー - [ツール] - [パーツフィーディング] - [パーツ] - [振動]の[システムで振動制御]ボタンを選択します。
この例では、[PF_Feeder callbackで振動制御]を選択し、振動処理を独自に記述する方法を紹介します。ユーザーの振動処理は、PF_Feederコールバック関数内で実行されます。 システムが提供する振動処理とは異なる振動処理が必要な場合は、[PF_Feeder callbackで振動制御]を選択します。 カスタムプラットフォーム(穴, 溝, ポケットなど)を使用する場合は、PF_Feederコールバック関数を介して振動を自分で処理する必要があります。
詳細は、以下を参照してください。
プログラム例 5.2

[PF_Feeder callbackで振動制御]が選択されている場合(平面, 貼りつき防止, 転がり防止の各標準プラットフォーム)でも、システムは、さまざまな状況でのパーツの最も適切な処理を判断します。 判断結果は、引数 “state” を介してPF_Feederコールバック関数に提供されます。 さまざまな状態の定数値が “PartFeeding.inc” ファイルに定義されています。
たとえば、定数”PF_FEEDER_PICKOK”は、パーツのロボットによるピックプレースが可能となったことを意味します。 別の例として、システムがパーツを反転するのが最善の処理であると判断したときに、定数 “PF_FEEDER_FLIP” がPF_Feeder コールバック関数に渡されます。 引数“state”の値をどのように扱うかは、ユーザーに委ねられます。

概念的には、ユーザーは、PF_Feederコールバック関数の引数“state”と、適切なフィーダー制御コマンドを使用して、システム処理を再作成することができます。繰り返しになりますが、平面プラットフォームの場合は、通常は、[システムで振動制御]を選択します。つまり、この例では、PF_Feederコールバック関数とフィーダー制御コマンドを使用して、システム処理を模倣する方法を示しています。

サンプルコード
Main.prg

Function main
    If Motor = Off Then
        Motor On
    EndIf
    Power Low
    Jump Park
    PF_Start 1
Fend

PartFeeding.prg

Function PF_Robot(PartID As Integer) As Integer
    Do While PF_QueLen(PartID) > 0
        P0 = PF_QueGet(PartID)
        Jump P0
        On Gripper; Wait 0.2
        Jump Place
        Off Gripper; Wait 0.2
        PF_QueRemove PartID
        If PF_IsStopRequested(PartID) = True Then
            Exit Do
        EndIf
    Loop
    PF_Robot = PF_CALLBACK_SUCCESS

Fend

Function PF_Feeder(PartID As Integer, NumFrontParts As Integer, NumBackParts As Integer, state As Integer) As Integer

    Select state

        ' OK to Pick
        Case PF_FEEDER_PICKOK
             ' Call PF_Robot because there are parts ready to pick
            PF_Feeder = PF_CALLBACK_SUCCESS

         ' Supply more parts
        Case PF_FEEDER_SUPPLY
            PFControlReturnVal = PF_Control(PartID, PF_CONTROL_SUPPLY_FIRST)
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Parts are spread out but need to be flipped
         Case PF_FEEDER_FLIP
            PF_Flip PartID
            ' Restart and re-acquire images
            PF_Feeder = PF_CALLBACK_RESTART

        ' Shift parts into pick region
        Case PF_FEEDER_SHIFT
            PF_Shift PartID, PF_SHIFT_FORWARD
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Center, Flip and Separate
        Case PF_FEEDER_CENTER_FLIP
            PF_Center PartID, PF_CENTER_LONG_AXIS
            PF_Center PartID, PF_CENTER_SHORT_AXIS
            PF_Flip PartID
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Hopper is empty
        Case PF_FEEDER_HOPPER_EMPTY
            PFStatusReturnVal = PF_Status(PartID, PF_STATUS_NOPART)
            PFControlReturnVal = PF_Control(PartID, PF_CONTROL_SUPPLY_FIRST)
            ' Center, Flip and Separate
            PF_Center PartID, PF_CENTER_LONG_AXIS
            PF_Center PartID, PF_CENTER_SHORT_AXIS
            PF_Flip PartID
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Parts have gathered against the platform wall
        Case PF_FEEDER_SHIFT_BACKWARDS
            PF_Shift PartID, PF_SHIFT_BACKWARD
            PF_Feeder = PF_CALLBACK_RESTART

        ' Hopper Supply, Center, Flip and Separate
        Case PF_FEEDER_SUPPLY_CENTER_FLIP
            PFControlReturnVal = PF_Control(PartID, PF_CONTROL_SUPPLY)
            PF_Center PartID, PF_CENTER_LONG_AXIS
            PF_Center PartID, PF_CENTER_SHORT_AXIS
            PF_Flip PartID
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Too many parts
        Case PF_FEEDER_TOO_MANY
            PFStatusReturnVal = PF_Status(PartID, PF_STATUS_TOOMANYPART)
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Wrong part
        Case PF_FEEDER_WRONGPART
            PFStatusReturnVal = PF_Status(PartID, PF_STATUS_WRONGPART)
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

    Send

Fend