Sensor Synchronizer APIs
The sensor synchronizer APIs are implemented by the following classes. You can find the corresponding header file in the c++/include/sensor directory to access the complete set of APIs.
| Header File | Class Name | Description |
sensor_synchronizer.h | SyncDataPackage | Encapsulates sensor data from multiple sensors with similar timestamps. |
SensorSynchronizer | Implements software-based synchronization for data from multiple sensors. |
Synchronized Data Package
Section titled “Synchronized Data Package”Get Package Timestamp
Section titled “Get Package Timestamp”-
Method:
std::chrono::system_clock::time_point get_timestamp() const -
Return Value:
Timestamp.
Add Sensor Data
Section titled “Add Sensor Data”-
Method:
void add_sensor_data(const std::string& sensor_name, std::shared_ptr<SensorData> data) -
Parameters:
ParameterTypeDescription sensor_nameInput Sensor name. dataInput Sensor data, a shared pointer to a SensorDataobject. -
Return Value:
None (void).
Add Robotic Arm Real-time State Data
Section titled “Add Robotic Arm Real-time State Data”-
Method:
void add_arm_state(const std::string& arm_name, std::shared_ptr<AbcArmRealtimeState> data) -
Parameters:
ParameterTypeDescription arm_nameInput Robotic arm name. dataInput Robotic arm real-time state data, a shared pointer to an AbcArmRealtimeState object. -
Return Value:
None (void).
Get Sensor Data
Section titled “Get Sensor Data”-
Method:
std::shared_ptr<SensorData> get_sensor_data(const std::string& sensor_name) const -
Parameter:
ParameterTypeDescription sensor_nameInput Sensor name. -
Return Value:
A shared pointer to a
SensorDataobject.
Get Robotic Arm Real-time State Data
Section titled “Get Robotic Arm Real-time State Data”-
Method:
std::shared_ptr<AbcArmRealtimeState> get_arm_data(const std::string& arm_name) const -
Parameter:
ParameterTypeDescription arm_nameInput Robotic arm name. -
Return Value:
A shared pointer to an AbcArmRealtimeState object.
Get All Sensor Data
Section titled “Get All Sensor Data”-
Method:
const std::map<std::string, std::shared_ptr<SensorData>>& get_all_sensor_data() const -
Return Value:
Map of sensor names to their data.
Get All Robotic Arm Real-time State Data
Section titled “Get All Robotic Arm Real-time State Data”-
Method:
const std::map<std::string, std::shared_ptr<AbcArmRealtimeState>>& get_all_arm_data() const -
Return Value:
Map of arm names to their real-time state data.
Check If Contains Data for Specified Sensor
Section titled “Check If Contains Data for Specified Sensor”-
Method:
bool has_sensor_data(const std::string& sensor_name) const -
Parameter:
ParameterTypeDescription sensor_nameInput Sensor name. -
Return Value:
trueif data exists,falseotherwise.
Get Sensor Count in Data Package
Section titled “Get Sensor Count in Data Package”-
Method:
size_t get_sensor_count() const -
Return Value:
Number of sensors.
Get Arm Count in Data Package
Section titled “Get Arm Count in Data Package”-
Method:
size_t get_arm_count() const -
Return Value:
Number of arms.
Sensor Synchronizer
Section titled “Sensor Synchronizer”Parameterized Constructor
Section titled “Parameterized Constructor”-
Method:
SensorSynchronizer(SyncPolicy sync_policy = SyncPolicy::NEAREST, int time_tolerance_ms = 10) -
Parameters:
ParameterTypeDescription sync_policyInput (optional) Synchronization policy. For details, please refer to SyncPolicy. time_tolerance_msInput (optional) Time tolerance, in milliseconds.
Add Sensor
Section titled “Add Sensor”-
Method:
AbcErrorCode add_sensor(const std::string& name, std::shared_ptr<SensorInterface> sensor) -
Parameters:
ParameterTypeDescription nameInput Sensor name. sensorInput A shared pointer to a SensorInterfaceobject. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Add Robotic Arm
Section titled “Add Robotic Arm”-
Method:
AbcErrorCode add_arm(const std::string& name, std::shared_ptr<ArmInterface> arm) -
Parameters:
ParameterTypeDescription nameInput Robotic arm name. armInput A shared pointer to an ArmInterfaceobject. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Remove Sensor
Section titled “Remove Sensor”-
Method:
AbcErrorCode remove_sensor(const std::string& name) -
Parameter:
ParameterTypeDescription nameInput Sensor name. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Remove Robotic Arm
Section titled “Remove Robotic Arm”-
Method:
AbcErrorCode remove_arm(const std::string& name) -
Parameter:
ParameterTypeDescription nameInput Robotic arm name. -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Sensor
Section titled “Get Sensor”-
Method:
std::shared_ptr<SensorInterface> get_sensor(const std::string& name) const -
Parameter:
ParameterTypeDescription nameInput Sensor name. -
Return Value:
A shared pointer to a
SensorInterfaceobject.
Start Synchronization
Section titled “Start Synchronization”-
Method:
AbcErrorCode start() -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Stop Synchronization
Section titled “Stop Synchronization”-
Method:
AbcErrorCode stop() -
Return Value:
AbcErrorCode::SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Register Data Synchronization Callback Function
Section titled “Register Data Synchronization Callback Function”-
Method:
void set_sync_data_callback(const SyncDataCallback& callback) -
Parameter:
ParameterTypeDescription callbackInput SyncDataCallbackis a function pointer type. For details, please refer to SyncDataCallback. The callback function is called whenever sensor data or robotic arm state data is updated. -
Return Value:
None (void).
Set Synchronization Policy
Section titled “Set Synchronization Policy”-
Method:
void set_sync_policy(SyncPolicy policy) -
Parameter:
ParameterTypeDescription policyInput Synchronization policy. For details, please refer to SyncPolicy. -
Return Value:
None (void).
Get Synchronization Policy
Section titled “Get Synchronization Policy”-
Method:
SyncPolicy get_sync_policy() const -
Return Value:
The current synchronization policy. For details, please refer to SyncPolicy.
Set Time Tolerance
Section titled “Set Time Tolerance”-
Method:
void set_time_tolerance(int tolerance_ms) -
Parameter:
ParameterTypeDescription tolerance_msInput Time tolerance, in milliseconds. -
Return Value:
None (void).
Get Time Tolerance
Section titled “Get Time Tolerance”-
Method:
int get_time_tolerance() const -
Return Value:
Time tolerance, in milliseconds.
Set Synchronization Mode
Section titled “Set Synchronization Mode”-
Method:
void set_sync_mode(SyncMode mode) -
Parameter:
ParameterTypeDescription modeInput Synchronization mode. For details, please refer to SyncMode. -
Return Value:
None (void).
Get Synchronization Mode
Section titled “Get Synchronization Mode”-
Method:
SyncMode get_sync_mode() const -
Return Value:
The current synchronization mode. For details, please refer to SyncMode.
Set Reference Sensor
Section titled “Set Reference Sensor”-
Method:
void set_reference_sensor(const std::string& sensor_name) -
Parameter:
ParameterTypeDescription sensor_nameInput Sensor name. -
Return Value:
None (void).
Get Reference Sensor
Section titled “Get Reference Sensor”-
Method:
std::string get_reference_sensor() const -
Return Value:
The name of the reference sensor.
Check If Data Is Synchronizing
Section titled “Check If Data Is Synchronizing”-
Method:
bool is_syncing() const -
Return Value:
trueif data is synchronizing,falseotherwise.