Main Content

Unreal Editor でのアクターへのカメラの配置

Unreal® Editor のシーンでオブジェクトを可視化するために、シーン内の静的アクターまたはカスタム アクターにカメラを配置できます。開始するには、Vehicle Dynamics Blockset Interface for Unreal Engine Projects サポート パッケージが必要です。サポート パッケージのインストールと環境の構成を参照してください。

このワークフローに従うには、Unreal Engine® に関する知識が必要です。Visual Studio® 2022 がコンピューターにインストールされていることを確認してください。

静的アクターへのカメラの配置

次の手順に従って、Unreal Editor で、コーンからオフセットされた位置に Simulation 3D Camera Get ブロックを配置します。この例では Computer Vision Toolbox™ の To Video Display ブロックを使用しますが、別の可視化ブロックを使用してイメージを表示できます。

  1. Simulink® モデルに、Simulation 3D Scene ConfigurationSimulation 3D Camera Get、および To Video Display の各ブロックを追加します。

    Simulink model with blocks

    ブロック パラメーターを次のように設定します。Simulation 3D Scene Configuration ブロックで、[Unreal Editor を開く] を選択します。

    ブロックパラメーター設定

    Simulation 3D Scene Configuration

    • シーン ソースUnreal Editor

    • プロジェクト — サポート パッケージのプロジェクト ファイルのパスと名前を指定します。例: C:\Local\AutoVrtlEnv\AutoVrtlEnv.uproject

    Simulation 3D Camera Get

    • センサー ID1

    • 車両名[シーン原点]

    • 車両取り付け位置[原点]

    • オフセットを指定on

    • 相対並進 [X, Y, Z][-6, 0, 2]

      これは、コーンの取り付け位置から 6 m 後方、2 m 上にカメラ位置をオフセットします。

    • 相対回転 [Roll, Pitch, Yaw][0, 15, 0]

  2. Unreal Editor の [Place Actors] タブで、[Sim 3d Scene Cap] をワールド、シーン、またはマップに追加します。

    Unreal Editor Place Actors tab

  3. Unreal Editor の [Place Actors] タブで、[Cone] をワールド、シーン、またはマップに追加します。

    Unreal Editor Place Actors tab

  4. [World Outliner] タブで、[Sim3DSceneCap1] を右クリックして [Cone] に取り付けます。

    Unreal Editor World Outliner tab

  5. [Details] タブの [Transform] で、ワールド座標系の X、Y、Z にそれぞれ位置のオフセット -500,0,100 を加えます。これにより、カメラがコーンの後方 500 cm、上方 100 cm に取り付けられます。この値は、Simulation 3D Camera Get ブロック パラメーター [相対並進 [X, Y, Z]] の値と一致します。

    Unreal Editor set transformation values

  6. [Details] タブの [Actor] で、[Sim3DSceneCap1] に名前 Camera1 のタグを付けます。

    Unreal Editor set name values

  7. シミュレーションを実行します。

    1. Simulink モデルで [実行] をクリックします。

      Unreal Editor で開かれるプロジェクトがシーンのソースであるため、シミュレーションは開始されません。

    2. Simulink の [診断ビューアー] ウィンドウに次のメッセージが表示されていることを確認します。

      In the Simulation 3D Scene Configuration block, you set the scene source to 'Unreal Editor'. In Unreal Editor, select 'Play' to view the scene.

      これは、Simulink が Unreal Engine 3D 環境で車両および他のアセットをインスタンス化したことを示す確認のメッセージです。

    3. Unreal Editor で [Play] をクリックします。Unreal Editor で現在開いているシーンでシミュレーションが実行されます。

    [To Video Display] ウィンドウで結果を観察します。このウィンドウには、カメラからのイメージが表示されます。

    Cone on road

カスタム プロジェクトの車両へのカメラの配置

カスタムの Unreal Engine プロジェクトを作成し、そのプロジェクトの車両にカメラを配置するには、次の手順に従います。この例では Computer Vision Toolbox の To Video Display ブロックを使用しますが、別の可視化ブロックを使用してイメージを表示できます。

開始するには、Vehicle Dynamics Blockset Interface for Unreal Engine Projects サポート パッケージが必要です。サポート パッケージのインストールと環境の構成を参照してください。

  1. Simulink モデルに、Simulation 3D Scene ConfigurationSimulation 3D Camera GetTo Video DisplaySimulation 3D Actor Transform Set の各ブロック、および 3 つの Constant ブロックを追加します。

    Simulink model with blocks

    モデルを保存します。

  2. Epic Games® の Epic Games Launcher の [Vehicle] テンプレートを使用して、新規プロジェクトを作成します。

    1. Epic Games Launcher で、Unreal Engine 5.1 を起動します。

      Epic games launcher

      Epic Games Launcher の詳細については、Unreal Engine を参照してください。

    2. Unreal Project Browser で、[Games][Vehicle] を選択します。

      Select template

    3. ブラウザーで、ブループリントまたは C++ プロジェクトを作成します。プロジェクトの名前と場所を指定します。[Create] をクリックします。

      Project settings

      Epic Games Launcher で新規プロジェクトが作成され、Unreal Editor が開きます。

    4. MathWorks プラグインを有効にします。

      1. [Edit][Plugins] を選択します。

      2. [Plugins] タブで、[MathWorks] に移動します。[MathWorks Interface] など、有効にするコンテンツについて [Enabled] を選択します。

        Mathworks Plugins in Unreal Editor

    5. プロジェクトを保存します。Unreal Editor を閉じます。

  3. 手順 1 で保存した Simulink モデルを開きます。ブロック パラメーターを次のように設定します。

    ブロックパラメーター設定

    Simulation 3D Scene Configuration

    • シーン ソースUnreal Editor

    • プロジェクト — 手順 2 で保存したプロジェクトのパスを指定します。例: myProjectPath\myProject.uproject

    Simulation 3D Camera Get

    • センサー識別子1

    • 車両名[シーン原点]

    • 車両取り付け位置[原点]

    Simulation 3D Actor Transform Set

    • 3D シーンのアクターのタグMainCamera1

    ActTranslation

    • 定数値[-11310.0 - 300, 8140.0, 100]/100

    • ベクトル パラメーターを 1 次元として解釈off

    ActRotation

    • 定数値[0 0 0]

    • ベクトル パラメーターを 1 次元として解釈off

    ActScale

    • 定数値[1 1 1]

    • ベクトル パラメーターを 1 次元として解釈off

  4. Simulation 3D Scene Configuration ブロックで、[Unreal Editor を開く] を選択します。

  5. Unreal Editor の [Content Browser] で、Sim3DCamera に移動します。それをワールド、シーン、またはマップに追加します。

    Unreal editor modes tab with image of camera

  6. 車両 VehicleBlueprint にカメラをドラッグ アンド ドロップします。カメラを取り付ける車両のソケットまたはボーンを選択します。

    Sockets and bones available in Unreal Editor

  7. [Details] タブで、Sim3dCamera1 に名前 Camera1 のタグを付けます。

    Unreal editor details tab with tag name

  8. 親クラスを設定します。

    1. [Blueprints] で、[Open Level Blueprint] をクリックし、[Class Settings] を選択します。

      Unreal Editor Work Outliner tab

    2. [Class Options] で、[Parent Class]Sim 3d Level Script Actor に設定します。

      Unreal Editor class settings

  9. プロジェクトを保存します。

  10. シミュレーションを実行します。

    1. Simulink モデルで [実行] をクリックします。

      Unreal Editor で開かれるプロジェクトがシーンのソースであるため、シミュレーションは開始されません。

    2. Simulink の [診断ビューアー] ウィンドウに次のメッセージが表示されていることを確認します。

      In the Simulation 3D Scene Configuration block, you set the scene source to 'Unreal Editor'. In Unreal Editor, select 'Play' to view the scene.

      これは、Simulink が Unreal Engine 3D 環境で車両および他のアセットをインスタンス化したことを示す確認のメッセージです。

    3. Unreal Editor で [Play] をクリックします。Unreal Editor で現在開いているシーンでシミュレーションが実行されます。

参考

|

関連するトピック

外部の Web サイト