4 #include <foxglove_bridge/param_utils.hpp> 9 auto portDescription = rcl_interfaces::msg::ParameterDescriptor{};
11 portDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_INTEGER;
12 portDescription.description =
"The TCP port to bind the WebSocket server to";
13 portDescription.read_only =
true;
14 portDescription.additional_constraints =
15 "Must be a valid TCP port number, or 0 to use a random port";
16 portDescription.integer_range.resize(1);
17 portDescription.integer_range[0].from_value = 0;
18 portDescription.integer_range[0].to_value = 65535;
19 portDescription.integer_range[0].step = 1;
22 auto addressDescription = rcl_interfaces::msg::ParameterDescriptor{};
24 addressDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING;
25 addressDescription.description =
"The host address to bind the WebSocket server to";
26 addressDescription.read_only =
true;
29 auto sendBufferLimitDescription = rcl_interfaces::msg::ParameterDescriptor{};
31 sendBufferLimitDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_INTEGER;
32 sendBufferLimitDescription.description =
33 "Connection send buffer limit in bytes. Messages will be dropped when a connection's send " 34 "buffer reaches this limit to avoid a queue of outdated messages building up.";
35 sendBufferLimitDescription.integer_range.resize(1);
36 sendBufferLimitDescription.integer_range[0].from_value = 0;
37 sendBufferLimitDescription.integer_range[0].to_value = std::numeric_limits<int64_t>::max();
38 sendBufferLimitDescription.read_only =
true;
40 sendBufferLimitDescription);
42 auto useTlsDescription = rcl_interfaces::msg::ParameterDescriptor{};
44 useTlsDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_BOOL;
45 useTlsDescription.description =
"Use Transport Layer Security for encrypted communication";
46 useTlsDescription.read_only =
true;
47 node->declare_parameter(
PARAM_USETLS,
false, useTlsDescription);
49 auto certfileDescription = rcl_interfaces::msg::ParameterDescriptor{};
51 certfileDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING;
52 certfileDescription.description =
"Path to the certificate to use for TLS";
53 certfileDescription.read_only =
true;
56 auto keyfileDescription = rcl_interfaces::msg::ParameterDescriptor{};
58 keyfileDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING;
59 keyfileDescription.description =
"Path to the private key to use for TLS";
60 keyfileDescription.read_only =
true;
61 node->declare_parameter(
PARAM_KEYFILE,
"", keyfileDescription);
63 auto minQosDepthDescription = rcl_interfaces::msg::ParameterDescriptor{};
65 minQosDepthDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_INTEGER;
66 minQosDepthDescription.description =
"Minimum depth used for the QoS profile of subscriptions.";
67 minQosDepthDescription.read_only =
true;
68 minQosDepthDescription.additional_constraints =
"Must be a non-negative integer";
69 minQosDepthDescription.integer_range.resize(1);
70 minQosDepthDescription.integer_range[0].from_value = 0;
71 minQosDepthDescription.integer_range[0].to_value = INT32_MAX;
72 minQosDepthDescription.integer_range[0].step = 1;
75 auto maxQosDepthDescription = rcl_interfaces::msg::ParameterDescriptor{};
77 maxQosDepthDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_INTEGER;
78 maxQosDepthDescription.description =
"Maximum depth used for the QoS profile of subscriptions.";
79 maxQosDepthDescription.read_only =
true;
80 maxQosDepthDescription.additional_constraints =
"Must be a non-negative integer";
81 maxQosDepthDescription.integer_range.resize(1);
82 maxQosDepthDescription.integer_range[0].from_value = 0;
83 maxQosDepthDescription.integer_range[0].to_value = INT32_MAX;
84 maxQosDepthDescription.integer_range[0].step = 1;
87 auto topicWhiteListDescription = rcl_interfaces::msg::ParameterDescriptor{};
89 topicWhiteListDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
90 topicWhiteListDescription.description =
91 "List of regular expressions (ECMAScript) of whitelisted topic names.";
92 topicWhiteListDescription.read_only =
true;
94 topicWhiteListDescription);
96 auto serviceWhiteListDescription = rcl_interfaces::msg::ParameterDescriptor{};
98 serviceWhiteListDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
99 serviceWhiteListDescription.description =
100 "List of regular expressions (ECMAScript) of whitelisted service names.";
101 serviceWhiteListDescription.read_only =
true;
103 serviceWhiteListDescription);
105 auto paramWhiteListDescription = rcl_interfaces::msg::ParameterDescriptor{};
107 paramWhiteListDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
108 paramWhiteListDescription.description =
109 "List of regular expressions (ECMAScript) of whitelisted parameter names.";
110 paramWhiteListDescription.read_only =
true;
112 paramWhiteListDescription);
114 auto useCompressionDescription = rcl_interfaces::msg::ParameterDescriptor{};
116 useCompressionDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_BOOL;
117 useCompressionDescription.description =
118 "Use websocket compression (permessage-deflate). Suited for connections with smaller bandwith, " 119 "at the cost of additional CPU load.";
120 useCompressionDescription.read_only =
true;
123 auto paramCapabilities = rcl_interfaces::msg::ParameterDescriptor{};
125 paramCapabilities.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
126 paramCapabilities.description =
"Server capabilities";
127 paramCapabilities.read_only =
true;
128 node->declare_parameter(
134 auto clientTopicWhiteListDescription = rcl_interfaces::msg::ParameterDescriptor{};
136 clientTopicWhiteListDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
137 clientTopicWhiteListDescription.description =
138 "List of regular expressions (ECMAScript) of whitelisted client-published topic names.";
139 clientTopicWhiteListDescription.read_only =
true;
141 paramWhiteListDescription);
143 auto includeHiddenDescription = rcl_interfaces::msg::ParameterDescriptor{};
145 includeHiddenDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_BOOL;
146 includeHiddenDescription.description =
"Include hidden topics and services";
147 includeHiddenDescription.read_only =
true;
152 const std::vector<std::string>& strings) {
153 std::vector<std::regex> regexVector;
154 regexVector.reserve(strings.size());
156 for (
const auto& pattern : strings) {
158 regexVector.push_back(
159 std::regex(pattern, std::regex_constants::ECMAScript | std::regex_constants::icase));
160 }
catch (
const std::exception& ex) {
161 RCLCPP_ERROR(node->get_logger(),
"Ignoring invalid regular expression '%s': %s",
162 pattern.c_str(), ex.what());
constexpr char PARAM_USE_COMPRESSION[]
constexpr char PARAM_CAPABILITIES[]
constexpr char PARAM_SEND_BUFFER_LIMIT[]
constexpr char PARAM_KEYFILE[]
constexpr char PARAM_INCLUDE_HIDDEN[]
constexpr char PARAM_CERTFILE[]
constexpr char PARAM_MIN_QOS_DEPTH[]
constexpr char PARAM_USETLS[]
constexpr char PARAM_ADDRESS[]
constexpr char PARAM_PORT[]
constexpr char PARAM_MAX_QOS_DEPTH[]
constexpr int64_t DEFAULT_MAX_QOS_DEPTH
constexpr char PARAM_TOPIC_WHITELIST[]
constexpr char PARAM_PARAMETER_WHITELIST[]
constexpr char PARAM_CLIENT_TOPIC_WHITELIST[]
constexpr int64_t DEFAULT_SEND_BUFFER_LIMIT
void declareParameters(rclcpp::Node *node)
constexpr char PARAM_SERVICE_WHITELIST[]
std::vector< std::regex > parseRegexStrings(rclcpp::Node *node, const std::vector< std::string > &strings)
constexpr char DEFAULT_ADDRESS[]
constexpr int DEFAULT_PORT
constexpr int64_t DEFAULT_MIN_QOS_DEPTH
constexpr std::array< const char *, 5 > DEFAULT_CAPABILITIES