cola_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_cola_parser parses and converts binary Cola telegrams to ros messages SickLocColaTelegramMsg
4  * and vice versa.
5  *
6  * See Operation-Instruction-v1.1.0.241R.pdf, chapter 5.8 "About CoLa-A telegrams", page 46-48,
7  * Telegram-Listing-v1.1.0.241R.pdf, chapter 2.3.9 "Command: LocRequestTimestamp", page 21, and
8  * Technical_information_Telegram_Listing_NAV_LOC_en_IM0076556.PDF for further details about
9  * Cola telegrams.
10  *
11  * Copyright (C) 2019 Ing.-Buero Dr. Michael Lehning, Hildesheim
12  * Copyright (C) 2019 SICK AG, Waldkirch
13  *
14  * Licensed under the Apache License, Version 2.0 (the "License");
15  * you may not use this file except in compliance with the License.
16  * You may obtain a copy of the License at
17  *
18  * http://www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS,
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  *
26  * All rights reserved.
27  *
28  * Redistribution and use in source and binary forms, with or without
29  * modification, are permitted provided that the following conditions are met:
30  *
31  * * Redistributions of source code must retain the above copyright
32  * notice, this list of conditions and the following disclaimer.
33  * * Redistributions in binary form must reproduce the above copyright
34  * notice, this list of conditions and the following disclaimer in the
35  * documentation and/or other materials provided with the distribution.
36  * * Neither the name of SICK AG nor the names of its
37  * contributors may be used to endorse or promote products derived from
38  * this software without specific prior written permission
39  * * Neither the name of Ing.-Buero Dr. Michael Lehning nor the names of its
40  * contributors may be used to endorse or promote products derived from
41  * this software without specific prior written permission
42  *
43  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
44  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
47  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
48  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
49  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
50  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
51  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
53  * POSSIBILITY OF SUCH DAMAGE.
54  *
55  * Authors:
56  * Michael Lehning <michael.lehning@lehning.de>
57  *
58  * Copyright 2019 SICK AG
59  * Copyright 2019 Ing.-Buero Dr. Michael Lehning
60  *
61  */
62 #ifndef __SIM_LOC_COLA_PARSER_H_INCLUDED
63 #define __SIM_LOC_COLA_PARSER_H_INCLUDED
64 
65 #include "sick_scan/ros_wrapper.h"
67 
68 namespace sick_scan_xd
69 {
79  class ColaParser
80  {
81  public:
82 
94  {
95  sINVALID = 0,
96  sRN = 1,
97  sRA = 2,
98  sMN = 3,
99  sAN = 4,
100  sMA = 5,
101  sWN = 6,
102  sWA = 7,
103  sEN = 8,
104  sEA = 9,
105  sSN = 10,
106  sFA = 11,
109 
118  const std::string & command_name, const std::vector<std::string> & parameter = std::vector<std::string>());
119 
128  static sick_scan_xd::SickLocColaTelegramMsg decodeColaTelegram(const std::vector<uint8_t> & cola_binary);
129 
136 
143  static std::vector<uint8_t> encodeColaTelegram(const sick_scan_xd::SickLocColaTelegramMsg & cola_telegram, bool parameter_is_ascii = true);
144 
152  static std::vector<uint8_t> encodeColaTelegram(const COLA_SOPAS_COMMAND & command_type, const std::string & command_name,
153  const std::vector<std::string> & parameter = std::vector<std::string>(), bool parameter_is_ascii = true);
154 
159  static const std::string & asciiSTX(void) { return s_cola_ascii_start_tag; }
160 
165  static const std::string & asciiETX(void) { return s_cola_ascii_end_tag; }
166 
171  static std::vector<uint8_t> binarySTX(void){ return sick_scan_xd::ColaAsciiBinaryConverter::ConvertColaAscii(asciiSTX()); }
172 
177  static std::vector<uint8_t> binaryETX(void){ return sick_scan_xd::ColaAsciiBinaryConverter::ConvertColaAscii(asciiETX()); }
178 
185  static std::string convertSopasCommand(COLA_SOPAS_COMMAND command_type);
186 
193  static COLA_SOPAS_COMMAND convertSopasCommand(const std::string & sopas_command);
194 
202  static int32_t convertColaArg(const std::string & cola_arg, int base = 10, int32_t default_value = 0);
203 
211  static uint32_t convertColaArg(const std::string & cola_arg, int base = 10, uint32_t default_value = 0);
212 
219  static bool convertColaResponseBool(const std::string & cola_response_arg, bool default_value);
220 
221  protected:
222 
223  static const std::string s_command_type_string[MAX_COLA_COMMAND_NUMBER];
224  static const std::map<std::string, COLA_SOPAS_COMMAND> s_command_type_map;
225  static const std::string s_cola_ascii_start_tag;
226  static const std::string s_cola_ascii_end_tag;
227 
228  }; // class ColaParser
229 
230 } // namespace sick_scan_xd
231 #endif // __SIM_LOC_COLA_PARSER_H_INCLUDED
sick_scan_xd::ColaParser::sWA
@ sWA
Write answer (response)
Definition: cola_parser.h:102
pcap_json_converter.cola_ascii
bool cola_ascii
Definition: pcap_json_converter.py:132
sick_scan_xd::ColaParser::binaryETX
static std::vector< uint8_t > binaryETX(void)
Returns the binary "end of text" tag in a Cola-Binary command, i.e. {0x03}.
Definition: cola_parser.h:177
sick_scan_xd::ColaParser::binarySTX
static std::vector< uint8_t > binarySTX(void)
Returns the binary "start of text" tag in a Cola-Binary command, i.e. {0x02}.
Definition: cola_parser.h:171
sick_scan_xd::ColaParser::createColaTelegram
static sick_scan_xd::SickLocColaTelegramMsg createColaTelegram(const COLA_SOPAS_COMMAND &command_type, const std::string &command_name, const std::vector< std::string > &parameter=std::vector< std::string >())
Creates and returns a Cola telegram (type SickLocColaTelegramMsg).
Definition: cola_parser.cpp:99
sick_scan_xd::ColaParser::s_command_type_string
static const std::string s_command_type_string[MAX_COLA_COMMAND_NUMBER]
static table to convert COLA_SOPAS_COMMAND to string, f.e. s_command_type_string[sRN]:="sRN",...
Definition: cola_parser.h:223
sick_scan_xd::SickLocColaTelegramMsg_
Definition: SickLocColaTelegramMsg.h:24
sick_scan_xd::ColaParser::encodeColaTelegram
static std::vector< uint8_t > encodeColaTelegram(const sick_scan_xd::SickLocColaTelegramMsg &cola_telegram, bool parameter_is_ascii=true)
Encodes and returns a Cola Binary telegram from ros message SickLocColaTelegramMsg.
Definition: cola_parser.cpp:180
sick_scan_xd::ColaParser::sRA
@ sRA
Read by name (response)
Definition: cola_parser.h:97
sick_scan_xd::ColaParser::sSN
@ sSN
Answer (response)
Definition: cola_parser.h:105
sick_scan_xd::ColaParser::s_command_type_map
static const std::map< std::string, COLA_SOPAS_COMMAND > s_command_type_map
static map to convert COLA_SOPAS_COMMANDs from string to enum, f.e. s_command_type_map["sRN"]:=sRN,...
Definition: cola_parser.h:224
cola_converter.h
sick_scan_xd::ColaParser::sWN
@ sWN
Write by name (request)
Definition: cola_parser.h:101
sick_scan_xd::ColaParser::convertColaResponseBool
static bool convertColaResponseBool(const std::string &cola_response_arg, bool default_value)
Definition: cola_parser.cpp:286
sick_scan_xd
Definition: abstract_parser.cpp:65
sick_scan_xd::ColaParser::decodeColaTelegram
static sick_scan_xd::SickLocColaTelegramMsg decodeColaTelegram(const std::vector< uint8_t > &cola_binary)
Decodes and returns a Cola message of type SickLocColaTelegramMsg from a Cola-Binary telegram....
Definition: cola_parser.cpp:118
sick_scan_xd::ColaParser::convertColaArg
static int32_t convertColaArg(const std::string &cola_arg, int base=10, int32_t default_value=0)
Definition: cola_parser.cpp:243
sick_scan_xd::ColaParser::asciiETX
static const std::string & asciiETX(void)
Returns the "end of text" tag in a Cola ASCII command, i.e. "<ETX>".
Definition: cola_parser.h:165
sick_scan_xd::ColaParser::MAX_COLA_COMMAND_NUMBER
@ MAX_COLA_COMMAND_NUMBER
Number of possible COLA_SOPAS_COMMANDs incl. invalid command.
Definition: cola_parser.h:107
sick_scan_xd::ColaParser::sINVALID
@ sINVALID
uninitialized, command_type should never have this value)
Definition: cola_parser.h:95
multiscan_sopas_test_server.cola_binary
int cola_binary
Definition: multiscan_sopas_test_server.py:173
sick_scan_xd::ColaParser::sRN
@ sRN
Read by name (request)
Definition: cola_parser.h:96
sick_scan_xd::ColaParser::COLA_SOPAS_COMMAND
enum sick_scan_xd::ColaParser::COLA_SOPAS_COMMAND_ENUM COLA_SOPAS_COMMAND
Enumeration of SOPAS commands in cola telegrams: The command_type in SickLocColaTelegramMsg is one of...
sick_scan_xd::ColaParser
class ColaParser parses and converts binary Cola telegrams to ros messages SickLocColaTelegramMsg and...
Definition: cola_parser.h:79
sick_scan_xd::ColaParser::sMA
@ sMA
Method by name (response)
Definition: cola_parser.h:100
sick_scan_xd::ColaParser::COLA_SOPAS_COMMAND_ENUM
COLA_SOPAS_COMMAND_ENUM
Enumeration of SOPAS commands in cola telegrams: The command_type in SickLocColaTelegramMsg is one of...
Definition: cola_parser.h:93
sick_scan_xd::ColaParser::sEA
@ sEA
Event answer (response)
Definition: cola_parser.h:104
sick_scan_xd::ColaParser::convertSopasCommand
static std::string convertSopasCommand(COLA_SOPAS_COMMAND command_type)
Converts and returns a COLA_SOPAS_COMMAND to string. Example: convertSopasCommand(sMN) returns "sMN".
Definition: cola_parser.cpp:218
sick_scan_xd::ColaParser::sEN
@ sEN
Event by name (request)
Definition: cola_parser.h:103
sick_scan_xd::ColaAsciiBinaryConverter::ConvertColaAscii
static std::string ConvertColaAscii(const std::vector< uint8_t > &cola_telegram)
Converts and returns a Cola-ASCII telegram to string.
Definition: cola_converter.cpp:105
sick_scan_xd::ColaParser::sFA
@ sFA
Error Answer with error code (response)
Definition: cola_parser.h:106
sick_scan_base.h
sick_scan_xd::ColaParser::s_cola_ascii_end_tag
static const std::string s_cola_ascii_end_tag
All Cola-ACSII telegrams start with s_cola_ascii_start_tag := "<ETX>" ("End of TeXt")
Definition: cola_parser.h:226
sick_scan_xd::ColaParser::asciiSTX
static const std::string & asciiSTX(void)
Returns the "start of text" tag in a Cola ASCII command, i.e. "<STX>".
Definition: cola_parser.h:159
sick_scan_xd::ColaParser::s_cola_ascii_start_tag
static const std::string s_cola_ascii_start_tag
All Cola-ACSII telegrams start with s_cola_ascii_start_tag := "<STX>" ("Start of TeXt")
Definition: cola_parser.h:225
ros_wrapper.h
sick_scan_xd::ColaParser::sAN
@ sAN
Response to sMN.
Definition: cola_parser.h:99
sick_scan_xd::ColaParser::sMN
@ sMN
Method by name (request)
Definition: cola_parser.h:98


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