Skip to content

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 FileClass NameDescription
sensor_synchronizer.hSyncDataPackageEncapsulates sensor data from multiple sensors with similar timestamps.
SensorSynchronizerImplements software-based synchronization for data from multiple sensors.
  • Method:

    std::chrono::system_clock::time_point get_timestamp() const
  • Return Value:

    Timestamp.

  • Method:

    void add_sensor_data(const std::string& sensor_name, std::shared_ptr<SensorData> data)
  • Parameters:

    Parameter
    Type
    Description
    sensor_nameInputSensor name.
    dataInputSensor data, a shared pointer to a SensorData object.
  • Return Value:

    None (void).

  • Method:

    void add_arm_state(const std::string& arm_name, std::shared_ptr<AbcArmRealtimeState> data)
  • Parameters:

    Parameter
    Type
    Description
    arm_nameInputRobotic arm name.
    dataInputRobotic arm real-time state data, a shared pointer to an AbcArmRealtimeState object.
  • Return Value:

    None (void).

  • Method:

    std::shared_ptr<SensorData> get_sensor_data(const std::string& sensor_name) const
  • Parameter:

    Parameter
    Type
    Description
    sensor_nameInputSensor name.
  • Return Value:

    A shared pointer to a SensorData object.

  • Method:

    std::shared_ptr<AbcArmRealtimeState> get_arm_data(const std::string& arm_name) const
  • Parameter:

    Parameter
    Type
    Description
    arm_nameInputRobotic arm name.
  • Return Value:

    A shared pointer to an AbcArmRealtimeState object.

  • Method:

    const std::map<std::string, std::shared_ptr<SensorData>>& get_all_sensor_data() const
  • Return Value:

    Map of sensor names to their 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:

    Parameter
    Type
    Description
    sensor_nameInputSensor name.
  • Return Value:

    true if data exists, false otherwise.

  • Method:

    size_t get_sensor_count() const
  • Return Value:

    Number of sensors.

  • Method:

    size_t get_arm_count() const
  • Return Value:

    Number of arms.

  • Method:

    SensorSynchronizer(SyncPolicy sync_policy = SyncPolicy::NEAREST, int time_tolerance_ms = 10)
  • Parameters:

    Parameter
    Type
    Description
    sync_policyInput (optional)Synchronization policy. For details, please refer to SyncPolicy.
    time_tolerance_msInput (optional)Time tolerance, in milliseconds.
  • Method:

    AbcErrorCode add_sensor(const std::string& name, std::shared_ptr<SensorInterface> sensor)
  • Parameters:

    Parameter
    Type
    Description
    nameInputSensor name.
    sensorInputA shared pointer to a SensorInterface object.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode add_arm(const std::string& name, std::shared_ptr<ArmInterface> arm)
  • Parameters:

    Parameter
    Type
    Description
    nameInputRobotic arm name.
    armInputA shared pointer to an ArmInterface object.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode remove_sensor(const std::string& name)
  • Parameter:

    Parameter
    Type
    Description
    nameInputSensor name.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode remove_arm(const std::string& name)
  • Parameter:

    Parameter
    Type
    Description
    nameInputRobotic arm name.
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    std::shared_ptr<SensorInterface> get_sensor(const std::string& name) const
  • Parameter:

    Parameter
    Type
    Description
    nameInputSensor name.
  • Return Value:

    A shared pointer to a SensorInterface object.

  • Method:

    AbcErrorCode start()
  • Return Value:

    AbcErrorCode::SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    AbcErrorCode stop()
  • Return Value:

    AbcErrorCode::SUCCESS indicates 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:

    Parameter
    Type
    Description
    callbackInputSyncDataCallback is 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).

  • Method:

    void set_sync_policy(SyncPolicy policy)
  • Parameter:

    Parameter
    Type
    Description
    policyInputSynchronization policy. For details, please refer to SyncPolicy.
  • Return Value:

    None (void).

  • Method:

    SyncPolicy get_sync_policy() const
  • Return Value:

    The current synchronization policy. For details, please refer to SyncPolicy.

  • Method:

    void set_time_tolerance(int tolerance_ms)
  • Parameter:

    Parameter
    Type
    Description
    tolerance_msInputTime tolerance, in milliseconds.
  • Return Value:

    None (void).

  • Method:

    int get_time_tolerance() const
  • Return Value:

    Time tolerance, in milliseconds.

  • Method:

    void set_sync_mode(SyncMode mode)
  • Parameter:

    Parameter
    Type
    Description
    modeInputSynchronization mode. For details, please refer to SyncMode.
  • Return Value:

    None (void).

  • Method:

    SyncMode get_sync_mode() const
  • Return Value:

    The current synchronization mode. For details, please refer to SyncMode.

  • Method:

    void set_reference_sensor(const std::string& sensor_name)
  • Parameter:

    Parameter
    Type
    Description
    sensor_nameInputSensor name.
  • Return Value:

    None (void).

  • Method:

    std::string get_reference_sensor() const
  • Return Value:

    The name of the reference sensor.

  • Method:

    bool is_syncing() const
  • Return Value:

    true if data is synchronizing, false otherwise.