5 #include <foxglove_bridge/param_utils.hpp>
10 const auto type = value.
getType();
12 if (type == XmlRpc::XmlRpcValue::Type::TypeBoolean) {
14 }
else if (type == XmlRpc::XmlRpcValue::Type::TypeInt) {
16 }
else if (type == XmlRpc::XmlRpcValue::Type::TypeDouble) {
18 }
else if (type == XmlRpc::XmlRpcValue::Type::TypeString) {
20 }
else if (type == XmlRpc::XmlRpcValue::Type::TypeStruct) {
21 std::unordered_map<std::string, foxglove::ParameterValue> paramMap;
22 for (
const auto& [elementName, elementVal] : value) {
23 paramMap.insert({elementName,
fromRosParam(elementVal)});
26 }
else if (type == XmlRpc::XmlRpcValue::Type::TypeArray) {
27 std::vector<foxglove::ParameterValue> paramVec;
28 for (
int i = 0; i < value.
size(); ++i) {
32 }
else if (type == XmlRpc::XmlRpcValue::Type::TypeInvalid) {
33 throw std::runtime_error(
"Parameter not set");
35 throw std::runtime_error(
"Unsupported parameter type: " + std::to_string(type));
44 const auto paramType =
param.getType();
46 return param.getValue<
bool>();
48 return static_cast<int>(
param.getValue<int64_t>());
50 return param.getValue<
double>();
52 return param.getValue<std::string>();
55 const auto& paramMap =
56 param.getValue<std::unordered_map<std::string, foxglove::ParameterValue>>();
57 for (
const auto& [paramName, paramElement] : paramMap) {
58 valueStruct[paramName] =
toRosParam(paramElement);
63 const auto vec =
param.getValue<std::vector<foxglove::ParameterValue>>();
64 for (
int i = 0; i < static_cast<int>(vec.size()); ++i) {
69 throw std::runtime_error(
"Unsupported parameter type");
76 std::vector<std::regex> result;
77 for (
const auto& pattern : patterns) {
80 std::regex(pattern, std::regex_constants::ECMAScript | std::regex_constants::icase));