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


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Wed May 5 2021 03:05:48