1.1. DDS Enabler¶
-
class DDSEnabler¶
Wrapper class that encapsulates all dependencies required to launch DDS Enabler.
Public Functions
-
DDSEnabler(const yaml::EnablerConfiguration &configuration, const CallbackSet &callbacks)¶
DDSEnabler constructor by required values.
Creates DDSEnabler instance with given configuration.
- Parameters:
configuration – Structure encapsulating all enabler configuration options.
callbacks – Set of callbacks to be used by the enabler.
-
bool set_file_watcher(const std::string &file_path)¶
Associate the file watcher to the configuration file and establish the callback to reload the configuration.
- Parameters:
file_path – The path to the configuration file.
- Returns:
trueif operation was succesful,falseotherwise.
-
utils::ReturnCode reload_configuration(yaml::EnablerConfiguration &new_configuration)¶
Reconfigure the Enabler with the new configuration.
- Parameters:
new_configuration – The configuration to replace the previous configuration with.
- Returns:
RETCODE_OKif allowed topics list has been updated correctly- Returns:
RETCODE_NO_DATAif new allowed topics list is the same as the previous one- Returns:
RETCODE_ERRORif any other error has occurred.
-
bool publish(const std::string &topic_name, const std::string &json)¶
Publish a JSON message to the specified topic.
- Parameters:
topic_name – The name of the topic to publish to.
json – The JSON message to publish.
- Returns:
trueif the message was published successfully,falseotherwise.
-
bool announce_service(const std::string &service_name, participants::Protocol Protocol)¶
Creates a server for the given service.
This function announces a service by setting up a server for it. It returns a boolean indicating whether the operation was successful. Failure may occur if there is an issue requesting the data types to user’s app for the corresponding request and reply topics.
- Parameters:
service_name – The name of the service to be announced.
Protocol – The RPC protocol to be used (overloaded function, without this parameter uses ROS2 by default).
- Returns:
true if the service was successfully announced, false otherwise.
-
bool revoke_service(const std::string &service_name)¶
Stops the server for the given service.
This function revokes the server associated with the specified service. It returns a boolean indicating whether the operation was successful. The operation will fail if the service was not previously announced.
- Parameters:
service_name – The name of the service to be stopped.
- Returns:
true if the service was successfully stopped, false otherwise.
-
bool send_service_request(const std::string &service_name, const std::string &json, uint64_t &request_id, participants::Protocol Protocol)¶
Sends a request to a specified service.
Sends a request containing the given JSON data to the specified service. If successful, the request identifier is stored in the provided reference and will match the one received in the reply callback.
The function fails if there is no server for the service or if the request is malformed. The request identifier is incremented sequentially across all services.
- Parameters:
service_name – The target service name.
json – The JSON-formatted request data.
request_id – Reference to store the unique request identifier.
Protocol – The RPC protocol to be used (overloaded function, without this parameter uses ROS2 by default).
- Returns:
true if the request was successfully sent, false otherwise.
-
bool send_service_reply(const std::string &service_name, const std::string &json, const uint64_t request_id)¶
Sends a reply to the given service.
This function sends a reply to the specified service with the provided JSON data. It returns a boolean indicating whether the operation was successful. Failure may occur if the service was not previously created or if the request ID does not match any request.
Note
The request_id must coincide with the one received in the request.
- Parameters:
service_name – The name of the service to send the reply to.
json – The JSON data to be sent with the reply.
request_id – The unique identifier of the request to which this reply corresponds.
- Returns:
true if the reply was successfully sent, false otherwise.
-
bool announce_action(const std::string &action_name, participants::Protocol Protocol)¶
Creates server for the given action.
This function announces an action by setting up a server for it. It returns a boolean indicating whether the operation was successful. Failure may occur if there is an issue requesting the data types to user’s app.
- Parameters:
action_name – The name of the action to be announced.
Protocol – The RPC protocol to be used (overloaded function, without this parameter uses ROS2 by default).
- Returns:
true if the action was successfully announced, false otherwise.
-
bool revoke_action(const std::string &action_name)¶
Stops the server for the given action.
This function revokes the server associated with the specified action. It returns a boolean indicating whether the operation was successful. Failure may occur if the action was not previously announced.
- Parameters:
action_name – The name of the action to be stopped.
- Returns:
true if the action was successfully stopped, false otherwise.
-
bool send_action_feedback(const char *action_name, const char *json, const participants::UUID &goal_id)¶
Send feedback for the specified goal_id action.
This function sends feedback for the specified action goal identified by the given goal ID. It returns a boolean indicating whether the operation was successful.
- Parameters:
action_name – The name of the action for which the feedback is being sent.
json – The JSON data to be sent as feedback.
goal_id – The unique identifier of the action goal for which the feedback is being sent.
- Returns:
true if the feedback was successfully sent, false otherwise.
-
bool send_action_result(const char *action_name, const participants::UUID &goal_id, const participants::StatusCode &status_code, const char *json)¶
Send result for the specified goal_id action.
This function sends the result for the specified action goal identified by the given goal ID. It returns a boolean indicating whether the operation was successful.
- Parameters:
action_name – The name of the action for which the result is being sent.
goal_id – The unique identifier of the action goal for which the result is being sent.
status_code – The status code representing the result of the action.
json – The JSON data to be sent as the result.
- Returns:
true if the result was successfully sent, false otherwise.
-
bool send_action_cancel_goal_reply(const char *action_name, const std::vector<participants::UUID> &goal_ids, const participants::CancelCode &cancel_code, const uint64_t request_id)¶
Sends a cancel goal reply for the specified action.
This function sends a reply for a cancel goal request for the specified action. It returns a boolean indicating whether the operation was successful.
- Parameters:
action_name – The name of the action for which the cancel goal reply is being sent.
goal_ids – The unique identifiers of the action goals for which the cancel goal reply is being sent.
cancel_code – The cancel code representing the result of the cancel goal request.
request_id – The unique identifier of the cancel goal request.
- Returns:
true if the cancel goal reply was successfully sent, false otherwise.
-
bool update_action_status(const std::string &action_name, const participants::UUID &goal_id, const participants::StatusCode &status_code)¶
Publishes an update for the status of an action.
This function publishes a msg update for the status of an action. It returns a boolean indicating whether the operation was successful. Failure may occur if the action was not previously announced or if the goal ID is not currently active.
- Parameters:
action_name – The name of the action for which the status is being updated.
goal_id – The unique identifier of the action goal for which the status is being updated.
status_code – The status code representing the current state of the action.
- Returns:
true if the status update was successfully sent, false otherwise.
-
bool send_action_goal(const std::string &action_name, const std::string &json, participants::UUID &goal_id, participants::Protocol Protocol)¶
Sends an action goal to the specified action.
This function sends an action goal to the specified action with the provided JSON data. It returns a boolean indicating whether the operation was successful. Failure may occur if the action server was not previously created, if the action types are unknown or if the action goal is malformed.
The goal_id is a unique identifier for the action goal and is generated by the function.
- Parameters:
action_name – The name of the action to send the goal to.
json – The JSON data to be sent with the action goal.
goal_id – Reference to store the unique identifier of the action goal.
Protocol – The RPC protocol to be used (overloaded function, without this parameter uses ROS2 by default).
- Returns:
true if the action goal was successfully sent, false otherwise.
-
bool cancel_action_goal(const std::string &action_name, const participants::UUID &goal_id, const int64_t timestamp = 0)¶
Cancels an action goal for the specified action.
This function sends a request to an action server to cancel: If the goal ID is empty and timestamp is zero, cancel all goals If the goal ID is empty and timestamp is not zero, cancel all goals accepted at or before the timestamp If the goal ID is not empty and timestamp is zero, cancel the goal with the given ID regardless of the time it was accepted If the goal ID is not empty and timestamp is not zero, cancel the goal with the given ID and all goals accepted at or before the timestamp The success of the operation only indicates that the cancel request was sent, not that it was processed. The actual cancellation of the goals would be notified via a status update of each individual action.
- Parameters:
action_name – The name of the action for which the goal is to be canceled.
goal_id – The unique identifier of the action goal to be canceled or empty to cancel all goals.
timestamp – The acceptance timestamp of the goal to be canceled.
- Returns:
true if the cancel action request was successfully sent, false otherwise.
-
DDSEnabler(const yaml::EnablerConfiguration &configuration, const CallbackSet &callbacks)¶