MATLAB to Export - BETA

This article was written for version 2.0.9 of Core. Click here for the most recent version of the help center.

The BETA version of the PolySync-MATLAB/Simulink support provides a workflow to export time synchronized data from PolySync, and import the data into MATLAB/Simulink for application and algorithm development.

The BETA version supports these six message types:

  • ps_lane_model_msg
  • ps_lidar_points_msg
  • ps_objects_msg
  • ps_platform_motion_msg
  • ps_radar_targets_msg
  • ps_traffic_sign_msg

This workflow was built as a proof-of-concept between The MathWorks and PolySync. Full-featured support is under joint-development and is expected to be available near Q2 2017.

The full version will support all message types, and will have a streaming interface rather than the export/import process.

1. Workflow

Here’s a high-level overview of the workflow for accessing time-synchronized data in MATLAB:

  1. Build and run the CSV export node
  2. Replay data to export the supported high-level message types to CSV
  3. Use provided MATLAB tools and examples to import CSV and begin autonomous vehicle application development

1.1 CSV export node

PolySync CSV export node─polysync-csv-export─subscribes to the appropriate message types at runtime, and is responsible for writing a CSV file containing all data from each message received.

The source code can be found in the GitHub example [here]().

1.1.1 Building the node

The node comes precompiled with the PolySync release package, or follow these steps to clone the C++ examples repo and build the node:

$ git clone
$ cd PolySync-Core-CPP-Examples/CSVExporter
$ mkdir build && cd build
$ cmake .. && make
1.1.1 Running the node

The node can be run anywhere on the system. It takes in the message types to convert to CSV as command line arguments.

$ polysync-csv-export -t ps_objects_msg ps_lane_model_msg ps_radar_targets_msg

Each message type will create its own CSV file in the same directory where the node is run.

To see all available command line options, pass in the help -h flag.

1.2 Replay data on PolySync

Once the CSV export node is running, start nodes in the hardware context, or replay a logfile session to begin publishing data to the PolySync bus via the polysync-core-dynamic-driver nodes.

The CSV export node will automatically receive the messages and begin exporting the data to CSV.

To stop the polysync-csv-node use CTRL+C, the node will disconnect from PolySync and stop receiving messages. The node will continue to write all data currently in the buffer.

1.3 Import data in MATLAB

Download the MATLAB import resources directly from here.

The sample CSV data can be downloaded separately from our Dropbox.

There are two MATLAB project folders included. The +polysync/ and +bev/ folders can be opened using MATLAB.

  • +polysync/
    • Contains the MATLAB data structures, derived from the original PolySync message types
    • Contains the read_polysync_csv_* routines and associated resources to read the PolySync CSV data
  • +bev/
    • Contains the resources to plot detection’s
1.3.1 Running MATLAB examples

The MathWorks has provided useful examples that show how to access the CSV data in meaningful ways. The files are located included in the MATLABBridge-BETA.tar.gz download from above.

Run the examplePlotRadarAndVision.m and examplePlotRadarVisionAndLidar.m applications to see the examples in action.