settings_helpers.hpp
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // © Copyright 2020, Septentrio NV/SA.
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // 1. Redistributions of source code must retain the above copyright
9 // notice, node list of conditions and the following disclaimer.
10 // 2. Redistributions in binary form must reproduce the above copyright
11 // notice, node list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // 3. Neither the name of the copyright holder nor the names of its
14 // contributors may be used to endorse or promote products derived
15 // from node software without specific prior written permission.
16 //
17 // node SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF node SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 // *****************************************************************************
30 
31 #pragma once
32 
33 #include "settings.hpp"
34 #ifdef ROS1
36 #endif
37 #ifdef ROS2
39 #endif
40 
41 namespace settings {
42 
43  // Check uniqueness of IPS ids
45  {
46  if (!settings.tcp_ip_server.empty())
47  {
48  if (settings.tcp_ip_server == settings.udp_ip_server)
49  node->log(
51  "stream_device.tcp.ip_server and stream_device.udp.ip_server cannot use the same IP server");
52  for (size_t i = 0; i < settings.rtk.ip_server.size(); ++i)
53  {
54  if (settings.tcp_ip_server == settings.rtk.ip_server[i].id)
55  node->log(
57  "stream_device.tcp.ip_server and rtk_settings.ip_server_" +
58  std::to_string(i + 1) +
59  ".id cannot use the same IP server");
60  }
61  }
62  if (!settings.udp_ip_server.empty())
63  {
64  for (size_t i = 0; i < settings.rtk.ip_server.size(); ++i)
65  {
66  if (settings.udp_ip_server == settings.rtk.ip_server[i].id)
67  node->log(
69  "stream_device.udp.ip_server and rtk_settings.ip_server_" +
70  std::to_string(i + 1) +
71  ".id cannot use the same IP server");
72  }
73  }
74  if (settings.rtk.ip_server.size() == 2)
75  {
76  if (!settings.rtk.ip_server[0].id.empty() &&
77  (settings.rtk.ip_server[0].id == settings.rtk.ip_server[1].id))
78  node->log(
80  "rtk_settings.ip_server_1.id and rtk_settings.ip_server_2.id cannot use the same IP server");
81  }
82  }
83 
84  // Check uniqueness of IPS ports
86  {
87  if (settings.tcp_port != 0)
88  {
89  if (std::to_string(settings.tcp_port) == settings.device_tcp_port)
90  node->log(
92  "stream_device.tcp.port and device port cannot be the same");
93  for (size_t i = 0; i < settings.rtk.ip_server.size(); ++i)
94  {
95  if (settings.tcp_port == settings.rtk.ip_server[i].port)
96  node->log(log_level::ERROR,
97  "stream_device.tcp.port and rtk_settings.ip_server_" +
98  std::to_string(i + 1) +
99  ".port cannot be the same!");
100  }
101  }
102  if (settings.rtk.ip_server.size() == 2)
103  {
104  if ((settings.rtk.ip_server[0].port != 0) &&
105  (settings.rtk.ip_server[0].port == settings.rtk.ip_server[1].port))
106  node->log(
108  "rtk_settings.ip_server_1.port and rtk_settings.ip_server_2.port cannot be the same");
109  }
110  }
111 
112  // Check uniqueness of IPS id for VSM
114  {
115  if (!settings.ins_vsm.ip_server.empty())
116  {
117  if (!settings.tcp_ip_server.empty() &&
118  (settings.tcp_ip_server == settings.ins_vsm.ip_server))
119  node->log(
121  "stream_device.tcp.ip_server and ins_vsm.ip_server.id cannot use the same IP server");
122  if (!settings.udp_ip_server.empty() &&
123  (settings.udp_ip_server == settings.ins_vsm.ip_server))
124  node->log(
126  "stream_device.udp.ip_server and ins_vsm.ip_server.id cannot use the same IP server");
127  for (size_t i = 0; i < settings.rtk.ip_server.size(); ++i)
128  {
129  if (settings.ins_vsm.ip_server == settings.rtk.ip_server[i].id)
130  node->log(log_level::ERROR,
131  "ins_vsm.ip_server.id and rtk_settings.ip_server_" +
132  std::to_string(i + 1) +
133  ".id cannot use the same IP server");
134  }
135  }
136  }
137 
138  // Check uniqueness of IPS port for VSM
140  {
141  if (settings.ins_vsm.ip_server_port != 0)
142  {
143  if (std::to_string(settings.ins_vsm.ip_server_port) ==
144  settings.device_tcp_port)
145  node->log(
147  "device port and ins_vsm.ip_server.port cannot be the same");
148  if ((settings.tcp_port != 0) &&
149  (settings.tcp_port == settings.ins_vsm.ip_server_port))
150  node->log(
152  "stream_device.tcp.port and ins_vsm.ip_server.port cannot be the same");
153  if ((settings.udp_port != 0) &&
154  (settings.udp_port == settings.ins_vsm.ip_server_port))
155  node->log(
157  "stream_device.udp.port and ins_vsm.ip_server.port cannot be the same");
158  for (size_t i = 0; i < settings.rtk.ip_server.size(); ++i)
159  {
160  if (settings.ins_vsm.ip_server_port ==
161  settings.rtk.ip_server[i].port)
162  node->log(log_level::ERROR,
163  "ins_vsm.ip_server.port and rtk_settings.ip_server_" +
164  std::to_string(i + 1) +
165  ".port cannot use be same");
166  }
167  }
168  }
169 
171  {
172  if (settings.auto_publish && !settings.configure_rx)
173  {
174  settings.publish_gpst = true;
175  settings.publish_navsatfix = true;
176  settings.publish_gpsfix = true;
177  settings.publish_pose = true;
178  settings.publish_diagnostics = true;
179  settings.publish_aimplusstatus = true;
180  settings.publish_galauthstatus = true;
181  settings.publish_gpgga = true;
182  settings.publish_gprmc = true;
183  settings.publish_gpgsa = true;
184  settings.publish_gpgsv = true;
185  settings.publish_measepoch = true;
186  settings.publish_pvtcartesian = true;
187  settings.publish_pvtgeodetic = true;
188  settings.publish_basevectorcart = true;
189  settings.publish_basevectorgeod = true;
190  settings.publish_poscovcartesian = true;
191  settings.publish_poscovgeodetic = true;
192  settings.publish_velcovcartesian = true;
193  settings.publish_velcovgeodetic = true;
194  settings.publish_atteuler = true;
195  settings.publish_attcoveuler = true;
196  settings.publish_insnavcart = true;
197  settings.publish_insnavgeod = true;
198  settings.publish_imusetup = true;
199  settings.publish_velsensorsetup = true;
200  settings.publish_exteventinsnavgeod = true;
201  settings.publish_exteventinsnavcart = true;
202  settings.publish_extsensormeas = true;
203  settings.publish_imu = true;
204  settings.publish_localization = true;
205  settings.publish_localization_ecef = true;
206  settings.publish_twist = true;
207  if (!settings.publish_tf_ecef)
208  settings.publish_tf = true;
209  } else if (settings.auto_publish && settings.configure_rx)
210  {
211  node->log(log_level::WARN,
212  "auto_publish has no effect if configure_rx is true.");
213  }
214  }
215 
216 } // namespace settings
log_level::WARN
@ WARN
Definition: typedefs.hpp:182
settings::checkUniquenssOfIps
void checkUniquenssOfIps(ROSaicNodeBase *node, const Settings &settings)
Definition: settings_helpers.hpp:44
ROSaicNodeBase::log
void log(log_level::LogLevel logLevel, const std::string &s) const
Log function to provide abstraction of ROS loggers.
Definition: typedefs.hpp:286
settings::autoPublish
void autoPublish(ROSaicNodeBase *node, Settings &settings)
Definition: settings_helpers.hpp:170
settings::checkUniquenssOfIpsVsm
void checkUniquenssOfIpsVsm(ROSaicNodeBase *node, const Settings &settings)
Definition: settings_helpers.hpp:113
settings.hpp
ROSaicNodeBase
This class is the base class for abstraction.
Definition: typedefs.hpp:192
typedefs.hpp
Settings
Settings struct.
Definition: settings.hpp:149
settings::checkUniquenssOfIpsPortsVsm
void checkUniquenssOfIpsPortsVsm(ROSaicNodeBase *node, const Settings &settings)
Definition: settings_helpers.hpp:139
log_level::ERROR
@ ERROR
Definition: typedefs.hpp:183
settings
Definition: settings_helpers.hpp:41
typedefs_ros1.hpp
settings::checkUniquenssOfIpsPorts
void checkUniquenssOfIpsPorts(ROSaicNodeBase *node, const Settings &settings)
Definition: settings_helpers.hpp:85


septentrio_gnss_driver
Author(s): Tibor Dome, Thomas Emter
autogenerated on Sat May 10 2025 03:03:11