Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
sick_scan::ResultPortParser Class Reference

#include <result_port_parser.h>

Public Member Functions

virtual bool decode (const std::vector< uint8_t > &binary_data)
 
virtual std::vector< uint8_t > encode (void)
 
virtual sick_scan::SickLocResultPortTelegramMsg & getTelegramMsg (void)
 
virtual const sick_scan::SickLocResultPortTelegramMsg & getTelegramMsg (void) const
 
 ResultPortParser (const std::string &frame_id="")
 

Protected Member Functions

virtual uint16_t computeChecksum (const std::vector< uint8_t > &binary_data, bool binary_data_with_trailer=true)
 
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="")
 
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)
 
virtual size_t decodeResultPortHeader (const std::vector< uint8_t > &binary_data, size_t start_byte, sick_scan::SickLocResultPortHeaderMsg &telegram_header)
 
virtual size_t decodeResultPortPayload (const std::vector< uint8_t > &binary_data, size_t start_byte, sick_scan::SickLocResultPortPayloadMsg &telegram_payload)
 
virtual size_t decodeResultPortTrailer (const std::vector< uint8_t > &binary_data, size_t start_byte, sick_scan::SickLocResultPortCrcMsg &telegram_trailer)
 
template<typename T >
void encodePushValue (T value, std::vector< uint8_t > &binary_data, bool little_endian=false)
 
virtual void encodeResultPortHeader (const sick_scan::SickLocResultPortHeaderMsg &telegram_header, std::vector< uint8_t > &binary_data)
 
virtual void encodeResultPortPayload (const sick_scan::SickLocResultPortPayloadMsg &telegram_payload, std::vector< uint8_t > &binary_data)
 
virtual void encodeResultPortTrailer (uint16_t checksum, std::vector< uint8_t > &binary_data)
 
virtual bool isLittleEndianPayload (uint16_t payload_type)
 

Static Protected Member Functions

static void parseAssert (bool assertion, const std::string &assertion_msg, const std::string &info, const std::string &file, int line)
 

Protected Attributes

bool m_little_endian_payload
 true if payload type is 0x06c2 (little endian), default: false (payload encoded in big endian format) More...
 
std::string m_publish_frame_id
 frame_id of published ros messages (type SickLocResultPortTelegramMsg) More...
 
sick_scan::SickLocResultPortTelegramMsg m_result_port_telegram
 the result port telegram decoded from binary data More...
 

Detailed Description

class ResultPortParser implements a parser for result port telegrams for SIM Localization.

Definition at line 67 of file result_port_parser.h.

Constructor & Destructor Documentation

◆ ResultPortParser()

sick_scan::ResultPortParser::ResultPortParser ( const std::string &  frame_id = "")

Constructor

Parameters
[in]frame_idframe_id of published ros messages (type SickLocResultPortTelegramMsg)

Definition at line 70 of file result_port_parser.cpp.

Member Function Documentation

◆ computeChecksum()

uint16_t sick_scan::ResultPortParser::computeChecksum ( const std::vector< uint8_t > &  binary_data,
bool  binary_data_with_trailer = true 
)
protectedvirtual

Computes and returns the checksum of a result port telegram.

Checksum := CRC16-CCITT over length of header (52 bytes) and payload (52 bytes) without 2 bytes of this trailer. Size: UInt16 = 2 byte Checksum details (See chapter 5.9 "About result port telegrams" of the operation manual for further details): Width: 16 bits Truncated polynomial: 0x1021 CRC polynomials with orders of x16 + x12 + x5 + 1 (counted without the leading '1' bit) Initial value = 0xFFFF

Additional note: According to http://srecord.sourceforge.net/crc16-ccitt.html, CRC16-CCITT is specified by Width = 16 bits, Truncated polynomial = 0x1021, Initial value = 0xFFFF, Input data is NOT reflected, Output CRC is NOT reflected. This is often referred as "CRC-16/CCITT-FALSE" (because of "reflected_in/out=FALSE", width=16 poly=0x1021 init=0xffff refin=false refout=false), in contrast to other flavors like "CRC-16/MCRF4XX" (width=16 poly=0x1021 init=0xffff refin=true refout=true).

This CRC checksum uses the implementation by https://github.com/madler/crcany (sources under the zlib license, permitting free commercial use) with algorithm "CRC-16/CCITT-FALSE" (crc16ccitt_false.c and crc16ccitt_false.h). Other crc checksum algorithms may be used if required.

Parameters
[in]binary_databinary data of result port telegram
[in]binary_data_with_trailertrue (default): binary_data (input) contains 2 byte trailer
Returns
CRC16 checksum

Definition at line 159 of file result_port_parser.cpp.

◆ copyBytesToArray()

template<typename T >
size_t sick_scan::ResultPortParser::copyBytesToArray ( const std::vector< uint8_t > &  binary_data,
size_t  start_byte,
std::vector< T > &  dst_array,
const std::string &  info = "" 
)
protected

Copies the next N=dst_array.size() bytes from binary_data to dst_array, starting at binary_data[start_byte].

Parameters
[in]binary_databinary data, at least start_byte+sizeof(value) byte binary data
[in]start_bytefirst byte to start copying from binary_data
[out]dst_arraydestination
[in]infodescriptional message, used in exception in case of errors
Returns
number of bytes decoded := dst_array.size()
Exceptions
std::invalid_argumentin case of parse errors

Definition at line 127 of file result_port_parser.cpp.

◆ copyBytesToValue()

template<typename T >
size_t sick_scan::ResultPortParser::copyBytesToValue ( const std::vector< uint8_t > &  binary_data,
size_t  start_byte,
T &  value,
const std::string &  info = "",
bool  little_endian = false 
)
protected

Copies the next N=sizeof(value) bytes from binary_data to a value (number type), starting at binary_data[start_byte].

Parameters
[in]binary_databinary data, at least start_byte+sizeof(value) byte binary data
[in]start_bytefirst byte to start copying from binary_data
[out]valuedestination
[in]infodescriptional message, used in exception in case of errors
[in]little_endiantrue: binary_data encoded in little endian format, false (default): binary_data encoded in big endian format
Returns
number of bytes decoded := sizeof(value)
Exceptions
std::invalid_argumentin case of parse errors

Definition at line 97 of file result_port_parser.cpp.

◆ decode()

bool sick_scan::ResultPortParser::decode ( const std::vector< uint8_t > &  binary_data)
virtual

Decodes a result port telegram from binary data.

Parameters
[in]binary_databinary data (106 byte binary result port telegram), f.e. { 0x53, 0x49, 0x43, 0x4B, 0x00, ... }
Returns
true if binary_data successfully decode, false otherwise.

Definition at line 314 of file result_port_parser.cpp.

◆ decodeResultPortHeader()

size_t sick_scan::ResultPortParser::decodeResultPortHeader ( const std::vector< uint8_t > &  binary_data,
size_t  start_byte,
sick_scan::SickLocResultPortHeaderMsg &  telegram_header 
)
protectedvirtual

Decodes the header of a result port telegram from binary data.

Parameters
[in]binary_databinary data, at least start_byte+52 byte binary result port telegram header
[in]start_bytefirst byte to start decoding in binary_data
[out]telegram_headerdecoded result port telegram header
Returns
number of bytes decoded
Exceptions
std::invalid_argumentin case of parse errors

Definition at line 189 of file result_port_parser.cpp.

◆ decodeResultPortPayload()

size_t sick_scan::ResultPortParser::decodeResultPortPayload ( const std::vector< uint8_t > &  binary_data,
size_t  start_byte,
sick_scan::SickLocResultPortPayloadMsg &  telegram_payload 
)
protectedvirtual

Decodes the payload of a result port telegram from binary data.

Parameters
[in]binary_databinary data, at least start_byte+52 byte binary result port telegram payload
[in]start_bytefirst byte to start decoding in binary_data
[out]telegram_payloaddecoded result port telegram payload
Returns
number of bytes decoded
Exceptions
std::invalid_argumentin case of parse errors

Definition at line 238 of file result_port_parser.cpp.

◆ decodeResultPortTrailer()

size_t sick_scan::ResultPortParser::decodeResultPortTrailer ( const std::vector< uint8_t > &  binary_data,
size_t  start_byte,
sick_scan::SickLocResultPortCrcMsg &  telegram_trailer 
)
protectedvirtual

Decodes the trailer of a result port telegram from binary data.

Parameters
[in]binary_databinary data, at least start_byte+2 byte binary result port telegram trailer
[in]start_bytefirst byte to start decoding in binary_data
[out]telegram_trailerdecoded result port telegram trailer
Returns
number of bytes decoded
Exceptions
std::invalid_argumentin case of parse errors

Definition at line 298 of file result_port_parser.cpp.

◆ encode()

std::vector< uint8_t > sick_scan::ResultPortParser::encode ( void  )
virtual

Encodes the result port telegram and returns its binary data.

Returns
binary data (106 byte binary result port telegram), f.e. { 0x53, 0x49, 0x43, 0x4B, 0x00, ... }

Definition at line 429 of file result_port_parser.cpp.

◆ encodePushValue()

template<typename T >
void sick_scan::ResultPortParser::encodePushValue ( value,
std::vector< uint8_t > &  binary_data,
bool  little_endian = false 
)
protected

Encodes a value to binary data.

Parameters
[in]valuesource
[out]binary_databinary data (destination buffer)
[in]little_endiantrue: binary_data encoded in little endian format, false (default): binary_data encoded in big endian format

Definition at line 354 of file result_port_parser.cpp.

◆ encodeResultPortHeader()

void sick_scan::ResultPortParser::encodeResultPortHeader ( const sick_scan::SickLocResultPortHeaderMsg &  telegram_header,
std::vector< uint8_t > &  binary_data 
)
protectedvirtual

Encodes the header of the result port telegram and append its binary data to binary_data (destination).

Parameters
[in]telegram_headerheader of result port telegram
[out]binary_datadestination buffer

Definition at line 378 of file result_port_parser.cpp.

◆ encodeResultPortPayload()

void sick_scan::ResultPortParser::encodeResultPortPayload ( const sick_scan::SickLocResultPortPayloadMsg &  telegram_payload,
std::vector< uint8_t > &  binary_data 
)
protectedvirtual

Encodes the payload of the result port telegram and append its binary data to binary_data (destination).

Parameters
[in]telegram_payloadpayload of result port telegram
[out]binary_datadestination buffer

Definition at line 397 of file result_port_parser.cpp.

◆ encodeResultPortTrailer()

void sick_scan::ResultPortParser::encodeResultPortTrailer ( uint16_t  checksum,
std::vector< uint8_t > &  binary_data 
)
protectedvirtual

Encodes the checksum (trailer) of the result port telegram and append its binary data to binary_data (destination).

Parameters
[in]checksumchecksum (trailer) of result port telegram
[out]binary_datadestination buffer

Definition at line 420 of file result_port_parser.cpp.

◆ getTelegramMsg() [1/2]

virtual sick_scan::SickLocResultPortTelegramMsg& sick_scan::ResultPortParser::getTelegramMsg ( void  )
inlinevirtual

Returns the result port telegram.

Definition at line 93 of file result_port_parser.h.

◆ getTelegramMsg() [2/2]

virtual const sick_scan::SickLocResultPortTelegramMsg& sick_scan::ResultPortParser::getTelegramMsg ( void  ) const
inlinevirtual

Returns the result port telegram.

Definition at line 98 of file result_port_parser.h.

◆ isLittleEndianPayload()

bool sick_scan::ResultPortParser::isLittleEndianPayload ( uint16_t  payload_type)
protectedvirtual

Returns true, if the PayloadType of a telegram_header indicates a little endian payload, or false otherwise.

Parameters
[in]payload_typethe PayloadType of a telegram_header
Returns
true for little endian payloads, false otherwise

Definition at line 176 of file result_port_parser.cpp.

◆ parseAssert()

void sick_scan::ResultPortParser::parseAssert ( bool  assertion,
const std::string &  assertion_msg,
const std::string &  info,
const std::string &  file,
int  line 
)
staticprotected

Shortcut to print error messages and to throw an std::invalid_argument exception in case of assertion failures

Definition at line 77 of file result_port_parser.cpp.

Member Data Documentation

◆ m_little_endian_payload

bool sick_scan::ResultPortParser::m_little_endian_payload
protected

true if payload type is 0x06c2 (little endian), default: false (payload encoded in big endian format)

Definition at line 226 of file result_port_parser.h.

◆ m_publish_frame_id

std::string sick_scan::ResultPortParser::m_publish_frame_id
protected

frame_id of published ros messages (type SickLocResultPortTelegramMsg)

Definition at line 224 of file result_port_parser.h.

◆ m_result_port_telegram

sick_scan::SickLocResultPortTelegramMsg sick_scan::ResultPortParser::m_result_port_telegram
protected

the result port telegram decoded from binary data

Definition at line 225 of file result_port_parser.h.


The documentation for this class was generated from the following files:


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Wed Sep 7 2022 02:25:06