result_port_parser.h
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 /*
3  * @brief sim_loc_result_port_parser implements a parser for
4  * result port telegrams for SIM Localization.
5  *
6  * Copyright (C) 2019 Ing.-Buero Dr. Michael Lehning, Hildesheim
7  * Copyright (C) 2019 SICK AG, Waldkirch
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * All rights reserved.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions are met:
25  *
26  * * Redistributions of source code must retain the above copyright
27  * notice, this list of conditions and the following disclaimer.
28  * * Redistributions in binary form must reproduce the above copyright
29  * notice, this list of conditions and the following disclaimer in the
30  * documentation and/or other materials provided with the distribution.
31  * * Neither the name of SICK AG nor the names of its
32  * contributors may be used to endorse or promote products derived from
33  * this software without specific prior written permission
34  * * Neither the name of Ing.-Buero Dr. Michael Lehning nor the names of its
35  * contributors may be used to endorse or promote products derived from
36  * this software without specific prior written permission
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
42  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
43  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
44  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
46  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49  *
50  * Authors:
51  * Michael Lehning <michael.lehning@lehning.de>
52  *
53  * Copyright 2019 SICK AG
54  * Copyright 2019 Ing.-Buero Dr. Michael Lehning
55  *
56  */
57 #ifndef __SIM_LOC_RESULT_PORT_PARSER_H_INCLUDED
58 #define __SIM_LOC_RESULT_PORT_PARSER_H_INCLUDED
59 
60 #include "sick_scan/ros_wrapper.h"
61 
62 namespace sick_scan_xd
63 {
69  {
70  public:
71 
76  ResultPortParser(const std::string & frame_id = "");
77 
83  virtual bool decode(const std::vector<uint8_t> & binary_data);
84 
89  virtual std::vector<uint8_t> encode(void);
90 
95 
100 
101  protected:
102 
106  static void parseAssert(bool assertion, const std::string & assertion_msg, const std::string & info, const std::string & file, int line);
107 
118  template<typename T> size_t copyBytesToValue(const std::vector<uint8_t> & binary_data, size_t start_byte, T & value, const std::string & info = "", bool little_endian = false);
119 
129  template<typename T> size_t copyBytesToArray(const std::vector<uint8_t> & binary_data, size_t start_byte, std::vector<T> & dst_array, const std::string & info = "");
130 
153  virtual uint16_t computeChecksum(const std::vector<uint8_t> & binary_data, bool binary_data_with_trailer = true);
154 
160  virtual bool isLittleEndianPayload(uint16_t payload_type);
161 
170  virtual size_t decodeResultPortHeader(const std::vector<uint8_t> & binary_data, size_t start_byte, sick_scan_xd::SickLocResultPortHeaderMsg & telegram_header);
171 
180  virtual size_t decodeResultPortPayload(const std::vector<uint8_t> & binary_data, size_t start_byte, sick_scan_xd::SickLocResultPortPayloadMsg & telegram_payload);
181 
190  virtual size_t decodeResultPortTrailer(const std::vector<uint8_t> & binary_data, size_t start_byte, sick_scan_xd::SickLocResultPortCrcMsg & telegram_trailer);
191 
198  template<typename T> void encodePushValue(T value, std::vector<uint8_t> & binary_data, bool little_endian = false);
199 
205  virtual void encodeResultPortHeader(const sick_scan_xd::SickLocResultPortHeaderMsg & telegram_header, std::vector<uint8_t> & binary_data);
206 
212  virtual void encodeResultPortPayload(const sick_scan_xd::SickLocResultPortPayloadMsg & telegram_payload, std::vector<uint8_t> & binary_data);
213 
219  virtual void encodeResultPortTrailer(uint16_t checksum, std::vector<uint8_t> & binary_data);
220 
221  /*
222  * member data
223  */
224 
225  std::string m_publish_frame_id;
228 
229  };
230 
231 } // namespace sick_scan_xd
232 #endif // __SIM_LOC_RESULT_PORT_PARSER_H_INCLUDED
sick_scan_xd::ResultPortParser::decodeResultPortHeader
virtual size_t decodeResultPortHeader(const std::vector< uint8_t > &binary_data, size_t start_byte, sick_scan_xd::SickLocResultPortHeaderMsg &telegram_header)
Definition: result_port_parser.cpp:189
sick_scan_xd::ResultPortParser::m_little_endian_payload
bool m_little_endian_payload
true if payload type is 0x06c2 (little endian), default: false (payload encoded in big endian format)
Definition: result_port_parser.h:227
sick_scan_xd::ResultPortParser::m_result_port_telegram
sick_scan_xd::SickLocResultPortTelegramMsg m_result_port_telegram
the result port telegram decoded from binary data
Definition: result_port_parser.h:226
sick_scan_xd::SickLocResultPortTelegramMsg_< std::allocator< void > >
sick_scan_xd::ResultPortParser::isLittleEndianPayload
virtual bool isLittleEndianPayload(uint16_t payload_type)
Definition: result_port_parser.cpp:176
sick_scan_xd::ResultPortParser::computeChecksum
virtual uint16_t computeChecksum(const std::vector< uint8_t > &binary_data, bool binary_data_with_trailer=true)
Definition: result_port_parser.cpp:159
sick_scan_xd::ResultPortParser::encodeResultPortHeader
virtual void encodeResultPortHeader(const sick_scan_xd::SickLocResultPortHeaderMsg &telegram_header, std::vector< uint8_t > &binary_data)
Definition: result_port_parser.cpp:378
sick_scan_xd::ResultPortParser
Definition: result_port_parser.h:68
sick_scan_xd::SickLocResultPortHeaderMsg_< std::allocator< void > >
sick_scan_xd
Definition: abstract_parser.cpp:65
sick_scan_xd::ResultPortParser::copyBytesToArray
size_t copyBytesToArray(const std::vector< uint8_t > &binary_data, size_t start_byte, std::vector< T > &dst_array, const std::string &info="")
Definition: result_port_parser.cpp:127
sick_scan_xd::ResultPortParser::getTelegramMsg
virtual sick_scan_xd::SickLocResultPortTelegramMsg & getTelegramMsg(void)
Definition: result_port_parser.h:94
sick_scan_xd::SickLocResultPortPayloadMsg_< std::allocator< void > >
sick_scan_xd::ResultPortParser::m_publish_frame_id
std::string m_publish_frame_id
frame_id of published ros messages (type SickLocResultPortTelegramMsg)
Definition: result_port_parser.h:225
sick_scan_xd::ResultPortParser::encodeResultPortPayload
virtual void encodeResultPortPayload(const sick_scan_xd::SickLocResultPortPayloadMsg &telegram_payload, std::vector< uint8_t > &binary_data)
Definition: result_port_parser.cpp:397
imu_delay_tester.line
line
Definition: imu_delay_tester.py:135
sick_scan_xd::ResultPortParser::decodeResultPortPayload
virtual size_t decodeResultPortPayload(const std::vector< uint8_t > &binary_data, size_t start_byte, sick_scan_xd::SickLocResultPortPayloadMsg &telegram_payload)
Definition: result_port_parser.cpp:238
sick_scan_xd::ResultPortParser::getTelegramMsg
virtual const sick_scan_xd::SickLocResultPortTelegramMsg & getTelegramMsg(void) const
Definition: result_port_parser.h:99
sick_scan_xd::ResultPortParser::ResultPortParser
ResultPortParser(const std::string &frame_id="")
Definition: result_port_parser.cpp:70
sick_scan_xd::ResultPortParser::decodeResultPortTrailer
virtual size_t decodeResultPortTrailer(const std::vector< uint8_t > &binary_data, size_t start_byte, sick_scan_xd::SickLocResultPortCrcMsg &telegram_trailer)
Definition: result_port_parser.cpp:298
sick_scan_base.h
sick_scan_xd::SickLocResultPortCrcMsg_< std::allocator< void > >
sick_scan_xd::ResultPortParser::decode
virtual bool decode(const std::vector< uint8_t > &binary_data)
Definition: result_port_parser.cpp:314
sick_scan_xd::ResultPortParser::encode
virtual std::vector< uint8_t > encode(void)
Definition: result_port_parser.cpp:429
ros_wrapper.h
sick_scan_xd::ResultPortParser::encodeResultPortTrailer
virtual void encodeResultPortTrailer(uint16_t checksum, std::vector< uint8_t > &binary_data)
Definition: result_port_parser.cpp:420
sick_scan_xd::ResultPortParser::copyBytesToValue
size_t copyBytesToValue(const std::vector< uint8_t > &binary_data, size_t start_byte, T &value, const std::string &info="", bool little_endian=false)
Definition: result_port_parser.cpp:97
sick_scan_xd::ResultPortParser::encodePushValue
void encodePushValue(T value, std::vector< uint8_t > &binary_data, bool little_endian=false)
Definition: result_port_parser.cpp:354
sick_scan_xd::ResultPortParser::parseAssert
static void parseAssert(bool assertion, const std::string &assertion_msg, const std::string &info, const std::string &file, int line)
Definition: result_port_parser.cpp:77


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:10