Network Communication Interface
The following UDPÂ extensions are available:
UDP Network Communication Add-on Overview
Network Communication Add-on is a device that allows communication with external applications or devices over User Datagram Protocol (UDP).
The Network Communication Add-on devices can be created in both the content and the application set up as a device. The protocol used is the same as the Real-Time UDP for MATLAB and Simulink.
Data Format
The UDP Module sends data in binary and expects to read data in the same format.
If a UDP Send extension has multiple fields, the data will be packed one value after the other, the packet will be as big as the sum of each field's data size.
One packet with all field values is sent per extension, per simulation step.
The UDP Receive extension is expecting its data to be packed the same way that it is sent.
The module will try to read one packet per extension per step. The packet read must contain a value for each field. Partial packets will be rejected and a warning will be issued in the log.
The order of fields within the extension matters: data will be packed/unpacked in the same order as within the extension.
This table shows the direct conversion between the Vortex type and the external type.
Vortex Type | External Type | Bytes |
---|---|---|
double | double | 8 |
float | single | 4 |
int | int32 | 4 |
unsigned int | uint32 | 4 |
short | int16 | 2 |
unsigned short | uint16 | 2 |
char | int8 | 1 |
unsigned char | uint8 | 1 |
bool | boolean | 1 |
Data is packed in little-endian.
Single and double values are packed using the IEEE 754 standard representation for binary32 and binary 64, respectively.
Setup
UDPÂ Module
In order to enable UDPÂ network communication, you must first add the UDPÂ Module to your Setup file. The UDPÂ Module manages all UDPÂ send and receive extensions (see below). The UDP module will read data from the network and fill the UDP Receive extensions during the pre-update phase of the simulation and will write data from the UDP send extensions to the network during the post-update phase of the simulation. Data is read/written at the frame rate of the simulation.
There must be a UDP Module located in the application setup file in order to make the extensions functional in the Vortex Studio Editor. The extensions are not functional when their name is grayed out.
From the Vortex Studio Editor and create a new setup or open an existing one.
To add a UDPÂ Module:
- In your Setup file, select Modules in the Toolbox.
- Double-click UDPÂ Module to add it to your setup.
- If desired, rename the UDPÂ Module in the Name field of its Properties panel.
The editor default setup file already has a UPD Module.
Adding UPD extensions as content extensions
UDP extension can be used to drive data to an external UDP system, from the content and back.
For example, a Connection Container can be added in the same object as the UDP extension. In the same example, a Controllable Human is also added to the content in order to demonstrate data field connections.
Data fields from Human Control are added to Connections.
Once the data fields are added to the Connections Container, the fields can be linked together, as seen in the next image.
The data sent to the external application or device will be transferred to the Controllable Human's Body Move Speed and Bode Rotate Speed.
UDP Send extension in the content
In order to send communications to external applications or devices using UDP, you must add a UDPÂ Send extension to your simulation.
To add a UDPÂ Send extension:
- In your scene or mechanism, select Network in the Toolbox.
- Double-click UDPÂ Send to add it.
- Right-click the UDPÂ Send extension in the Explorer panel, then select Edit from the menu to add input data.
- In the resulting window, click Add. A new input row appears in the table.
- Edit the name of the input.
- Click in the Type field to open a drop-down list of possible data types for your input field (e.g., double, int32, Boolean).
- Click in the Physical Dimension field to open a drop-down list of possible dimensions for your input field (e.g., length, volume, mass).
- Add as many input fields as required, then click Ok.
In the UDPÂ Send extension's Properties panel, you will see the following fields.
- Inputs
- Input data:Â This section displays the input data (via the Edit functionality mentioned above ) in the specified data type.
- Debug
- Log Traffic:Â When selected, adds information to the application log.
- Outputs
- Stats
- Bound: Indicates whether the extension has made the connection through the socket.
- Packets:Â Displays the number of packets communicated with the device.
- Bytes:Â Displays the number of bytes communicated with the device.
- Stats
- Parameters
- Auto Assign Locals:Â When selected, automatic local port and IPÂ addressing is allowed
- Local Address:Â Shows the source IPv4 address from which to send data. The default address (127.0.0.1) sets the address to the localhost.
- Local Port:Â Displays the source port from which to send data.
- Remote Address:Â Remote IPv4 address to which data is sent.
- Remote Port: This shows the port to which data is sent.
- Device ID:Â This section is filled in automatically by the module, providing identification information for the communicating device.
UDPÂ Receive extension in the content
In order to receive communications from external applications or devices using UDP, you must add a UDPÂ Receive extension to your simulation.
To add a UDPÂ Receive extension:
- In your scene or mechanism, select Network in the Toolbox.
- Double-click UDPÂ Receive to add it.
- Right-click the UDPÂ Receive extension in the Explorer panel, then select Edit from the menu to add output data.
- In the resulting window, click Add. A new output row appears in the table.
- Edit the name of the output.
- Click in the Type field to open a drop-down list of possible data types for your output field (e.g., double, int32, Boolean).
- Click in the Physical Dimension field to open a drop-down list of possible dimensions for your output field (e.g., length, volume, mass).
- Add as many output fields as required, then click Ok.
In the UDPÂ Receive extension's Properties panel, you will see the following fields.
- Inputs
- Debug
- Log Traffic:Â When selected, adds information to the application log.
- Debug
- Outputs
- Output data:Â This section displays the output data (via the Edit functionality mentioned above ) in the specified data type.
- Stats
- Bound:Â Indicates whether the extension has made the connection through the socket.
- Packets:Â Displays the number of packets communicated with the device.
- Bytes:Â Displays the number of bytes communicated with the device.
- Parameters
- Local Address:Â Shows the source IPv4 address from which to send data. The default address (127.0.0.1) sets the address to the localhost.
- Local Port:Â Displays the source port from which to send data.
- Auto Assign Remote:Â When selected, an automatic remote port and IPÂ address are allowed.
- Remote Address:Â Displays the source from which to receive data. The default address (0.0.0.0) enables the acceptance of all UDP packets from any accessible computer. If set to a specific IPÂ address, only packets arriving from that address are received.
- Remote Port: This shows the port of the target computer.
- Device ID:Â This section is filled in automatically by the module, providing identification information for the communicating device.
Adding UDP extensions as Devices in the application
If you are connecting to an external device or application (e.g., Simulink), this section and the Network Extensions above should provide you with enough information to set it up to communicate with Vortex® Studio using UDP.
Similar to the module, the send and receive extensions can be added by searching UDP Send or UDP Receive in the Toolbox.
Once an extension is added, it is possible to modify its properties in the Properties panel.
In the Properties panel, you will find the following information:
- Networking information (address/port)
- Device ID
- List of data to be sent/received
Parameters
The local address and port identify the host IP address and port, while the remote address and port describe the IP address and port of the external application or device communicating with Vortex Studio Editor.
The Device ID lists the information concerning the device, which is used in order to identify the device. This will be filled automatically by the module.
Received and Sent Data
The list of data to be sent or received can be found in the Outputs section when dealing with the UDP Receive extension, and the Inputs panel when dealing with the UDP Send extension.
As the name suggests, the UDP Receive extension will receive data, while the UDP Send will send data according to this data list.
To add data, right-click on the extension and select Edit. This window is used to add and remove fields of data, e.g., inputs and outputs.
In the example shown above, the UDP Receive extension will receive two double values (Move and Rotate) and one int32 value (Run).
Note The order of the data in the list will dictate the structure of the sent/received data. However, the names have no impact and are simply there to identify them locally.
Mapping the Device
Once the communication device has been created in the application setup, it can be mapped in the Vortex Studio Player via The Control Presets tab.
Mapping allows you to connect data fields to a Control Interface, which in turn is connected to a mechanism.
In the previous image, the UDP Receive device is associated with "ControlInterfaceInputs".
Once the data fields are properly associated, the data will automatically be transmitted to the Control Interface.
It is also possible to set the communication device as a Control Interface's default device in Vortex Studio Editor. This means that the Control Interface will automatically associate this device when the content is loaded in Vortex Studio Player.