SetRos2Parameter Class
Set any ROS2 parameter on any node at runtime via the standard set_parameters service. More...
Declaration
Included Headers
Base class
| class | ServiceClientBehaviorBase<ServiceT> |
|
A base class for behaviors which need to send a request to a ROS service client and wait for a result. More... | |
Public Constructors Index
| SetRos2Parameter (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources) | |
| SetRos2Parameter (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< ClientInterfaceBase< SetParameters > > client_interface) | |
Private Member Functions Index
| tl::expected< std::string, std::string > | getServiceName () override |
|
User-provided function to get the name of the service when initializing the service client. More... | |
| tl::expected< std::chrono::duration< double >, std::string > | getResponseTimeout () override |
|
Optional user-provided function to set the timeout used when waiting for the service response. More... | |
| tl::expected< std::chrono::duration< double >, std::string > | getWaitForServerAvailableTimeout () override |
|
Optional user-provided function to set the timeout used when waiting for the service server to be available. More... | |
| tl::expected< SetParameters::Request, std::string > | createRequest () override |
|
Creates a SetParameters request with a single parameter parsed from port values. More... | |
| tl::expected< bool, std::string > | processResponse (const SetParameters::Response &response) override |
|
Checks whether the parameter was set successfully. More... | |
| std::shared_future< tl::expected< bool, std::string > > & | getFuture () override |
|
Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member. More... | |
Private Member Attributes Index
| std::shared_future< tl::expected< bool, std::string > > | future_ |
|
Holds the result of calling the service asynchronously. More... | |
Public Static Functions Index
| static BT::PortsList | providedPorts () |
| static BT::KeyValueVector | metadata () |
Description
Set any ROS2 parameter on any node at runtime via the standard set_parameters service.
This Behavior calls the node_name/set_parameters service to update a single parameter. It accepts the parameter value as a string and parses it according to the specified type. Useful for tuning Nav2 costmap parameters (e.g. robot_radius, footprint), controller gains, or any other parameter exposed via the standard ROS2 parameter service.
For array types, provide comma-separated values (e.g. "0.1,0.2,0.3" for double_array).
| Data Port Name | Port Type | Object Type |
|---|---|---|
| node_name | input | std::string |
| parameter_name | input | std::string |
| parameter_value | input | std::string |
| parameter_type | input | std::string |
| response_timeout | input | double |
| wait_for_server_available_timeout | input | double |
Definition at line 51 of file set_ros2_parameter.hpp.
Public Constructors
SetRos2Parameter()
| explicit |
Declaration at line 54 of file set_ros2_parameter.hpp, definition at line 301 of file set_ros2_parameter.cpp.
SetRos2Parameter()
| explicit |
Declaration at line 57 of file set_ros2_parameter.hpp, definition at line 307 of file set_ros2_parameter.cpp.
Private Member Functions
createRequest()
| virtual |
Creates a SetParameters request with a single parameter parsed from port values.
- Returns
The request message, or an error string if port reading or value parsing fails.
Declaration at line 75 of file set_ros2_parameter.hpp, definition at line 381 of file set_ros2_parameter.cpp.
getFuture()
| inline virtual |
Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member.
Definition at line 85 of file set_ros2_parameter.hpp.
getResponseTimeout()
| virtual |
Optional user-provided function to set the timeout used when waiting for the service response.
If no user-defined implementation is provided, the default implementation returns a negative duration, which will cause the service client to wait for the response without timing out.
- Returns
Returns the service response timeout duration. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Declaration at line 68 of file set_ros2_parameter.hpp, definition at line 361 of file set_ros2_parameter.cpp.
getServiceName()
| virtual |
User-provided function to get the name of the service when initializing the service client.
- Returns
Returns the name of the service. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Declaration at line 66 of file set_ros2_parameter.hpp, definition at line 339 of file set_ros2_parameter.cpp.
getWaitForServerAvailableTimeout()
| virtual |
Optional user-provided function to set the timeout used when waiting for the service server to be available.
If no user-defined implementation is provided, the default implementation returns 3.0 seconds, which will be the timeout duration for waiting for the service server to become available.
- Returns
Returns the service server wait timeout duration. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.
Declaration at line 69 of file set_ros2_parameter.hpp, definition at line 371 of file set_ros2_parameter.cpp.
processResponse()
|
Checks whether the parameter was set successfully.
- Parameters
-
response Response message received from the service server.
- Returns
True if successful, false with reason if the parameter could not be set.
Declaration at line 82 of file set_ros2_parameter.hpp, definition at line 404 of file set_ros2_parameter.cpp.
Private Member Attributes
future_
|
Holds the result of calling the service asynchronously.
Definition at line 93 of file set_ros2_parameter.hpp.
Public Static Functions
metadata()
| static |
Declaration at line 63 of file set_ros2_parameter.hpp, definition at line 334 of file set_ros2_parameter.cpp.
providedPorts()
| static |
Declaration at line 61 of file set_ros2_parameter.hpp, definition at line 314 of file set_ros2_parameter.cpp.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.