Default Services In Sugarcoat Components#
In addition to the standard ROS2 Lifecycle Node services, Sugarcoat Components provide a powerful set of built-in services for live reconfiguration. These services allow you to dynamically adjust inputs, outputs, and parameters on-the-fly, making it easier to respond to changing runtime conditions or trigger intelligent behavior in response to events. Like any ROS2 services, they can be called from other Nodes or with the ROS2 CLI, and can also be called programmatically as part of an action sequence or event-driven workflow in the launch script.
Replacing an Input or Output with a different Topic#
You can swap an existing topic connection (input or output) with a different topic online without restarting your script. The service will stop the running lifecycle node, replace the connection and restart it again.
Service Name: /{component_name}/change_topic
Service Type: automatika_ros_sugar/srv/ReplaceTopic
📥 Request#
Field |
Type |
Description |
---|---|---|
|
|
Direction of the topic to replace. Use |
|
|
The full name of the currently connected topic you want to replace. |
|
|
The full name of the new topic to connect. |
|
|
Fully qualified message type of the new topic (see supported types). |
📤 Response#
Field |
Type |
Description |
---|---|---|
|
|
Indicates whether the topic replacement was successful. |
|
|
If unsuccessful, this provides a description of the failure. |
Example#
To replace the output topic name of the AwesomeComponent
created in the previous example, we can send the following service e call to the node:
ros2 service call /awesome_component/change_topic automatika_ros_sugar/srv/ReplaceTopic "{direction: 1, old_name: '/voice', new_name: '/audio_device_0', new_msg_type: 'Audio'}"
Updating a configuration parameter value#
This ChangeParameter
service allows updating a single configuration parameter at runtime. You can choose whether the component remains active during the change, or temporarily deactivates for a safe update.
Service Name: /{component_name}/update_config_parameter
Service Type: automatika_ros_sugar/srv/ChangeParameter
📥 Request#
Field |
Type |
Description |
---|---|---|
|
|
Name of the parameter to change with nested attributes if needed |
|
|
New value for the parameter (as a string, internally converted to proper type). |
|
|
If |
📤 Response#
Field |
Type |
Description |
---|---|---|
|
|
Indicates if the parameter was successfully updated. |
|
|
If failed, provides a descriptive error message. |
Example#
Lets change the loop_rate
for our AwesomeComponent
to 1Hz
with restarting the node:
ros2 service call /awesome_component/update_config_parameter automatika_ros_sugar/srv/ChangeParameter "{name: 'loop_rate', value: '1', keep_alive: false}"
Updating a set of configuration parameters#
The ChangeParameters
service allows updating multiple parameters at once, making it ideal for switching modes, profiles, or reconfiguring components in batches. Similar to ChangeParameter
service, you can choose whether the component stays active or temporarily deactivates during the update.
Service Name: /{component_name}/update_config_parameters
Service Type: automatika_ros_sugar/srv/ChangeParameters
📥 Request#
Field |
Type |
Description |
---|---|---|
|
|
List of parameter names to update |
|
|
New values for each parameter, given as strings (converted internally). |
|
|
If |
📤 Response#
Field |
Type |
Description |
---|---|---|
|
|
A list of success flags for each parameter update. |
|
|
A list of error messages (or empty strings) corresponding to each parameter. |
Example#
Lets change multiple parameters at once for our AwesomeComponent
with restarting the node:
ros2 service call /awesome_component/update_config_parameters automatika_ros_sugar/srv/ChangeParameters "{names: ['loop_rate', 'fallback_rate'], values: ['1', '10'], keep_alive: false}"
Reconfiguring the Component from a given file#
The ConfigureFromFile
service lets you reconfigure an entire component from a YAML, JSON or TOML configuration file while the node is online. This is useful for applying scenario-specific settings, or restoring saved configurations—all in a single operation.
Service Name: /{component_name}/configure_from_file
Service Type: automatika_ros_sugar/srv/ConfigureFromFile
📥 Request#
Field |
Type |
Description |
---|---|---|
|
|
Absolute path to the file containing the parameters under the component name. |
|
|
If |
📤 Response#
Field |
Type |
Description |
---|---|---|
|
|
Indicates whether the file re-configuration update was successful. |
|
|
If failed, provides a descriptive error message. |
Example#
Example YAML configuration file for our AwesomeComponent
:
/**: # Common parameters for all components
fallback_rate: 10.0
# Parameters specific to component under component name
awesome_component:
loop_rate: 100.0
Executing a Component’s method#
The ExecuteMethod
service enables runtime invocation of any class method in the component. This is useful for triggering specific behaviors, tools, or diagnostics during runtime without writing additional interfaces.
Service Name: /{component_name}/execute_method
Service Type: automatika_ros_sugar/srv/ExecuteMethod
📥 Request#
Field |
Type |
Description |
---|---|---|
|
|
The name of the method to invoke (as registered by the component). |
|
|
A JSON-formatted string containing the method’s keyword arguments. Example: |
📤 Response#
Field |
Type |
Description |
---|---|---|
|
|
Indicates whether the method call was successful. |
|
|
If failed, provides a descriptive error message. |