Go to the documentation of this file.
15 #ifndef PSEN_SCAN_V2_STANDALONE_SCANNER_PROTOCOL_DEF_H
16 #define PSEN_SCAN_V2_STANDALONE_SCANNER_PROTOCOL_DEF_H
24 #include <unordered_map>
26 #include <boost/optional.hpp>
28 #define BOOST_MSM_CONSTRUCTOR_ARG_SIZE 12 // see https://www.boost.org/doc/libs/1_66_0/libs/msm/doc/HTML/ch03s05.html
31 #include <boost/msm/back/state_machine.hpp>
33 #include <boost/msm/front/state_machine_def.hpp>
35 #include <boost/msm/back/tools.hpp>
36 #include <boost/msm/back/metafunctions.hpp>
64 namespace protocol_layer
66 namespace msm = boost::msm;
67 namespace mpl = boost::mpl;
72 #define STATE(state_name)\
73 class state_name : public msm::front::state<>\
76 template <class Event, class FSM>\
77 void on_entry(Event const&, FSM& fsm);\
79 template <class Event, class FSM>\
80 void on_exit(Event const&, FSM& fsm);\
165 STATE(WaitForStartReply);
166 STATE(WaitForMonitoringFrame);
167 STATE(WaitForStopReply);
195 template <
class FSM,
class Event>
196 void exception_caught(Event
const& event, FSM& fsm, std::exception& exception);
198 template <
class FSM,
class Event>
216 a_row < Idle, e::StartRequest, WaitForStartReply, &m::sendStartRequest >,
217 a_row < Idle, e::StopRequest, WaitForStopReply, &m::sendStopRequest >,
218 row < WaitForStartReply, e::RawReplyReceived, WaitForMonitoringFrame, &m::notifyUserAboutStart, &m::isAcceptedStartReply >,
219 row < WaitForStartReply, e::RawReplyReceived, Error, &m::notifyUserAboutRefusedStartReply, &m::isRefusedStartReply >,
220 row < WaitForStartReply, e::RawReplyReceived, Error, &m::notifyUserAboutUnknownStartReply, &m::isUnknownStartReply >,
221 a_irow < WaitForStartReply, e::StartTimeout, &m::handleStartRequestTimeout >,
222 a_irow < WaitForMonitoringFrame, e::RawMonitoringFrameReceived, &m::handleMonitoringFrame >,
223 a_irow < WaitForMonitoringFrame, e::MonitoringFrameTimeout, &m::handleMonitoringFrameTimeout >,
224 a_row < WaitForStartReply, e::StopRequest, WaitForStopReply, &m::sendStopRequest >,
225 a_row < WaitForMonitoringFrame, e::StopRequest, WaitForStopReply, &m::sendStopRequest >,
226 _irow < WaitForStopReply, e::RawMonitoringFrameReceived >,
227 row < WaitForStopReply, e::RawReplyReceived, Stopped, &m::notifyUserAboutStop, &m::isAcceptedStopReply >,
228 row < WaitForStopReply, e::RawReplyReceived, Error, &m::notifyUserAboutRefusedStopReply, &m::isRefusedStopReply >,
229 row < WaitForStopReply, e::RawReplyReceived, Error, &m::notifyUserAboutUnknownStopReply, &m::isUnknownStopReply >,
230 _irow < Stopped, e::RawMonitoringFrameReceived >
324 #endif // PSEN_SCAN_V2_STANDALONE_SCANNER_PROTOCOL_DEF_H
bool isAcceptedStopReply(scanner_events::RawReplyReceived const &reply_event)
ScannerConfiguration config_
Interface to create event timeout callbacks.
void notifyUserAboutRefusedStartReply(scanner_events::RawReplyReceived const &reply_event)
Helper for asynchronously sending and receiving data via UDP.
void checkForInternalErrors(const data_conversion_layer::scanner_reply::Message &msg)
Exception thrown when something goes wrong with the scanner reply.
const std::chrono::high_resolution_clock::duration Timeout
bool isUnknownStartReply(scanner_events::RawReplyReceived const &reply_event)
const ScannerStartedCallback scanner_started_callback_
void notifyUserAboutUnknownStopReply(scanner_events::RawReplyReceived const &reply_event)
virtual ~IWatchdogFactory()=default
bool isStartReply(data_conversion_layer::scanner_reply::Message const &msg)
void exception_caught(Event const &event, FSM &fsm, std::exception &exception)
bool framesContainMeasurements(const std::vector< data_conversion_layer::monitoring_frame::MessageStamped > &stamped_msg)
communication_layer::UdpClientImpl data_client_
void handleMonitoringFrame(const scanner_events::RawMonitoringFrameReceived &event)
std::function< void()> ScannerStoppedCallback
Watchdog factory implementation for scanner interaction timeouts.
InternalScannerReplyError(const std::string &error_msg)
msm::back::state_machine< ScannerProtocolDef > ScannerStateMachine
State machine handling all events according to the scanner protocol and error handling specification.
void informUserAboutTheScanData(const data_conversion_layer::monitoring_frame::MessageStamped &stamped_msg)
Received Start- or Stop-Reply message from scanner device.
std::function< void(const LaserScan &)> InformUserAboutLaserScanCallback
bool isRefusedReply(data_conversion_layer::scanner_reply::Message const &msg)
void sendMessageWithMeasurements(const std::vector< data_conversion_layer::monitoring_frame::MessageStamped > &stamped_msg)
static constexpr uint32_t DEFAULT_NUM_MSG_PER_ROUND
Timeout while waiting for scanner device to start.
bool isRefusedStopReply(scanner_events::RawReplyReceived const &reply_event)
bool isUnknownStopReply(scanner_events::RawReplyReceived const &reply_event)
void notifyUserAboutRefusedStopReply(scanner_events::RawReplyReceived const &reply_event)
std::unique_ptr< util::Watchdog > create(const util::Watchdog::Timeout &timeout, const TimeoutCallback &timeout_callback) override
WatchdogFactory watchdog_factory_
std::function< void()> ScannerStartedCallback
void handleMonitoringFrameTimeout(const scanner_events::MonitoringFrameTimeout &event)
virtual std::unique_ptr< util::Watchdog > create(const util::Watchdog::Timeout &timeout, const TimeoutCallback &timeout_callback)=0
std::unique_ptr< util::Watchdog > monitoring_frame_watchdog_
Higher level data type representing a reply message from the scanner.
void checkForChangedActiveZoneset(const data_conversion_layer::monitoring_frame::Message &msg)
void no_transition(Event const &event, FSM &, int state)
void notifyUserAboutStart(scanner_events::RawReplyReceived const &reply_event)
bool isUnknownReply(data_conversion_layer::scanner_reply::Message const &msg)
Table describing the state machine which is specified in the scanner protocol.
Wrapping class for a Message and its corresponding timestamp.
bool isRefusedStartReply(scanner_events::RawReplyReceived const &reply_event)
const std::function< void()> start_timeout_callback_
const InformUserAboutLaserScanCallback inform_user_about_laser_scan_callback_
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)
std::function< void(const std::string &)> StopErrorCallback
Timeout while waiting for MonitoringFrame.
const ScannerStoppedCallback scanner_stopped_callback_
const StartErrorCallback start_error_callback_
Received monitoring frame from scanner device.
static constexpr std::chrono::milliseconds WATCHDOG_TIMEOUT
void handleStartRequestTimeout(const scanner_events::StartTimeout &event)
This class represents a single laser scan in the <tf_prefix> target frame.
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
void notifyUserAboutUnknownStartReply(scanner_events::RawReplyReceived const &reply_event)
WatchdogFactory()=default
std::unordered_map< ScannerId, ScanBuffer > scan_buffers_
bool isStopReply(data_conversion_layer::scanner_reply::Message const &msg)
std::unique_ptr< util::Watchdog > start_reply_watchdog_
const StopErrorCallback stop_error_callback_
Higher level data type representing a single monitoring frame.
boost::optional< data_conversion_layer::monitoring_frame::Message > zoneset_reference_msg_
Definition of the scanner protocol. It is initialized using the StateMachineArgs class.
std::function< void(const std::string &)> ErrorCallback
std::function< void(const data_conversion_layer::RawDataConstPtr &, const std::size_t &, const int64_t ×tamp)> NewMessageCallback
void checkForDiagnosticErrors(const data_conversion_layer::monitoring_frame::Message &msg)
void sendStopRequest(const T &event)
bool isAcceptedReply(data_conversion_layer::scanner_reply::Message const &msg)
std::function< void()> TimeoutCallback
std::function< void(const std::string &)> StartErrorCallback
void sendStartRequest(const T &event)
Contains the events needed to define and implement the scanner protocol.
const std::function< void()> monitoring_frame_timeout_callback_
communication_layer::UdpClientImpl control_client_
void notifyUserAboutStop(scanner_events::RawReplyReceived const &reply_event)
bool isAcceptedStartReply(scanner_events::RawReplyReceived const &reply_event)
Higher level data type storing the configuration details of the scanner like scanner IP,...
psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Jun 22 2024 02:46:12