ParseData.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 
24 // -- END LICENSE BLOCK ------------------------------------------------
25 
26 //----------------------------------------------------------------------
33 //----------------------------------------------------------------------
34 
36 
37 namespace sick {
38 namespace data_processing {
39 
41 {
42  m_data_header_parser_ptr = std::make_shared<sick::data_processing::ParseDataHeader>();
43  m_derived_values_parser_ptr = std::make_shared<sick::data_processing::ParseDerivedValues>();
44  m_measurement_data_parser_ptr = std::make_shared<sick::data_processing::ParseMeasurementData>();
46  std::make_shared<sick::data_processing::ParseGeneralSystemState>();
47  m_intrusion_data_parser_ptr = std::make_shared<sick::data_processing::ParseIntrusionData>();
48  m_application_data_parser_ptr = std::make_shared<sick::data_processing::ParseApplicationData>();
49 }
50 
53 {
55  setDataBlocksInData(buffer, data);
56  return data;
57 }
58 
60  datastructure::Data& data) const
61 {
62  setDataHeaderInData(buffer, data);
63 
64  auto dataHeadPtr = data.getDataHeaderPtr();
65  uint32_t expected_size =
66  dataHeadPtr->getDerivedValuesBlockSize() + dataHeadPtr->getMeasurementDataBlockSize() +
67  dataHeadPtr->getGeneralSystemStateBlockSize() + dataHeadPtr->getIntrusionDataBlockSize() +
68  dataHeadPtr->getApplicationDataBlockSize();
69  uint32_t actual_size = buffer.getLength();
70  if (actual_size < expected_size)
71  {
72  ROS_WARN("Skipping data, sizes do not match, actual size is smaller then expected "
73  "size! If this occurs please report with a stacktrace if the driver crashes at some "
74  "other place. ");
75  ROS_WARN("Expected minimum size: %i", expected_size);
76  ROS_WARN("Actual size: %i", actual_size);
77  ROS_WARN("Skipping all data for this message.");
78 
79  dataHeadPtr->setDerivedValuesBlockSize(0);
80  dataHeadPtr->setDerivedValuesBlockOffset(0);
81  dataHeadPtr->setMeasurementDataBlockSize(0);
82  dataHeadPtr->setMeasurementDataBlockOffset(0);
83  dataHeadPtr->setGeneralSystemStateBlockSize(0);
84  dataHeadPtr->setGeneralSystemStateBlockOffset(0);
85  dataHeadPtr->setIntrusionDataBlockSize(0);
86  dataHeadPtr->setIntrusionDataBlockOffset(0);
87  dataHeadPtr->setApplicationDataBlockSize(0);
88  dataHeadPtr->setApplicationDataBlockOffset(0);
89  }
90 
91  setDerivedValuesInData(buffer, data);
92  setMeasurementDataInData(buffer, data);
93  setGeneralSystemStateInData(buffer, data);
94  setIntrusionDataInData(buffer, data);
95  setApplicationDataInData(buffer, data);
96 }
97 
99  datastructure::Data& data) const
100 {
101  sick::datastructure::DataHeader data_header =
102  m_data_header_parser_ptr->parseUDPSequence(buffer, data);
103  data.setDataHeaderPtr(std::make_shared<sick::datastructure::DataHeader>(data_header));
104 }
105 
107  datastructure::Data& data) const
108 {
109  sick::datastructure::DerivedValues derived_values =
110  m_derived_values_parser_ptr->parseUDPSequence(buffer, data);
111  data.setDerivedValuesPtr(std::make_shared<sick::datastructure::DerivedValues>(derived_values));
112 }
113 
115  datastructure::Data& data) const
116 {
117  sick::datastructure::MeasurementData measurement_data =
118  m_measurement_data_parser_ptr->parseUDPSequence(buffer, data);
120  std::make_shared<sick::datastructure::MeasurementData>(measurement_data));
121 }
122 
124  datastructure::Data& data) const
125 {
126  sick::datastructure::GeneralSystemState general_system_state =
127  m_general_system_state_parser_ptr->parseUDPSequence(buffer, data);
129  std::make_shared<sick::datastructure::GeneralSystemState>(general_system_state));
130 }
131 
133  datastructure::Data& data) const
134 {
135  sick::datastructure::IntrusionData intrusion_data =
136  m_intrusion_data_parser_ptr->parseUDPSequence(buffer, data);
137  data.setIntrusionDataPtr(std::make_shared<sick::datastructure::IntrusionData>(intrusion_data));
138 }
139 
141  datastructure::Data& data) const
142 {
143  sick::datastructure::ApplicationData application_data =
144  m_application_data_parser_ptr->parseUDPSequence(buffer, data);
146  std::make_shared<sick::datastructure::ApplicationData>(application_data));
147 }
148 
149 } // namespace data_processing
150 } // namespace sick
std::shared_ptr< sick::data_processing::ParseDataHeader > m_data_header_parser_ptr
Definition: ParseData.h:75
void setApplicationDataPtr(const std::shared_ptr< ApplicationData > &application_data_ptr)
Sets the application data.
Definition: Data.cpp:99
The GeneralSystemState class. It includes a summary of the current system state, the state of the saf...
std::shared_ptr< sick::data_processing::ParseDerivedValues > m_derived_values_parser_ptr
Definition: ParseData.h:76
A packetbuffer for the raw data from the sensor.
Definition: PacketBuffer.h:61
void setMeasurementDataInData(const datastructure::PacketBuffer &buffer, datastructure::Data &data) const
Definition: ParseData.cpp:114
void setDerivedValuesInData(const datastructure::PacketBuffer &buffer, datastructure::Data &data) const
Definition: ParseData.cpp:106
data
void setDataBlocksInData(const datastructure::PacketBuffer &buffer, datastructure::Data &data) const
Definition: ParseData.cpp:59
#define ROS_WARN(...)
The data class containing all data blocks of a measurement.
Definition: Data.h:55
The application io class, bundles application input and output.
sick::datastructure::Data parseUDPSequence(const sick::datastructure::PacketBuffer &buffer) const
Parses the udp data transferred in the packet buffer. It will be parsed into the data reference...
Definition: ParseData.cpp:52
Class containing all IntrusionDatums.
Definition: IntrusionData.h:48
void setDataHeaderInData(const datastructure::PacketBuffer &buffer, datastructure::Data &data) const
Definition: ParseData.cpp:98
void setMeasurementDataPtr(const std::shared_ptr< MeasurementData > &measurement_data_ptr)
Sets the measurement data.
Definition: Data.cpp:79
void setDerivedValuesPtr(const std::shared_ptr< DerivedValues > &derived_values_ptr)
Sets the derived values.
Definition: Data.cpp:69
void setGeneralSystemStateInData(const datastructure::PacketBuffer &buffer, datastructure::Data &data) const
Definition: ParseData.cpp:123
std::shared_ptr< sick::data_processing::ParseApplicationData > m_application_data_parser_ptr
Definition: ParseData.h:80
ParseData()
Constructor of the parser.
Definition: ParseData.cpp:40
std::shared_ptr< sick::data_processing::ParseGeneralSystemState > m_general_system_state_parser_ptr
Definition: ParseData.h:78
Class containing all scanpoints of a single measurement.
size_t getLength() const
Returns length of the current PacketBuffer.
The DerivedValues class Includes the derived configuration of the measurement data channel...
Definition: DerivedValues.h:48
void setDataHeaderPtr(const std::shared_ptr< DataHeader > &data_header_ptr)
Sets the data header.
Definition: Data.cpp:48
Contains the content of the data header of a udp data packet.
Definition: DataHeader.h:46
void setApplicationDataInData(const datastructure::PacketBuffer &buffer, datastructure::Data &data) const
Definition: ParseData.cpp:140
std::shared_ptr< DataHeader > getDataHeaderPtr() const
Gets the data header.
Definition: Data.cpp:42
void setGeneralSystemStatePtr(const std::shared_ptr< GeneralSystemState > &general_system_state_ptr)
Sets the general system state.
Definition: Data.cpp:58
void setIntrusionDataPtr(const std::shared_ptr< IntrusionData > &intrusion_data_ptr)
Sets the intrusion data.
Definition: Data.cpp:89
std::shared_ptr< sick::data_processing::ParseMeasurementData > m_measurement_data_parser_ptr
Definition: ParseData.h:77
std::shared_ptr< sick::data_processing::ParseIntrusionData > m_intrusion_data_parser_ptr
Definition: ParseData.h:79
void setIntrusionDataInData(const datastructure::PacketBuffer &buffer, datastructure::Data &data) const
Definition: ParseData.cpp:132


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Fri Apr 2 2021 02:45:41