scanner_state_machine_def.h
Go to the documentation of this file.
1 // Copyright (c) 2020-2021 Pilz GmbH & Co. KG
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU Lesser General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
15 
20 {
21 namespace protocol_layer
22 {
24  const communication_layer::NewMessageCallback& control_msg_callback,
25  const communication_layer::ErrorCallback& control_error_callback,
26  const communication_layer::ErrorCallback& start_error_callback,
27  const communication_layer::ErrorCallback& stop_error_callback,
28  const communication_layer::NewMessageCallback& data_msg_callback,
29  const communication_layer::ErrorCallback& data_error_callback,
30  const ScannerStartedCallback& scanner_started_callback,
31  const ScannerStoppedCallback& scanner_stopped_callback,
32  const InformUserAboutLaserScanCallback& laser_scan_callback,
33  const TimeoutCallback& start_timeout_callback,
34  const TimeoutCallback& monitoring_frame_timeout_callback)
35  : config_(config)
36  , control_client_(control_msg_callback,
37  control_error_callback,
38  config_.hostUDPPortControl(), // LCOV_EXCL_LINE Lcov bug?
39  config_.clientIp(),
40  config_.scannerControlPort())
41  , data_client_(data_msg_callback,
42  data_error_callback,
43  config_.hostUDPPortData(), // LCOV_EXCL_LINE Lcov bug?
44  config_.clientIp(),
45  config_.scannerDataPort())
46  , scanner_started_callback_(scanner_started_callback)
47  , scanner_stopped_callback_(scanner_stopped_callback)
48  , start_error_callback_(start_error_callback)
49  , stop_error_callback_(stop_error_callback)
50  , inform_user_about_laser_scan_callback_(laser_scan_callback)
51  , start_timeout_callback_(start_timeout_callback)
52  , monitoring_frame_timeout_callback_(monitoring_frame_timeout_callback)
53 {
54 }
55 
56 //+++++++++++++++++++++++++++++++++ States ++++++++++++++++++++++++++++++++++++
57 
58 // clang-format off
59 #define DEFAULT_ON_ENTRY_IMPL(state_name)\
60  template <class Event, class FSM>\
61  void ScannerProtocolDef::state_name::on_entry(Event const&, FSM& fsm)\
62  {\
63  PSENSCAN_DEBUG("StateMachine", "Entering state: " #state_name);\
64  }\
65 
66 #define DEFAULT_ON_EXIT_IMPL(state_name)\
67  template <class Event, class FSM>\
68  void ScannerProtocolDef::state_name::on_exit(Event const&, FSM& fsm)\
69  {\
70  PSENSCAN_DEBUG("StateMachine", "Exiting state: " #state_name);\
71  }
72 
73 #define DEFAULT_STATE_IMPL(state_name)\
74  DEFAULT_ON_ENTRY_IMPL(state_name)\
75  DEFAULT_ON_EXIT_IMPL(state_name)
76 // clang-format on
77 
78 DEFAULT_STATE_IMPL(WaitForStopReply)
79 
81 
82 // \cond Ignore "was not declared or defined" warnings from doxygen
83 template <class Event, class FSM>
84 void ScannerProtocolDef::Idle::on_exit(Event const& /*unused*/, FSM& fsm) // NOLINT
85 {
86  PSENSCAN_DEBUG("StateMachine", "Exiting state: Idle");
87  fsm.control_client_.startAsyncReceiving();
88  fsm.data_client_.startAsyncReceiving();
89 }
90 
91 template <class Event, class FSM>
92 void ScannerProtocolDef::WaitForStartReply::on_entry(Event const& /*unused*/, FSM& fsm) // NOLINT
93 {
94  PSENSCAN_DEBUG("StateMachine", "Entering state: WaitForStartReply");
95  // Start watchdog...
96  fsm.start_reply_watchdog_ = fsm.watchdog_factory_.create(WATCHDOG_TIMEOUT, fsm.start_timeout_callback_);
97 }
98 
99 template <class Event, class FSM>
100 void ScannerProtocolDef::WaitForStartReply::on_exit(Event const& /*unused*/, FSM& fsm) // NOLINT
101 {
102  PSENSCAN_DEBUG("StateMachine", "Exiting state: WaitForStartReply");
103  // Stops the watchdog by resetting the pointer
104  fsm.start_reply_watchdog_.reset();
105 }
106 
107 template <class Event, class FSM>
108 void ScannerProtocolDef::WaitForMonitoringFrame::on_entry(Event const& /*unused*/, FSM& fsm) // NOLINT
109 {
110  PSENSCAN_DEBUG("StateMachine", "Entering state: WaitForMonitoringFrame");
111  fsm.scan_buffer_.reset();
112  // Start watchdog...
113  fsm.monitoring_frame_watchdog_ =
114  fsm.watchdog_factory_.create(WATCHDOG_TIMEOUT, fsm.monitoring_frame_timeout_callback_);
115 }
116 
117 template <class Event, class FSM>
118 void ScannerProtocolDef::WaitForMonitoringFrame::on_exit(Event const& /*unused*/, FSM& fsm) // NOLINT
119 {
120  PSENSCAN_DEBUG("StateMachine", "Exiting state: WaitForMonitoringFrame");
121  // Stops the watchdog by resetting the pointer
122  fsm.monitoring_frame_watchdog_.reset();
123 }
124 
125 template <class Event, class FSM>
126 void ScannerProtocolDef::Stopped::on_entry(Event const& /*unused*/, FSM& /*unused*/) // NOLINT
127 {
128  PSENSCAN_DEBUG("StateMachine", "Entering state: Stopped");
129 }
130 
131 DEFAULT_ON_EXIT_IMPL(Stopped)
132 
135 
136 // \endcond
137 //+++++++++++++++++++++++++++++++++ Actions +++++++++++++++++++++++++++++++++++
138 
139 template <class T>
140 inline void ScannerProtocolDef::sendStartRequest(const T& event)
141 {
142  PSENSCAN_DEBUG("StateMachine", "Action: sendStartRequest");
143 
144  if (!config_.hostIp())
145  {
146  auto host_ip{ control_client_.hostIp() };
147  config_.hostIp(host_ip.to_ulong());
148  PSENSCAN_INFO("StateMachine", "No host ip set! Using local ip: {}", host_ip.to_string());
149  }
152 }
153 
155 {
156  PSENSCAN_DEBUG("StateMachine", "Action: handleStartRequestTimeout");
157  PSENSCAN_ERROR("StateMachine",
158  "Timeout while waiting for the scanner to start! Retrying... "
159  "(Please check the ethernet connection or contact PILZ support if the error persists.)");
160  sendStartRequest(event);
161 }
162 
163 template <class T>
164 inline void ScannerProtocolDef::sendStopRequest(const T& event)
165 {
166  PSENSCAN_DEBUG("StateMachine", "Action: sendStopRequest");
167  data_client_.stop();
169 }
170 
172 {
173  PSENSCAN_DEBUG("StateMachine", "Action: handleMonitoringFrame");
175 
176  try
177  {
179  *(event.data_), event.num_bytes_) };
182  const data_conversion_layer::monitoring_frame::MessageStamped stamped_msg{ msg, event.timestamp_ };
183  informUserAboutTheScanData(stamped_msg);
184  }
185  // LCOV_EXCL_START
187  {
188  PSENSCAN_ERROR("StateMachine", e.what());
189  }
190  // LCOV_EXCL_STOP
191 }
192 
194 {
196 }
197 
199 {
201 }
202 
204 {
206  *(reply_event.data_)) };
208  fmt::format("Unknown result code {:#04x} in start reply.", static_cast<uint32_t>(msg.result())));
209 }
210 
212 {
213  start_error_callback_("Start Request refused by device.");
214 }
215 
217 {
219  *(reply_event.data_)) };
220  stop_error_callback_(fmt::format("Unknown result code {:#04x} in stop reply.", static_cast<uint32_t>(msg.result())));
221 }
222 
224 {
225  stop_error_callback_("Stop Request refused by device.");
226 }
227 
229 {
230  if (msg.hasDiagnosticMessagesField() && !msg.diagnosticMessages().empty())
231  {
233  1 /* sec */, "StateMachine", "The scanner reports an error: {}", util::formatRange(msg.diagnosticMessages()));
234  }
235 }
236 
237 inline void
239 {
240  if (!zoneset_reference_msg_.is_initialized() || (msg.scanCounter() >= zoneset_reference_msg_->scanCounter() &&
241  msg.activeZoneset() != zoneset_reference_msg_->activeZoneset()))
242  {
243  PSENSCAN_INFO("Scanner", "The scanner switched to active zoneset {}", msg.activeZoneset());
245  }
246 }
247 
250 {
251  try
252  {
253  scan_buffer_.add(stamped_msg);
255  {
257  }
258  }
259  catch (const ScanRoundError& ex)
260  {
261  PSENSCAN_WARN("ScanBuffer", ex.what());
262  }
263  if (config_.fragmentedScansEnabled()) // Send the scan fragment in any case.
264  {
265  sendMessageWithMeasurements({ stamped_msg });
266  }
267 }
268 
270  const std::vector<data_conversion_layer::monitoring_frame::MessageStamped>& stamped_msgs)
271 {
272  if (framesContainMeasurements(stamped_msgs))
273  {
274  try
275  {
277  }
278  // LCOV_EXCL_START
280  {
281  PSENSCAN_ERROR("StateMachine", ex.what());
282  }
283  // LCOV_EXCL_STOP
284  }
285 }
286 
288  const std::vector<data_conversion_layer::monitoring_frame::MessageStamped>& stamped_msgs)
289 {
290  if (std::all_of(stamped_msgs.begin(), stamped_msgs.end(), [](const auto& stamped_msg) {
291  return stamped_msg.msg_.measurements().empty();
292  }))
293  {
294  PSENSCAN_DEBUG("StateMachine", "No measurement data in current monitoring frame(s), skipping laser scan callback.");
295  return false;
296  }
297  return true;
298 }
299 
301 {
302  PSENSCAN_DEBUG("StateMachine", "Action: handleMonitoringFrameTimeout");
303 
304  PSENSCAN_WARN("StateMachine",
305  "Timeout while waiting for MonitoringFrame message."
306  " (Please check the ethernet connection or contact PILZ support if the error persists.)");
307 }
308 
309 //+++++++++++++++++++++++++++++++++ Guards ++++++++++++++++++++++++++++++++++++
310 
311 // LCOV_EXCL_START
313  : std::runtime_error(error_msg)
314 {
315 }
316 // LCOV_EXCL_STOP
317 
319 {
320  // LCOV_EXCL_START
322  {
323  throw InternalScannerReplyError("Unexpected code in reply");
324  }
326  {
328  {
329  throw InternalScannerReplyError("Request refused by device.");
330  }
331  else
332  {
333  throw InternalScannerReplyError("Unknown operation result code.");
334  }
335  }
336  // LCOV_EXCL_STOP
337 }
338 
340 {
342  *(reply_event.data_)) };
343  return isStartReply(msg) && isAcceptedReply(msg);
344 }
345 
347 {
349  *(reply_event.data_)) };
350  return isStartReply(msg) && isUnknownReply(msg);
351 }
352 
354 {
356  *(reply_event.data_)) };
357  return isStartReply(msg) && isRefusedReply(msg);
358 }
359 
361 {
363  *(reply_event.data_)) };
364  return isStopReply(msg) && isAcceptedReply(msg);
365 }
366 
368 {
370  *(reply_event.data_)) };
371  return isStopReply(msg) && isUnknownReply(msg);
372 }
373 
375 {
377  *(reply_event.data_)) };
378  return isStopReply(msg) && isRefusedReply(msg);
379 }
380 
382 {
384 }
385 
387 {
389 }
390 
392 {
394 }
395 
397 {
399 }
400 
402 {
404 }
405 
406 //++++++++++++++++++++ Special transitions ++++++++++++++++++++++++++++++++++++
407 
408 template <class FSM>
409 static std::string getStateName(const int& state_id)
410 {
411  using recursive_transition_table = typename boost::msm::back::recursive_get_transition_table<FSM>::type;
412  using states = typename boost::msm::back::generate_state_set<recursive_transition_table>::type;
413 
414  std::string mangle_state_name;
415  boost::mpl::for_each<states, boost::msm::wrap<boost::mpl::placeholders::_1> >(
416  boost::msm::back::get_state_name<recursive_transition_table>(mangle_state_name, state_id));
417  const auto full_name{ boost::core::demangle(mangle_state_name.c_str()) };
418  return full_name.substr(full_name.rfind("::") + 2);
419 }
420 
421 template <class T>
422 static std::string classNameShort(const T& t)
423 {
424  const auto full_name{ boost::core::demangle(typeid(t).name()) };
425  return full_name.substr(full_name.rfind("::") + 2);
426 }
427 
428 // LCOV_EXCL_START
429 template <class FSM, class Event>
430 void ScannerProtocolDef::exception_caught(Event const& event, FSM& /*unused*/, std::exception& exception) // NOLINT
431 {
432  PSENSCAN_ERROR("StateMachine", "Received error \"{}\". Shutting down now.", exception.what());
433  sendStopRequest(event);
434  throw exception;
435 }
436 // LCOV_EXCL_STOP
437 
438 template <class FSM, class Event>
439 void ScannerProtocolDef::no_transition(Event const& event, FSM& /*unused*/, int state) // NOLINT
440 {
441  PSENSCAN_WARN("StateMachine",
442  "No transition in state \"{}\" for event \"{}\".",
443  getStateName<FSM>(state),
444  classNameShort(event));
445 }
446 
447 template <class FSM>
449  FSM& /*unused*/,
450  int state)
451 {
452  PSENSCAN_WARN("StateMachine", "Received monitoring frame despite not waiting for it");
453 }
454 
455 } // namespace protocol_layer
456 } // namespace psen_scan_v2_standalone
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isAcceptedStopReply
bool isAcceptedStopReply(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:360
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::config_
ScannerConfiguration config_
Definition: scanner_state_machine.h:279
psen_scan_v2_standalone::protocol_layer::scanner_events::RawMonitoringFrameReceived::num_bytes_
const std::size_t num_bytes_
Definition: scanner_events.h:82
PSENSCAN_WARN
#define PSENSCAN_WARN(name,...)
Definition: logging.h:62
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::notifyUserAboutRefusedStartReply
void notifyUserAboutRefusedStartReply(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:211
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::checkForInternalErrors
void checkForInternalErrors(const data_conversion_layer::scanner_reply::Message &msg)
Definition: scanner_state_machine_def.h:318
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::InternalScannerReplyError
Exception thrown when something goes wrong with the scanner reply.
Definition: scanner_state_machine.h:240
psen_scan_v2_standalone::data_conversion_layer::stop_request::serialize
RawData serialize()
Definition: stop_request_serialization.cpp:28
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::Type::start
@ start
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isUnknownStartReply
bool isUnknownStartReply(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:346
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::result
constexpr OperationResult result() const
Definition: scanner_reply_msg.h:99
start_request_serialization.h
DEFAULT_STATE_IMPL
#define DEFAULT_STATE_IMPL(state_name)
Definition: scanner_state_machine_def.h:73
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::scanner_started_callback_
const ScannerStartedCallback scanner_started_callback_
Definition: scanner_state_machine.h:292
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::notifyUserAboutUnknownStopReply
void notifyUserAboutUnknownStopReply(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:216
psen_scan_v2_standalone::communication_layer::UdpClientImpl::write
void write(const data_conversion_layer::RawData &data)
Asynchronously sends the specified data to the other endpoint.
Definition: udp_client.h:275
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::AdditionalFieldMissing
Exception thrown if an additional field was missing during deserialization of a Message.
Definition: monitoring_frame_msg.h:49
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isStartReply
bool isStartReply(data_conversion_layer::scanner_reply::Message const &msg)
Definition: scanner_state_machine_def.h:396
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::exception_caught
void exception_caught(Event const &event, FSM &fsm, std::exception &exception)
Definition: scanner_state_machine_def.h:430
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::framesContainMeasurements
bool framesContainMeasurements(const std::vector< data_conversion_layer::monitoring_frame::MessageStamped > &stamped_msg)
Definition: scanner_state_machine_def.h:287
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::data_client_
communication_layer::UdpClientImpl data_client_
Definition: scanner_state_machine.h:289
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::handleMonitoringFrame
void handleMonitoringFrame(const scanner_events::RawMonitoringFrameReceived &event)
Definition: scanner_state_machine_def.h:171
psen_scan_v2_standalone::protocol_layer::ScannerStoppedCallback
std::function< void()> ScannerStoppedCallback
Definition: scanner_state_machine.h:86
psen_scan_v2_standalone::communication_layer::UdpClientImpl::stop
void stop()
Stops the underlying io_service so that no messages are received anymore.
Definition: udp_client.h:212
scanner_configuration.h
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::InternalScannerReplyError::InternalScannerReplyError
InternalScannerReplyError(const std::string &error_msg)
Definition: scanner_state_machine_def.h:312
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::informUserAboutTheScanData
void informUserAboutTheScanData(const data_conversion_layer::monitoring_frame::MessageStamped &stamped_msg)
Definition: scanner_state_machine_def.h:248
psen_scan_v2_standalone::data_conversion_layer::start_request::serialize
RawData serialize(const data_conversion_layer::start_request::Message &start_request, const uint32_t &seq_number=DEFAULT_SEQ_NUMBER)
Definition: start_request_serialization.cpp:52
psen_scan_v2_standalone::protocol_layer::scanner_events::RawReplyReceived
Received Start- or Stop-Reply message from scanner device.
Definition: scanner_events.h:48
psen_scan_v2_standalone::protocol_layer::InformUserAboutLaserScanCallback
std::function< void(const LaserScan &)> InformUserAboutLaserScanCallback
Definition: scanner_state_machine.h:90
PSENSCAN_DEBUG
#define PSENSCAN_DEBUG(name,...)
Definition: logging.h:63
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isRefusedReply
bool isRefusedReply(data_conversion_layer::scanner_reply::Message const &msg)
Definition: scanner_state_machine_def.h:391
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::sendMessageWithMeasurements
void sendMessageWithMeasurements(const std::vector< data_conversion_layer::monitoring_frame::MessageStamped > &stamped_msg)
Definition: scanner_state_machine_def.h:269
psen_scan_v2_standalone::protocol_layer::scanner_events::StartTimeout
Timeout while waiting for scanner device to start.
Definition: scanner_events.h:43
psen_scan_v2_standalone::data_conversion_layer::ScannerProtocolViolationError
: Exception thrown if data received from the scanner hardware could not be processed according to pro...
Definition: laserscan_conversions.h:37
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isRefusedStopReply
bool isRefusedStopReply(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:374
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::type
constexpr Type type() const
Definition: scanner_reply_msg.h:94
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isUnknownStopReply
bool isUnknownStopReply(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:367
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::notifyUserAboutRefusedStopReply
void notifyUserAboutRefusedStopReply(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:223
psen_scan_v2_standalone::data_conversion_layer::LaserScanConverter::toLaserScan
static LaserScan toLaserScan(const std::vector< data_conversion_layer::monitoring_frame::MessageStamped > &stamped_msgs)
Converts monitoring_frames of a scan_round to the user friendly LaserScan type sent by the IScanner::...
Definition: laserscan_conversions.h:86
DEFAULT_ON_ENTRY_IMPL
#define DEFAULT_ON_ENTRY_IMPL(state_name)
Definition: scanner_state_machine_def.h:59
psen_scan_v2_standalone::protocol_layer::ScannerStartedCallback
std::function< void()> ScannerStartedCallback
Definition: scanner_state_machine.h:85
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::hasDiagnosticMessagesField
bool hasDiagnosticMessagesField() const
Definition: monitoring_frame_msg.cpp:143
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::handleMonitoringFrameTimeout
void handleMonitoringFrameTimeout(const scanner_events::MonitoringFrameTimeout &event)
Definition: scanner_state_machine_def.h:300
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::monitoring_frame_watchdog_
std::unique_ptr< util::Watchdog > monitoring_frame_watchdog_
Definition: scanner_state_machine.h:283
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message
Higher level data type representing a reply message from the scanner.
Definition: scanner_reply_msg.h:33
psen_scan_v2_standalone::protocol_layer::scanner_events::RawMonitoringFrameReceived::data_
const data_conversion_layer::RawDataConstPtr data_
Definition: scanner_events.h:81
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::checkForChangedActiveZoneset
void checkForChangedActiveZoneset(const data_conversion_layer::monitoring_frame::Message &msg)
Definition: scanner_state_machine_def.h:238
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::no_transition
void no_transition(Event const &event, FSM &, int state)
Definition: scanner_state_machine_def.h:439
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::notifyUserAboutStart
void notifyUserAboutStart(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:193
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::scanCounter
uint32_t scanCounter() const
Definition: monitoring_frame_msg.cpp:46
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isUnknownReply
bool isUnknownReply(data_conversion_layer::scanner_reply::Message const &msg)
Definition: scanner_state_machine_def.h:386
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::MessageStamped
Wrapping class for a Message and its corresponding timestamp.
Definition: monitoring_frame_msg.h:109
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isRefusedStartReply
bool isRefusedStartReply(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:353
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::inform_user_about_laser_scan_callback_
const InformUserAboutLaserScanCallback inform_user_about_laser_scan_callback_
Definition: scanner_state_machine.h:296
PSENSCAN_INFO
#define PSENSCAN_INFO(name,...)
Definition: logging.h:61
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::scan_buffer_
ScanBuffer scan_buffer_
Definition: scanner_state_machine.h:284
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::ScannerProtocolDef
ScannerProtocolDef(const ScannerConfiguration &config, const communication_layer::NewMessageCallback &control_msg_callback, const communication_layer::ErrorCallback &control_error_callback, const communication_layer::ErrorCallback &start_error_callback, const communication_layer::ErrorCallback &stop_error_callback, const communication_layer::NewMessageCallback &data_msg_callback, const communication_layer::ErrorCallback &data_error_callback, const ScannerStartedCallback &scanner_started_callback, const ScannerStoppedCallback &scanner_stopped_callback, const InformUserAboutLaserScanCallback &laser_scan_callback, const TimeoutCallback &start_timeout_callback, const TimeoutCallback &monitoring_frame_timeout_callback)
Definition: scanner_state_machine_def.h:23
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::deserialize
Message deserialize(const data_conversion_layer::RawData &data)
Definition: scanner_reply_serialization_deserialization.cpp:60
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::diagnosticMessages
std::vector< diagnostic::Message > diagnosticMessages() const
Definition: monitoring_frame_msg.cpp:106
psen_scan_v2_standalone::protocol_layer::classNameShort
static std::string classNameShort(const T &t)
Definition: scanner_state_machine_def.h:422
psen_scan_v2_standalone::util::formatRange
std::string formatRange(const T &range)
Definition: format_range.h:38
DEFAULT_ON_EXIT_IMPL
#define DEFAULT_ON_EXIT_IMPL(state_name)
Definition: scanner_state_machine_def.h:66
psen_scan_v2_standalone::protocol_layer::ScanBuffer::isRoundComplete
bool isRoundComplete()
Definition: scan_buffer.h:129
PSENSCAN_WARN_THROTTLE
#define PSENSCAN_WARN_THROTTLE(period, name,...)
Definition: logging.h:78
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::OperationResult::accepted
@ accepted
psen_scan_v2_standalone::protocol_layer::scanner_events::MonitoringFrameTimeout
Timeout while waiting for MonitoringFrame.
Definition: scanner_events.h:87
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::Type::stop
@ stop
psen_scan_v2_standalone::protocol_layer::ScanBuffer::currentRound
std::vector< data_conversion_layer::monitoring_frame::MessageStamped > currentRound()
Definition: scan_buffer.h:124
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::scanner_stopped_callback_
const ScannerStoppedCallback scanner_stopped_callback_
Definition: scanner_state_machine.h:293
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::start_error_callback_
const StartErrorCallback start_error_callback_
Definition: scanner_state_machine.h:294
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message::activeZoneset
uint8_t activeZoneset() const
Definition: monitoring_frame_msg.cpp:58
psen_scan_v2_standalone::protocol_layer::getStateName
static std::string getStateName(const int &state_id)
Definition: scanner_state_machine_def.h:409
psen_scan_v2_standalone::protocol_layer::scanner_events::RawMonitoringFrameReceived
Received monitoring frame from scanner device.
Definition: scanner_events.h:70
psen_scan_v2_standalone::protocol_layer::ScanRoundError
Exception indicating problems with the monitoring frames of a scan round.
Definition: scan_buffer.h:31
psen_scan_v2_standalone::ScannerConfiguration::hostIp
boost::optional< uint32_t > hostIp() const
Definition: scanner_configuration.h:99
psen_scan_v2_standalone::protocol_layer::WATCHDOG_TIMEOUT
static constexpr std::chrono::milliseconds WATCHDOG_TIMEOUT
Definition: scanner_state_machine.h:82
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::deserialize
monitoring_frame::Message deserialize(const data_conversion_layer::RawData &data, const std::size_t &num_bytes)
Definition: monitoring_frame_deserialization.cpp:79
std
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::handleStartRequestTimeout
void handleStartRequestTimeout(const scanner_events::StartTimeout &event)
Definition: scanner_state_machine_def.h:154
psen_scan_v2_standalone::ScannerConfiguration::fragmentedScansEnabled
bool fragmentedScansEnabled() const
Definition: scanner_configuration.h:149
psen_scan_v2_standalone
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Definition: udp_client.h:41
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::notifyUserAboutUnknownStartReply
void notifyUserAboutUnknownStartReply(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:203
psen_scan_v2_standalone::communication_layer::UdpClientImpl::hostIp
boost::asio::ip::address_v4 hostIp()
Returns local ip address of current socket connection.
Definition: udp_client.h:242
PSENSCAN_ERROR
#define PSENSCAN_ERROR(name,...)
Definition: logging.h:60
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::OperationResult::unknown
@ unknown
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isStopReply
bool isStopReply(data_conversion_layer::scanner_reply::Message const &msg)
Definition: scanner_state_machine_def.h:401
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::stop_error_callback_
const StopErrorCallback stop_error_callback_
Definition: scanner_state_machine.h:295
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::Message
Higher level data type representing a single monitoring frame.
Definition: monitoring_frame_msg.h:62
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::Type::unknown
@ unknown
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::zoneset_reference_msg_
boost::optional< data_conversion_layer::monitoring_frame::Message > zoneset_reference_msg_
Definition: scanner_state_machine.h:285
psen_scan_v2_standalone::protocol_layer::ScanBuffer::add
void add(const data_conversion_layer::monitoring_frame::MessageStamped &stamped_msg)
Adds the message to the current scan round.
Definition: scan_buffer.h:134
psen_scan_v2_standalone::communication_layer::ErrorCallback
std::function< void(const std::string &)> ErrorCallback
Definition: udp_client.h:50
psen_scan_v2_standalone::communication_layer::NewMessageCallback
std::function< void(const data_conversion_layer::RawDataConstPtr &, const std::size_t &, const int64_t &timestamp)> NewMessageCallback
Definition: udp_client.h:49
psen_scan_v2_standalone::data_conversion_layer::scanner_reply::Message::OperationResult::refused
@ refused
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::checkForDiagnosticErrors
void checkForDiagnosticErrors(const data_conversion_layer::monitoring_frame::Message &msg)
Definition: scanner_state_machine_def.h:228
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::sendStopRequest
void sendStopRequest(const T &event)
Definition: scanner_state_machine_def.h:164
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isAcceptedReply
bool isAcceptedReply(data_conversion_layer::scanner_reply::Message const &msg)
Definition: scanner_state_machine_def.h:381
psen_scan_v2_standalone::protocol_layer::TimeoutCallback
std::function< void()> TimeoutCallback
Definition: scanner_state_machine.h:89
udp_client.h
config
config
psen_scan_v2_standalone::data_conversion_layer::start_request::Message
Higher level data type representing a scanner start request.
Definition: start_request.h:42
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::sendStartRequest
void sendStartRequest(const T &event)
Definition: scanner_state_machine_def.h:140
psen_scan_v2_standalone::protocol_layer::scanner_events::RawReplyReceived::data_
const data_conversion_layer::RawDataConstPtr data_
Definition: scanner_events.h:59
psen_scan_v2_standalone::protocol_layer::scanner_events
Contains the events needed to define and implement the scanner protocol.
Definition: scanner_events.h:30
t
geometry_msgs::TransformStamped t
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::control_client_
communication_layer::UdpClientImpl control_client_
Definition: scanner_state_machine.h:288
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::notifyUserAboutStop
void notifyUserAboutStop(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:198
psen_scan_v2_standalone::protocol_layer::ScannerProtocolDef::isAcceptedStartReply
bool isAcceptedStartReply(scanner_events::RawReplyReceived const &reply_event)
Definition: scanner_state_machine_def.h:339
psen_scan_v2_standalone::ScannerConfiguration
Higher level data type storing the configuration details of the scanner like scanner IP,...
Definition: scanner_configuration.h:34


psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Nov 25 2023 03:46:26