- Host Configuration
- Runtime Node Configuration
- SDF Configuration
- Logfile Management
- Managing the Runtime
- Application Code Portability
- Building C Examples
- Building C++ Examples
- Building a Node
- Clone Example Repos
- Coordinate Frames
- Diagnostic Trouble Codes
- Extending the Data Model
- IDE Setup
- Logged vs Source vs Published Video Parameters
- MATLAB to Export - BETA
- PolySync Messages
- ROS Bridge
- Release Notes
- Standard Units
- Dynamic Driver/HW Interface Development
- Application Development
Extending A Data Model Tutorial
In this tutorial, we will extend the DTC module to demonstrate how to extend the PolySync data model.
1. Adding a DTC
We begin by opening the IDL file that ships with the PolySync release package, and add a new Diagnostic Trouble Code (DTC):
$ sudo gedit $PSYNC_HOME/modules/dtc/dtc.idl
PolySync has reserved the lower 32-bits of the available
ps_dtc IDs. This means that custom DTCs must have an ID with a value of 4,294,967,296 >= x <= 18,446,744,073,709,551,615.
We will add a custom DTC to the IDL with our custom description and macro name:
/** @brief Ibeo Lux device has overheated and cannot operate. * Data will not be reported until the temperature matches the normal operating range. */ const ps_dtc DTC_IBEO_LUX_OVERHEATED = 4294967296;
DTCs are intended to represent a specific state of an application. Rather than saying hardware error, a DTC could indicate very specifically that the Ethernet sensor is overheated. Another DTC could indicate that the mirror is dirty, and so on.
2. Generate the data model
Once all changes have been saved, the PolySync PDM tool is used to generate the data model with the DTC built into the API. Navigate to a directory where you want to generate your pdm files and then run the below.
$ pdm-gen $PSYNC_HOME/modules/dtc/dtc.idl $PSYNC_HOME/modules/sensor/sensor.idl $PSYNC_HOME/modules/navigation/navigation.idl $PSYNC_HOME/modules/control/contorl.idl > pdm/version.txt $ sudo cp pdm/*.so $PSYNC_HOME/lib
Applications need to be rebuilt against the new API files before the new DTC is available at runtime, and can be used to indicate the diagnostic status.
The same process can be applied to any of the data model modules to extend or add new types and messages.
As you’ve worked through this tutorial, you’ve learned how to extend the DTC module to demonstrate how to extend the PolySync data model.
Ready for more? The Data Generation Tutorial expands on filling messages and publishing data to the PolySync bus, as well as working with multiple message types.