主要内容

Place Cameras on Actors in theUnreal编辑or

在虚幻中可视化对象®编辑场景,您可以将摄像机放在场景中的静态演员或自定义演员上。首先,您需要Vehicle Dynamics Blockset在terface forUnreal Engine4 Projects万博1manbetx支持包。看在stall Support Package and Configure Environment

要遵循此工作流程,您应该舒适使用虚幻引擎®。Make sure that you have Visual Studio®2019年安装在您的计算机上。

Place Camera on Static Actor

Follow these steps to place aSimulation 3D Camera Getblock that is offset from a cone in the Unreal Editor. Although this example uses the进行视频显示从Computer Vision Toolbox™块中块,您可以使用其他可视化块显示图像。

  1. 在模拟中万博1manbetx®模型,添加Simulation 3D Scene Configuration,Simulation 3D Camera Get, 和进行视频显示块。

    Simulink model with blocks

    Set these block parameters. In theSimulation 3D Scene Configurationblock, select打开虚幻编辑器

    堵塞 参数设置

    Simulation 3D Scene Configuration

    • 场景来源Unreal Editor

    • Project— Specify the path and name of the support package project file. For example,C:\Local\AutoVrtlEnv\AutoVrtlEnv.uproject

    Simulation 3D Camera Get

    • Sensor identifier1

    • Vehicle nameScene Origin

    • 车辆安装位置起源

    • Specify offset

    • Relative translation [X, Y, Z][-6, 0, 2]

      This offsets the camera location from the cone mounting location, 6 m behind, and 2 m up.

    • Relative rotation [Roll, Pitch, Yaw][0, 15, 0]

  2. 在里面Unreal Editor, from the放置演员选项卡,添加一个模拟3D场景帽to the world, scene, or map.

    Unreal Editor Place Actors tab

  3. 在里面Unreal Editor, from the放置演员选项卡,添加一个锥体to the world, scene, or map.

    Unreal Editor Place Actors tab

  4. On theWorld Outliner tab, right-click theSim3DSceneCap1和attach it to the锥体

    虚幻编辑世界Outliner选项卡

  5. On theDetailstab, under转换, add a location offset of-500,0,100in the X, Y, and Z world coordinate system, respectively. This attaches the camera 500 cm behind the cone and 100 cm above it. The values match theSimulation 3D Camera Getblock parameterRelative translation [X, Y, Z]value.

    虚幻编辑器设置转换值

  6. On theDetailstab, underActor,标记Sim3DSceneCap1with the name Camera1.

    Unreal Editor set name values

  7. Run the simulation.

    1. 在Simuli万博1manbetxnk模型中,单击Run

      Because the source of the scenes is the project opened in the Unreal Editor, the simulation does not start.

    2. Verify that the Diagnostic Viewer window in Simulink displays this message:

      在模拟3D场景配置块中,您将场景源设置为“虚幻编辑器”。在虚幻编辑器中,选择“播放”以查看场景。

      This message confirms that Simulink has instantiated the vehicles and other assets in the Unreal Engine 3D environment.

    3. 在里面Unreal Editor, click。The simulation runs in the scene currently open in the Unreal Editor.

    Observe the results in the To Video display window. The window displays the image from the camera.

    锥体上road

Place Camera on Vehicle in Custom Project

Follow these steps to create a custom Unreal Engine project and place a camera on a vehicle in the project. Although the example uses the进行视频显示block from Computer Vision Toolbox, you can use a different visualization block to display the image.

首先,您需要Vehicle Dynamics Blockset在terface forUnreal Engine4 Projects万博1manbetx支持包。看在stall Support Package and Configure Environment

  1. 在模拟中万博1manbetx模型,添加Simulation 3D Scene Configuration,Simulation 3D Camera Get,进行视频显示,Simulation 3D Actor Transform Set和三个持续的块。

    Simulink model with blocks

    Save the model.

  2. 使用车辆先进template from the Epic Games Launcher by Epic Games®

    1. 在里面Epic Games Launcher, launch Unreal Engine 4.26.

      Epic Games Launcher

      For more information about the Epic Games Launcher, seeUnreal Engine

    2. 在里面Unreal Project Browser, selectGames下一个

      Unreal engine games projects

    3. 选择模板,选择车辆先进模板并单击下一个

      Select template

    4. Project Settings,创建蓝图或C ++项目,然后选择一个项目名称和位置。点击创建项目

      Project settings

      The Epic Games Launcher creates a new project and opens the Unreal Editor.

    5. Enable the MathWorks Interface plugin.

      1. Select编辑>插件

      2. On the插件tab, navigate to MathWorks Interface. SelectEnabled

        Project settings

    6. Save the project. Close the Unreal Editor.

  3. Open the Simulink model that you saved in step 1. Set these block parameters.

    堵塞 参数设置

    Simulation 3D Scene Configuration

    • 场景来源Unreal Editor

    • Project- 指定您在步骤2中保存的项目的路径。例如Myproject Path\myProject。uproject

    Simulation 3D Camera Get

    • Sensor identifier1

    • Vehicle nameScene Origin

    • 车辆安装位置起源

    Simulation 3D Actor Transform Set

    • Tag for actor in 3D sceneMainCamera1

    ActTranslation

    • 持续的value[-11310.0 - 300, 8140.0, 100]/100

    • 在terpret vector parameters as 1-D离开

    ActRotation

    • 持续的value[0 0 0]

    • 在terpret vector parameters as 1-D离开

    ActScale

    • 持续的value(1 1 1)

    • 在terpret vector parameters as 1-D离开

  4. 在里面Simulation 3D Scene Configurationblock, select打开虚幻编辑器

  5. 在虚幻编辑中,在内容浏览器navigate toSim3DCamera。将其添加到世界,场景或地图中。

    Unreal editor modes tab with image of camera

  6. 在车辆上VehicleBlueprint,拖放相机。选择车辆插座或骨头将相机连接到。

    虚幻编辑器中可用的插座和骨头

  7. On theDetails标签,标记Sim3dCamera1with the nameCamera1

    虚幻编辑详细信息选项卡带有标签名称

  8. 设置父类。

    1. UnderBlueprints, 点击Open Level Blueprint, 和selectClass Settings

      虚幻编辑器处理Outliner选项卡

    2. 在里面类选项, set父级toSim3dLevelScriptActor

      Unreal Editor class settings

  9. Save the project.

  10. Run the simulation.

    1. 在Simuli万博1manbetxnk模型中,单击Run

      Because the source of the scenes is the project opened in the Unreal Editor, the simulation does not start.

    2. Verify that the Diagnostic Viewer window in Simulink displays this message:

      在模拟3D场景配置块中,您将场景源设置为“虚幻编辑器”。在虚幻编辑器中,选择“播放”以查看场景。

      This message confirms that Simulink has instantiated the vehicles and other assets in the Unreal Engine 3D environment.

    3. 在里面Unreal Editor, click。The simulation runs in the scene currently open in the Unreal Editor.

    Observe the results in the To Video Display window.

    道路上的车辆景观

看Also

|

相关话题

External Websites