Follow

UDP Remote Control

MVN can receive Remote Control commands via UDP. With this feature, it is possible to send basic commands from a different program running on the same PC or from a different PC on the same network.  In the set-up with multiple MVN systems, it is possible to start and stop the recording via remote commands for multiple MVN systems and other systems.

NOTE: if you want to automate actions on files (like: reprocessing, trimming or exporting) without having to use the MVN GUI, please take a look at MVN Command Lines.

MVN attempts to parse any UDP messages it receives and takes the appropriate actions: start a new recording or stop the ongoing recording or play the opened file. The time to start or stop a recording as contained in the command is expressed as a time code. Since MVN is synchronized with the time code it can properly determine the right moment to perform the action.

An example of the use of UDP Remote Control is the MVN Remote App (freely available for iOS and Android), which uses UDP Remote Control commands to interact with MVN from the ease of a smartphone. 

 

1. Software

Remote Control is a feature installed with MVN by default. The latest version of MVN can be found on the Xsens Website.
 

2. Set up MVN

1. Start MVN Animate / Analyze
2. By default UPD remote control is enabled. To check this you can go to Options > Remote Control.

mceclip0.png

3. Make sure that Enable UDP remote control is checked and note the Port number and Name

 

3. Set up connection

4.1 Standard setup
To send and receive messages through UDP, you need to know the IP address of your PC running MVN.

1. Get the IP address of the machine where MVN is running. You can do so by pressing the Windows key on your keyboard (mceclip4.png) and type "CMD"  and click Command Prompt.

mceclip5.png

2. in the Command Prompt, type in "ipconfig" and press the Enter-key to get an overview of the network settings.
3. Search for the IPv4 Address. 

mceclip6.png

NOTE: The IPv4 address has to be something like 172.16.10.160 (do not forget the dots!)

 

4.2 LAN Setup (optional)

To secure that the UDP commands are only sent to the PC('s) running MVN, it is preferable to configure the IP addresses of those PC's:
- IP address with only the LSB, e.g. 172.16.10.<index>.
- Subnetmask: 255.255.255.0

To Configure the IP address of the PC running MVN perform the following steps:

1. Go to Network and Sharing Center (Search 

mceclip2.png

 

2. In the Control Panel go to Network and Internet

mceclip5.png

 

3. In the Network and Internet Panel go to Network and Sharing Center

mceclip6.png

 

4. In the Network and Sharing Center go to Change adapter settings

mceclip4.png

5. Select and double-click the LAN you are connected to.

mceclip8.png

6. In the LAN settings click on Properties  

mceclip9.png

7. From the List, select the TCP/IPv4 and click on Properties

mceclip11.png

8. Fill in an  IP address of the LAN network with the Index being an unused address. 

- IP address with only the LSB, e.g. 172.16.10.<index>.
- Subnetmask: 255.255.255.0

 mceclip7.png


When the UDP command is sent to IP address 192.168.2.255, only the PC's with MVN will receive it.

4. Send message

You can now send UDP messages to a PC running MVN in the same network. 

To test your messages, you can use free programs such as Packet Sender. In the example below, a UDP message is created to send a Play/Pause command to MVN running on localhost (the local PC's IP-address, 127.0.0.1) through port 6004 (the default port MVN uses for UDP). 

mceclip2.png

In MVN go to View and make sure that Remote Control Log Window is enabled.

mceclip1.png

If you send the command with Packet Sender, you can check if MVN receives and acknowledges the message. 

mceclip4.png

 

5.  UDP commands specification

The UDP commands use case sensitive XML-like text-string containing ‘key-value’pairs. The commands are typically broadcast (e.g. destination IP-address <netmask>.255) over the network so all recording devices are triggered simultaneously, or sent to a specific IP-address.

NOTE: All fields are placed between double-quotes.
The Boolean format takes the values "TRUE" or "FALSE".
The Path format uses forward slashes.


5.1 IdentifyReq
Description: Request to MVN to identify itself.
Attributes: none
Response: IdentifyAck
Response Attributes:
- IpAddress, ddd.ddd.ddd.ddd: The IP address of the UDP Remote Control
- InstanceName, String: The instance name as entered in the MVN Studio preferences
- <Address>, Tag with VALUE: The address of the UDP Remote Control host machine. Usually, more than one address is returned, the caller should determine which address is relevant.

5.2 StartMeasuringReq
Description: Request to start measuring, wake up from low-power mode.
Attributes: none
Response: StartMeasuringAck
Response Attributes:
- Result, Boolean: TRUE if the request was successful

5.3 StopMeasuringReq
Description: Request to stop measuring, switch to low-power mode.
Attributes: none
Response: StopMeasuringAck
Response Attributes:
- Result, Boolean: TRUE if the request was successful

5.4 StartRecordingReq
Description: Request to start recording to an MVN file.
Attributes:
- SessionName, Path: Either the full path + filename of the desired MVN file or just the filename. Relative paths are not supported and may result in unpredictable behaviour. This is a required attribute.
- StartTime, hh mm ss: The StartTime is expressed as a timecode (hours minutes seconds). If the attribute is not supplied, an immediate start is triggered. Any extra values after the ss field are ignored. Note that a time that is more than 4 hours in the past is considered to be in the future.
- Description, String: The description of the recording. This will be recorded in the file.
Response: StartRecordingAc
Response Attributes:
- Result, Boolean: TRUE is the request was successful

5.5 StopRecordingReq
Description: Request to stop recording and save (and close, depending on settings) the MVN file.
Attributes:
- StopTime: hh mm ss: The StopTime is expressed as a timecode (hours minutes seconds frame). If the attribute is not supplied, an immediate stop is triggered. Any extra values after the ss field are ignored. Note that a time that is more than 4 hours in the past is considered to be in the future.
Response: StopRecordingAck
Response Attributes:
- Result, Boolean: TRUE if the request was successful


4.6 PlayPauseReq
Description: Toggle play / pause for the active session. This has no effect on a live session, only on a file session.
Attributes: none
Response: PlayPauseAck
Response Attributes: none


5.7 NavigateToStartReq
Description: Navigate to start of file for the active session. This has no effect on a live session, only on a file session.
Attributes: none
Response: NavigateToStartAck
Response Attributes: none


5.8 NavigateToEndReq
Description: Navigate to end of file for the active session. This has no effect on a live session, only on a file session.
Attributes: none
Response: NavigateToEndAck
Response Attributes: none

5.9 PreviousFrameReq
Description: Navigate one frame backwards for the active session. This has no effect on a live session, only on a file session.
Attributes: none
Response: PreviousFrameAck
Response Attributes: none

5.10 NextFrameReq
Description: Navigate one frame forwards for the active session. This has no effect on a live session, only on a file session.
Attributes: none
Response: NextFrameAck
Response Attributes: none


5.11 ToggleRepeatReq
Description: Toggle repeat for the active session. This has no effect on a live session, only on a file session.
Attributes: none
Response: ToggleRepeatAck
Response Attributes: none

5.12 AddMarkerReq
Description: Insert a marker into the active recording at the current frame. This is intended for a live session only. Its behavior is undefined if used on a file session.
Attributes:
- Text, String: The text of the marker. If not supplied or empty, a default marker text will be inserted.
Response: AddMarkerAck
Response Attributes: none


5.13 AddNetworkStreamingTargetReq
Description: Add a network streaming target.
Attributes:
- IpAddress, ddd.ddd.ddd.ddd: The IP address of the target to add
- PortNumber, Integer: The port number to stream to. If unspecified, the default port 9763 will be used
- Protocol, String: The desired protocol to enable. This is an optional field. The choices are:

o DgramPoseEuler
o DgramPoseQuat
o DgramUnity3D
o DgramMetaData
o DgramOptical
o DgramScaling
o DgramTrackerKinematics
o DgramLinearSegmentKinematics
o DgramAngularSegmentKinematics
o DgramCenterOfMass
o DgramJointAngles
o DgramTimeCode
o DgramSiemens


Response: AddNetworkStreamingTargetAck
Response Attributes:
- Result, Boolean: TRUE if the request was successful


5.14 RemoveNetworkStreamingTargetReq
Description: Remove a network streaming target.
Attributes:
- IpAddress, ddd.ddd.ddd.ddd: The IP address of the target to remove
- PortNumber, Integer: The port number of the target. If unspecified, the default port 9763 will be used. Please note that there must be an exact IP+port match in order to remove a target.
Response: RemoveNetworkStreamingTargetAck
Response Attributes:
- Result, Boolean: TRUE if the request was successful


5.15 SessionStatusReq
Description: Request session status information.
Attributes: none
Response: SessionStatusAck
Response Attributes: a relevant subset of the following
- isRecording, Boolean: The live session is currently recording
- isPlaying, Boolean: The file session is currently playing
- isRepeating, Boolean: The file session’s repeat option is enabled
- isPaused, Boolean: The file session is currently paused (not playing)
- playSpeedRatio, Fraction: The speed at which the file session is played. This is expressed as a fraction or an integer, ie: “1” or “4” or “1/8”

 

5.16 MoveCharacterToOriginReq
Description: Move the character to the origin. This has no effect on a file session, only on a live session.
Attributes:
- CharacterId, integer: The index of the character to move. Supply -1 or omit to move all characters.
Response: MoveCharacterToOriginAck
Response Attributes: none


5.17 ResetAxisReq
Description: Reset the axis definition of the character so it is facing North. This has no effect on a file session, only on a live session.
Attributes:
- CharacterId, integer: The index of the character to reset. Supply -1 or omit to reset all characters.
Response: ResetAxisAck
Response Attributes: none


5.18 SessionInfoReq
Description: Request session information.
Attributes: none
Response: SessionInfoAck
Response Attributes: a relevant subset of the following
- sessionName, String: The current session name
- recordingTrial, Integer: The current recording trial
- isLive, Boolean: The session is in live mode
- fileDurationFrame, Integer: The current file duration expressed in number of frames
- fileDurationMs, Integer: The current file duration expressed in milliseconds


5.19 JumpToFrameReq
Description: Jump to the specified frame.
Attributes:
- frame, Integer: The frame to jump to
Response: JumpToFrameAck
Response Attributes: none


5.20 SetMediaRecorderAddressReq
Description: Identifies a media recorder to transfer media from (i.e. reference video).
Attributes:
- IpAddress, String: The media recorder’s ip address.
- PortNumber, Integer: Port number with which communication will occur
Response: SetMediaRecorderAddressAck
Response Attributes: none


5.21 SetSessionNameReq
Description: Request a session name change
Attributes:
- sessionName, String: The new session name
Response: SetSessionNameAck
Response Attributes:
- Success, Boolean: The session name has been set successfully

 

5.22 CaptureName
Similar to the SetSessionNameReq, but added to conform to existing protocols. MVN Sends this message when the Network Sync feature is enabled in the Network Streaming options. When this message is received, the session name and path and take nr will be updated.
<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<CaptureName>
<Name VALUE="Name of the take/capture, optionally with path" />
<Take VALUE="Take/capture nr, to distinguish between multiple takes in the same session." />
</CaptureName>
MVN will send a CaptureNameAck message back with attribute Success=”TRUE” or “FALSE” to indicate success or failure.

5.23 CaptureStart
Similar to the StartRecordingReq, but added to conform to existing protocols. MVN Sends this message when the Network Sync feature is enabled in the Network Streaming options.


<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<CaptureStart>
<Name VALUE="Optional Name of the take/capture. When set, it defines the base filename to use for this specific recording. When missing, the current session information will be used" />
<SessionName VALUE="Ignored" />
<DatabasePath VALUE="Optional Path to write the data to. Prefixed to the Name parameter if present." />
<TimeCode VALUE="Optional Desired time of start of capture" />
<Notes>Optional Additional text to be stored in the capture</Notes>
</CaptureStart>


MVN will send a CaptureStartAck message back with attribute Success=”TRUE” or “FALSE” to indicate success or failure.

5.24 CaptureStop
Similar to the StopRecordingReq, but added to conform to existing protocols. MVN Sends this message when the Network Sync feature is enabled in the Network Streaming options.


<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<CaptureStop>
<Name VALUE="Optional Name of the take/capture, ignored by MVN" />
<TimeCode VALUE="Optional Desired time of end of capture" />
<Notes>Optional Additional text to be stored in the capture. This will replace the Notes from CaptureStart if present.</Notes>
</CaptureStop>


MVN will send a CaptureStopAck message back with attribute Success=”TRUE” or “FALSE” to indicate success or failure.


5.25 TimeSync
A network time synchronization message. This will align the internal timestamping of MVN with the supplied value. It is strongly recommended to only use this functionality on a very reliable network as timing jitter in the transmission can result in poor time synchronization. MVN does not send this message.


<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<TimeSync>
<TimeCode VALUE="Optional Current time, MVN will match its internal clock to this time" />
<Reset VALUE="Optional Reset time to match the local system time" />
</TimeSync>


MVN will not send a TimeSyncAck message back due to the additional latency. Do note that only the hour, minute and second parts of the received timecode will be used. So it is recommended to only send the message once per second on the second.


5.26 Example
The following gives an example of the command that starts a recording:

<StartRecordingReq SessionName="C:/Xsens/MVN/session_01" StartTime="13 46 13 25" />
<IdentifyAck InstanceName=”MVN Studio A”>
<Address VALUE=”192.168.3.4” />
<Address VALUE=”CA:56:3D:23:45:67:67” />
</IdentifyAck>

 


6. UDP Remote Control in sync with other devices

UDP Remote Control can also be used in sync with other devices using 1 Central Control PC. 

 

6.1 Set up multiple devices for syncing

1. For the correct functioning of the remote control code part, the hardware as seen in de picture below should be in place. The set-up has to have a system in place that generates the UDP commands, e.g. the “Central Control”. When the Switch in the picture below is one with IGMP support3, the UDP commands can be multicasted also.

mceclip0.png


Multicast is a kind of UDP traffic similar to BROADCAST, but only hosts that have explicitly requested to receive this kind of traffic will get it. This means that a MVN System has to join a multicast group if you want to receive traffic that belongs to that group.
IP addresses in the range 224.0.0.0 to 239.255.255.255 (Class D addresses) belong to multicast. No host can have this as IP address, but every machine can join a multicast address group.
The reserved IP-address 224.0.0.1, specifies “all systems on this subnet”. In the set-up, all listening sockets join the multicast group "224.0.0.1". This is the "all-hosts" group. All sending sockets transmit to "224.0.0.1". This ends up going to all machines that have joined the "all-hosts" group (224.0.0.1).


2. By default UPD remote control is enabled. To check this you can go to Options > Remote Control

mceclip0.png

The port used by Remote Control and the multicast IP-address to join can be configured. The default value for the port is 6004. The Remote Control will join any IP-address other than 0.0.0.0.
In the field ‘Name’ the (optional) ‘System ID’ can be specified which will be appended to the given filename.

3. Check the reception of the UDP commands.
A CaptureStart and CaptureStop can be sent right after each other in the format as specified in section 3.4. Open the ‘Remote Control Log Window from the ‘View’ menu. If no action is logged and executed in MVN, check the LAN set-up (see section 3.5).


6.2 Time offset
The command must specify a time in the future (expressed in a time code) when to start the recording. When the times in the MVN systems are synchronized to an external time code, the recordings can then start at the same time. However, there will be some offset as is discussed in the next paragraph.
After having received the start time (expressed as a time code) in the remote command, the first key-frame in the recording is the one for which the timestamp is larger than the received start time, assuming a synchronized MVN system of course. The MVN start time that is stored in the MVN file will be the time stamp of that frame. So, worst case the MVN start time is 1 sample (e.g. 8.33 ms for 120 Hz sample rate) larger than the specified start time.
Also, this means that for two MVN systems the worst case offset between key-frames with the same index is 1 frame at the start of the recording. Of course, this is a known offset since it follows from the values stored in the MVN file.
The above is illustrated in the picture below.

mceclip5.png

 

Was this article helpful?
0 out of 0 found this helpful
Do you have a question? Please post your question in our Community Forum