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 bestEffortQosTopicWhiteListDescription = rcl_interfaces::msg::ParameterDescriptor{};
89 bestEffortQosTopicWhiteListDescription.type =
90 rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
91 bestEffortQosTopicWhiteListDescription.description =
92 "List of regular expressions (ECMAScript) for topics that should be forced to use "
93 "'best_effort' QoS. Unmatched topics will use 'reliable' QoS if ALL publishers are 'reliable', "
94 "'best_effort' if any publishers are 'best_effort'.";
95 bestEffortQosTopicWhiteListDescription.read_only =
true;
97 bestEffortQosTopicWhiteListDescription);
99 auto topicWhiteListDescription = rcl_interfaces::msg::ParameterDescriptor{};
101 topicWhiteListDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
102 topicWhiteListDescription.description =
103 "List of regular expressions (ECMAScript) of whitelisted topic names.";
104 topicWhiteListDescription.read_only =
true;
106 topicWhiteListDescription);
108 auto serviceWhiteListDescription = rcl_interfaces::msg::ParameterDescriptor{};
110 serviceWhiteListDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
111 serviceWhiteListDescription.description =
112 "List of regular expressions (ECMAScript) of whitelisted service names.";
113 serviceWhiteListDescription.read_only =
true;
115 serviceWhiteListDescription);
117 auto paramWhiteListDescription = rcl_interfaces::msg::ParameterDescriptor{};
119 paramWhiteListDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
120 paramWhiteListDescription.description =
121 "List of regular expressions (ECMAScript) of whitelisted parameter names.";
122 paramWhiteListDescription.read_only =
true;
124 paramWhiteListDescription);
126 auto useCompressionDescription = rcl_interfaces::msg::ParameterDescriptor{};
128 useCompressionDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_BOOL;
129 useCompressionDescription.description =
130 "Use websocket compression (permessage-deflate). Suited for connections with smaller bandwith, "
131 "at the cost of additional CPU load.";
132 useCompressionDescription.read_only =
true;
135 auto paramCapabilities = rcl_interfaces::msg::ParameterDescriptor{};
137 paramCapabilities.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
138 paramCapabilities.description =
"Server capabilities";
139 paramCapabilities.read_only =
true;
140 node->declare_parameter(
146 auto clientTopicWhiteListDescription = rcl_interfaces::msg::ParameterDescriptor{};
148 clientTopicWhiteListDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
149 clientTopicWhiteListDescription.description =
150 "List of regular expressions (ECMAScript) of whitelisted client-published topic names.";
151 clientTopicWhiteListDescription.read_only =
true;
153 paramWhiteListDescription);
155 auto includeHiddenDescription = rcl_interfaces::msg::ParameterDescriptor{};
157 includeHiddenDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_BOOL;
158 includeHiddenDescription.description =
"Include hidden topics and services";
159 includeHiddenDescription.read_only =
true;
162 auto disableLoanMessageDescription = rcl_interfaces::msg::ParameterDescriptor{};
164 disableLoanMessageDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_BOOL;
165 disableLoanMessageDescription.description =
166 "Do not publish as loaned message when publishing a client message";
167 disableLoanMessageDescription.read_only =
true;
170 auto assetUriAllowlistDescription = rcl_interfaces::msg::ParameterDescriptor{};
172 assetUriAllowlistDescription.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING_ARRAY;
173 assetUriAllowlistDescription.description =
174 "List of regular expressions (ECMAScript) of whitelisted asset URIs.";
175 assetUriAllowlistDescription.read_only =
true;
176 node->declare_parameter(
178 std::vector<std::string>(
179 {
"^package://(?:\\w+/"
180 ")*\\w+\\.(?:dae|fbx|glb|gltf|jpeg|jpg|mtl|obj|png|stl|tif|tiff|urdf|webp|xacro)$"}),
181 paramWhiteListDescription);
185 const std::vector<std::string>& strings) {
186 std::vector<std::regex> regexVector;
187 regexVector.reserve(strings.size());
189 for (
const auto& pattern : strings) {
191 regexVector.push_back(
192 std::regex(pattern, std::regex_constants::ECMAScript | std::regex_constants::icase));
193 }
catch (
const std::exception& ex) {
194 RCLCPP_ERROR(node->get_logger(),
"Ignoring invalid regular expression '%s': %s",
195 pattern.c_str(), ex.what());