15 #include "rclcpp/parameter.hpp"
22 #include "rclcpp/node_interfaces/node_parameters.hpp"
23 #include "rclcpp/utilities.hpp"
25 using rclcpp::ParameterType;
28 Parameter::Parameter()
34 : name_(name), value_()
39 : name_(name), value_(value)
44 :
Parameter(parameter_info.descriptor.name, parameter_info.value)
51 return this->name_ == rhs.name_ && this->value_ == rhs.value_;
57 return !(*
this == rhs);
78 rcl_interfaces::msg::ParameterValue
93 return get_value<ParameterType::PARAMETER_BOOL>();
99 return get_value<ParameterType::PARAMETER_INTEGER>();
105 return get_value<ParameterType::PARAMETER_DOUBLE>();
111 return get_value<ParameterType::PARAMETER_STRING>();
114 const std::vector<uint8_t> &
117 return get_value<ParameterType::PARAMETER_BYTE_ARRAY>();
120 const std::vector<bool> &
123 return get_value<ParameterType::PARAMETER_BOOL_ARRAY>();
126 const std::vector<int64_t> &
129 return get_value<ParameterType::PARAMETER_INTEGER_ARRAY>();
132 const std::vector<double> &
135 return get_value<ParameterType::PARAMETER_DOUBLE_ARRAY>();
138 const std::vector<std::string> &
141 return get_value<ParameterType::PARAMETER_STRING_ARRAY>();
147 return Parameter(parameter.name, parameter.value);
150 rcl_interfaces::msg::Parameter
153 rcl_interfaces::msg::Parameter parameter;
154 parameter.name = name_;
168 std::stringstream ss;
169 ss <<
"\"" << param.
get_name() <<
"\": ";
178 os << std::to_string(pv);
185 os << std::to_string(parameters);
192 std::stringstream ss;
193 ss <<
"{\"name\": \"" << param.
get_name() <<
"\", ";
200 std::to_string(
const std::vector<rclcpp::Parameter> & parameters)
202 std::stringstream ss;
205 for (
const auto & pv : parameters) {
206 if (first ==
false) {
Store the type and value of a parameter.
RCLCPP_PUBLIC rcl_interfaces::msg::ParameterValue to_value_msg() const
Return a message populated with the parameter value.
RCLCPP_PUBLIC ParameterType get_type() const
Return an enum indicating the type of the set value.
Structure to store an arbitrary parameter with templated get/set methods.
RCLCPP_PUBLIC const std::vector< bool > & as_bool_array() const
Get value of parameter as bool array (vector<bool>).
static RCLCPP_PUBLIC Parameter from_parameter_msg(const rcl_interfaces::msg::Parameter ¶meter)
Convert a parameter message in a Parameter class object.
RCLCPP_PUBLIC const std::string & as_string() const
Get value of parameter as string.
RCLCPP_PUBLIC int64_t as_int() const
Get value of parameter as integer.
RCLCPP_PUBLIC const std::vector< double > & as_double_array() const
Get value of parameter as double array (vector<double>).
RCLCPP_PUBLIC std::string get_type_name() const
Get the type name of the parameter.
RCLCPP_PUBLIC const std::vector< uint8_t > & as_byte_array() const
Get value of parameter as byte array (vector<uint8_t>).
RCLCPP_PUBLIC Parameter()
Construct with an empty name and a parameter value of type rclcpp::PARAMETER_NOT_SET.
RCLCPP_PUBLIC rcl_interfaces::msg::Parameter to_parameter_msg() const
Convert the class in a parameter message.
RCLCPP_PUBLIC bool operator!=(const Parameter &rhs) const
Not equal operator.
RCLCPP_PUBLIC const std::string & get_name() const
Get the name of the parameter.
RCLCPP_PUBLIC std::string value_to_string() const
Get value of parameter as a string.
RCLCPP_PUBLIC const std::vector< int64_t > & as_integer_array() const
Get value of parameter as integer array (vector<int64_t>).
RCLCPP_PUBLIC const rclcpp::ParameterValue & get_parameter_value() const
Get the internal storage for the parameter value.
RCLCPP_PUBLIC ParameterType get_type() const
Get the type of the parameter.
RCLCPP_PUBLIC rcl_interfaces::msg::ParameterValue get_value_message() const
Get value of parameter as a parameter message.
RCLCPP_PUBLIC double as_double() const
Get value of parameter as double.
RCLCPP_PUBLIC const std::vector< std::string > & as_string_array() const
Get value of parameter as string array (vector<std::string>).
RCLCPP_PUBLIC bool operator==(const Parameter &rhs) const
Equal operator.
RCLCPP_PUBLIC bool as_bool() const
Get value of parameter as boolean.
RCLCPP_PUBLIC std::string to_string(const FutureReturnCode &future_return_code)
String conversion function for FutureReturnCode.
RCLCPP_PUBLIC std::ostream & operator<<(std::ostream &os, const FutureReturnCode &future_return_code)
Stream operator for FutureReturnCode.
RCLCPP_PUBLIC std::string _to_json_dict_entry(const Parameter ¶m)
Return a json encoded version of the parameter intended for a dict.