Main Content

链接至金宝appandSimscapeMultibodyModels

要在模型和虚拟世界之间建立实时数据连接,请在动态模型对象数量和相应的虚拟世界对象属性之间建立关联。例如,与虚拟世界对象属性(例如位置和旋转)创建关联。

AlthoughSimscape™ Multibody™and Simulink®are common platform for modeling mechanical systems, also you can use the金宝appSimulink 3D Animation™用于可视化MATLAB中实现模型的产品®

链接the Virtual World to a金宝appModel

You associate Simulink model signals to virtual world object properties through theVR Sinkblock from theSimulink 3D Animation块库,vrlib

将Simulink信号与虚拟对金宝app象属性相关联:

  1. 来自vrliblibrary, insert aVR Sink阻止您的simulink型号。金宝app

  2. To define the virtual world, use theVR Sink块参数对话框。输入虚拟世界3D文件的名称源文件, or clickBrowse至select the file interactively. To load the selected virtual reality scene, click申请

  3. 为了平稳的动作可视化,您可以更改块采样时间。For example, to update the virtual world 25 times per simulation second, set the采样时间0.04。在使用继承的样品时间时要小心VR Sink堵塞。根据所使用的求解器,使用继承的示例时间可能会导致虚拟世界的非quid(在仿真时间)更新。无量化的更新给观看虚拟世界的人会给系统动态带来错误的印象。

  4. InVirtual World Tree,扩展主要对象Transform分支。在场景对象层次结构中,根据Simulink的名称找到您要控制的所有部分金宝appAdd DEF Names。NamedTransform节点代表每个部分。选择旋转和位置字段旁边的复选框Transformnode. You can select other properties of virtual world objects, such as color, but rotations and positions are the ones most frequently controlled.

  5. 点击OK。For each selected field, theVR Sink块创建一个输入端口。增加VR Sink适当的块大小以适应输入端口的数量。

After you associate theVR Sinkblock with a virtual world, you can double-click it to open theSimulink 3D Animationviewer. To access the block parameters, in the viewer, selectSimulation>Block Properties

VR Sinkinputs take signals of the type corresponding to their virtual world representation. Position inputs are of typeSFVec3f的位置中[X Y Z]坐标。旋转输入类型SFRotation,将旋转定义为的四元素向量[axis angle], using the coordinate system described in使用的坐标系, where the angle value is in radians.

Match the coordinate system used by the Simulink model to that of the virtual world. If the two coordinate systems are not identical, transform an axis.

Usually, object positions are available in the form required by virtual world (Cartesian coordinates). Often, object rotations are defined using the rotation matrix representation. To convert such rotations into the VRML format, use the旋转矩阵到VRML旋转堵塞。

Object positions and rotations are treated differently depending on the virtual world hierarchy:

  • To define all parts in a Simulink model in global coordinates, when the virtual world has a flat structure of independent objects, use these positions and rotations.

    Object positions Send toVR Sinkall positions in global coordinates.
    对象旋转 Send toVR Sinkall rotations in global coordinates, with the center of rotation defined as the coordinate system origin. If the default center of rotation ofTransform对象是[0 0 0],您无需在虚拟世界3D文件中定义每个部分的中心。
  • 当Simulink模型中的所有部分都金宝app遵循层次关系,并且虚拟世界具有嵌套结构,请使用这些位置和旋转。

    Object positions Send toVR Sinkall positions in local coordinates relative to their parents or predecessors in the object hierarchy. For example, send the robot tool position relative to the robot hand.
    对象旋转

    Send toVR Sink本地坐标的所有旋转均相对于其父母或对象层次结构中的前辈。例如,将机器人工具旋转发送到机器人手。

    Match the positions of joints between objects visually by coinciding the centers of rotation in the virtual world and in the Simulink model. Coincide the center of rotation because when joints between parts are not positioned in the origin ([0 0 0]) of the coordinate system of the parent.

    为了定义与默认值不同的旋转中心,[0 0 0], define thecenterfield of the childTransform虚拟世界3D文件中的节点。例如,定义机器人工具旋转中心以与连接手的关节和手部局部坐标相吻合。

在层次结构结构中,当零件通过旋转关节连接时,很容易定义零件之间的相对旋转。关节轴直接定义虚拟世界旋转轴,因此您可以构建[axis angle]four-element rotation vector.

初始状态

A Simulink model initial conditions must correspond to the initial object positions and rotations defined in the virtual world. Otherwise, the object controlled from Simulink jumps from the position defined in the VRML file to the position dictated by Simulink for the simulation. To compensate for this offset, use one of these approaches:

  • In the virtual world 3D file, define another level of nestedTransform在受控对象周围。

  • 在Simuli金宝appnk模式下,将对象初始位置添加到模型计算中,然后发送到VR Sink堵塞。

Align the Simulink model initial conditions with the virtual world object positions, Maintain the correct position of the object relative to the surrounding scene. You can adjust the position of the surroundings of the object. For example, move the road position so that the car at position[0 0 0]留在道路上,没有车轮下沉或漂浮在道路上方。

VR占位符and VR Signal Expander Blocks

VR Sink块仅接受定义完全合格的字段值的输入。仅在一个维度上描述系统行为的动态模型仍然需要所有受控对象的完整3D位置,以实现其虚拟现实可视化。

To simplify the modeling in such cases, you can use theVR占位符andVR Expanderblocks of theSimulink 3D Animationlibrary.

VR占位符block sends out a special value that is interpreted as unspecified by theVR Sink堵塞。当这个占位符价值出现在VR Sinkinput, as a single value or as vector element, the appropriate value in the virtual world remains unchanged.

VR信号扩展器block creates a vector of predefined length, using some values from the input ports and filling the rest with placeholder signal values.

To control the position of a virtual object in a one-dimensional dynamic model, use theVR信号扩展器以受控维度为输入。为了输出,请在VR Sink堵塞。其余的矢量元素充满了占位符信号。

Use of theVR信号扩展器block is also a possibility when defining rotations. When the axis of rotation is defined in the virtual world 3D file, you can send to theVR Sinkblock a virtual world rotation value. Use a value consisting of three placeholder signals and the computed angle. This rotation value forms a valid four-element[axis angle]vector.

链接至SimscapeMultibodyModels

您可以使用Simulink 3D Animationproduct to view the behavior of a model created with theSIMSCAPE多体软件

  1. 使用Simulink界面中的机器模型金宝appSIMSCAPE多体blocks.

  2. 在虚拟世界中创建机器的详细视觉表示。

  3. Connect the virtual world to theSIMSCAPE多体车身传感器输出。

  4. 在一种查看尸体的行为tual world viewer.

您可以使用SIMSCAPE多体software for 3D visualizations using theSimulink 3D Animationproduct. In addition to the features thatSIMSCAPE多体product offers for modeling mechanical assemblies, the following features simplify the visualization ofSIMSCAPE多体虚拟现实中的模型:

  • SIMSCAPE多体虚拟世界坐标系统是相同的。

  • In theSIMSCAPE多体软件,您可以与全球和本地对象坐标一起工作。这种灵活性使该模型可以轻松地适应从CAD工具导出的虚拟世界的结构。

SIMSCAPE多体product also offers a convenient way of importing CAD assembly designs intoSIMSCAPE多体machines through theSIMSCAPE多体链接interface. Alternatively, when you export a CAD assembly to the virtual world format, you can add virtual reality visualization to such assemblies.

Simulink 3D Animation软件包含以下功能用于使用SIMSCAPE多体文件:vrcadcleanup, andvrphysmod

Depending on the virtual world hierarchy, you can use one of two approaches to help visualizeSIMSCAPE多体machines:

  • 当虚拟世界具有独立对象的平坦结构时,您可以使用机器零件的位置和旋转Body Sensorblocks. Connect theBody Sensorblock to appropriate coordinate systems attached to the bodies. Define positions and rotations using global coordinates. Usually, you can connect the sensor to a body coordinate system with origin at[0 0 0]and with an initial rotation matrix defined as the identity matrix,[1 0 0; 0 1 0, 0 0 1], in the global coordinates.

  • When the virtual world has a hierarchical structure of nested objects, you can obtain the body positions and rotations. Use aBody Sensorblock with its output set to use local body coordinates. In special cases, such as when two bodies are connected through a revolving joint, you can get the angle between the objects using a关节传感器堵塞。

链接至aMATLABModel

为了帮助您与虚拟世界互动Simulink 3D Animationproduct offers a set of MATLAB functions and constructs referred to collectively as its “MATLAB interface.” Circumstances when this MATLAB functionality is appropriate for use with CAD-based designs include:

  • Using customized GUIs to visualize static objects and their relations in a virtual environment, such as in interactive machine assembly instructions.

  • Visualizing 3D information based on an independent quantity (not necessarily time).

  • Using MATLAB interface functions in Simulink model callbacks.

  • Visualizing systems whose dynamic models are available as MATLAB code.

  • Visualizing systems where massive object changes, such as deformations, take place. In this case, send dynamically sized matrix-type data from the dynamic models to virtual worlds, which is not possible using just Simulink signals.

For information on setting object properties using the MATLAB interface, see与虚拟现实世界互动

Related Topics