Skip to content

SDK Data Connector

Occasionally you may want to work with the raw data recorded by Cognitive3D in realtime. This may be for writing data points in a specific format to your local computer, or this may include running this realtime data into a ML model. This page includes sample scripts and instructions for this sort of workflow.

Scripts available here work with the Cognitive3D Unity SDK version 2.2.0 and newer. They are provided as-is and may require additional work to format properties for your specific use case. These scripts were written for readability, not for performance. Although performance is not expected to significantly impact your app, additional optimization may be required.

Data Connector

This Data Connector script uses callback functions from the Cognitive3D SDK to organize data points we record with a usual implementation.

DataConnector.cs Sample Script

This script includes handy properties SessionID and CurrentTimestamp - these may be useful if you are serializing additional sensors or third party data and need to align timestamps.

Technically, all the data points are entered into a temporary list, then intended to be manually cleared after that data is read elsewhere. This simplifies the implementation if you wish to use data in multiple places.

In Unity, you can use the Inspector to select which types of data you want to record.

Inspector options for Data Connector data types and component to write data to a local file

Data Connector Local File

This script constantly reads data from Data Connector to write to the local computer with a filestream.

DataConnectorLocalFile.cs Sample Script

You can choose to save this data in a JSON or CSV format. Note that the CSV format uses | characters to separate commas used in arrays, such as position and rotation information.

Data Connector TCP Client and Server

This sends the recorded real-time data to a server via a TCP connection. The example includes a very simple server (written in c#) that returns a sample value every second. This server is expected to take input from the TCP client and produce some output to be used in your application.

DataConnectorTcpClient.cs Sample Script

DataConnectorTestServer.cs Sample Script

Configuration options for using Data Connector with a TCP client

intercom If you have a question or any feedback about our documentation please use the Intercom button (purple circle) in the lower right corner of any web page or join our Discord.