ParseTypeCodeData.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 
38 
39 namespace sick {
40 namespace data_processing {
41 
43 
44 
46  sick::datastructure::TypeCode& type_code) const
47 {
48  // Keep our own copy of the shared_ptr to keep the iterators valid
49  const std::shared_ptr<std::vector<uint8_t> const> vec_ptr = buffer.getBuffer();
50  std::vector<uint8_t>::const_iterator data_ptr = vec_ptr->begin();
51  type_code.setTypeCode(readTypeCode(data_ptr));
52  type_code.setInterfaceType(readInterfaceType(data_ptr));
53  type_code.setMaxRange(readMaxRange(data_ptr));
54  return true;
55 }
56 
57 std::string ParseTypeCodeData::readTypeCode(std::vector<uint8_t>::const_iterator data_ptr) const
58 {
59  uint16_t code_length = read_write_helper::readUint16LittleEndian(data_ptr);
60  std::string code;
61  for (uint8_t i = 0; i < code_length; i++)
62  {
63  code.push_back(read_write_helper::readUint8(data_ptr + 2 + i));
64  }
65  return code;
66 }
67 
68 uint8_t ParseTypeCodeData::readInterfaceType(std::vector<uint8_t>::const_iterator data_ptr) const
69 {
70  uint8_t type_code_interface_1 = read_write_helper::readUint8(data_ptr + 14);
71  uint8_t type_code_interface_2 = read_write_helper::readUint8(data_ptr + 15);
72 
74 
75  if ((type_code_interface_1 == 'Z' && type_code_interface_2 == 'A') ||
76  (type_code_interface_1 == 'A' && type_code_interface_2 == 'A'))
77  {
79  }
80  else if (type_code_interface_1 == 'I' && type_code_interface_2 == 'Z')
81  {
83  }
84  else if ((type_code_interface_1 == 'P' && type_code_interface_2 == 'Z') ||
85  (type_code_interface_1 == 'L' && type_code_interface_2 == 'Z'))
86  {
88  }
89  else if (type_code_interface_1 == 'A' && type_code_interface_2 == 'N')
90  {
92  }
93 
94  return res;
95 }
96 
97 float ParseTypeCodeData::readMaxRange(std::vector<uint8_t>::const_iterator data_ptr) const
98 {
99  uint8_t type_code_interface_1 = read_write_helper::readUint8(data_ptr + 12);
100  uint8_t type_code_interface_2 = read_write_helper::readUint8(data_ptr + 13);
101 
103 
104  if ((type_code_interface_1 == '3' && type_code_interface_2 == '0') ||
105  (type_code_interface_1 == '4' && type_code_interface_2 == '0') ||
106  (type_code_interface_1 == '5' && type_code_interface_2 == '5'))
107  {
109  }
110  else if (type_code_interface_1 == '9' && type_code_interface_2 == '0')
111  {
113  }
114 
115  return (float)res;
116 }
117 
118 
119 } // namespace data_processing
120 } // namespace sick
float readMaxRange(std::vector< uint8_t >::const_iterator data_ptr) const
bool parseTCPSequence(const datastructure::PacketBuffer &buffer, datastructure::TypeCode &type_code) const
Parses a tcp sequence to read the type code of the sensor.
A packetbuffer for the raw data from the sensor.
Definition: PacketBuffer.h:61
std::shared_ptr< std::vector< uint8_t > const > getBuffer() const
Getter to return a copy of the data saved in the PacketBuffer.
std::string readTypeCode(std::vector< uint8_t >::const_iterator data_ptr) const
void setInterfaceType(const uint8_t &interface_type)
Sets the interface type for the scanner.
Definition: TypeCode.cpp:56
ParseTypeCodeData()
Constructor of the parser.
uint8_t readInterfaceType(std::vector< uint8_t >::const_iterator data_ptr) const
void setMaxRange(const float &max_distance)
Sets the max range for the scanner.
Definition: TypeCode.cpp:66
void setTypeCode(const std::string &type_code)
Sets the type code for the scanner.
Definition: TypeCode.cpp:47
Class containing the type code of a laser scanner.
Definition: TypeCode.h:62
uint8_t readUint8(std::vector< uint8_t >::const_iterator it)
Read an unsigned 8-bit integer at offset.
uint16_t readUint16LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 16-bit integer at offset in little endian encoding.


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