ParseFieldGeometryData.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::FieldData& field_data) 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  uint32_t array_length = readArrayLength(data_ptr);
52  std::vector<uint16_t> geometry_distance_mm;
53  for (uint32_t i = 0; i < array_length; i++)
54  {
55  geometry_distance_mm.push_back(readArrayElement(data_ptr, i));
56  }
57  field_data.setBeamDistances(geometry_distance_mm);
58 
59  // Values are persistent for all scanners
60  field_data.setStartAngleDegrees(-47.5); // defined start angle in degrees in sick coordinates
61  float res = 275.0 / array_length; // 275 is the defined field of view
62  field_data.setAngularBeamResolutionDegrees(res);
63 
64  return true;
65 }
66 
67 uint32_t
68 ParseFieldGeometryData::readArrayLength(std::vector<uint8_t>::const_iterator data_ptr) const
69 {
70  return read_write_helper::readUint32LittleEndian(data_ptr + 4);
71 }
72 
73 uint16_t ParseFieldGeometryData::readArrayElement(std::vector<uint8_t>::const_iterator data_ptr,
74  uint32_t elem_number) const
75 {
76  return read_write_helper::readUint16LittleEndian(data_ptr + 8 + elem_number * 2);
77 }
78 
79 
80 } // namespace data_processing
81 } // namespace sick
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.
bool parseTCPSequence(const datastructure::PacketBuffer &buffer, datastructure::FieldData &field_data) const
Parses a tcp sequence and return the field geometry data of the warning and protective fields...
void setStartAngleDegrees(const float &start_angle)
Set the start angle of the scan from degrees.
Definition: FieldData.cpp:203
uint32_t readArrayLength(std::vector< uint8_t >::const_iterator data_ptr) const
Field data for warning and protective fields.
Definition: FieldData.h:48
uint32_t readUint32LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 32-bit integer at offset in little endian encoding.
void setAngularBeamResolutionDegrees(const float &angular_beam_resolution)
Set the angular resolution between beams from degrees.
Definition: FieldData.cpp:233
uint16_t readArrayElement(std::vector< uint8_t >::const_iterator data_ptr, uint32_t elem_number) const
void setBeamDistances(const std::vector< uint16_t > &beam_distances)
Sets vector with beam distances for field.
Definition: FieldData.cpp:188
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