Skip to content

File vls128_decoder.hpp

File List > decoders > vls128_decoder.hpp

Go to the documentation of this file

// Copyright 2024 TIER IV, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "nebula_decoders/nebula_decoders_velodyne/decoders/velodyne_scan_decoder.hpp"

#include <velodyne_msgs/msg/velodyne_packet.hpp>
#include <velodyne_msgs/msg/velodyne_scan.hpp>

#include <array>
#include <memory>
#include <tuple>
#include <vector>

namespace nebula
{
namespace drivers
{
namespace vls128
{
class Vls128Decoder : public VelodyneScanDecoder
{
public:
  explicit Vls128Decoder(
    const std::shared_ptr<const drivers::VelodyneSensorConfiguration> & sensor_configuration,
    const std::shared_ptr<const drivers::VelodyneCalibrationConfiguration> &
      calibration_configuration);
  void unpack(const std::vector<uint8_t> & packet, int32_t packet_seconds) override;
  int pointsPerPacket() override;
  std::tuple<drivers::NebulaPointCloudPtr, double> get_pointcloud() override;
  void reset_pointcloud(double time_stamp) override;
  void reset_overflow(double time_stamp) override;

private:
  bool parsePacket(const velodyne_msgs::msg::VelodynePacket & velodyne_packet) override;
  float sin_rot_table_[ROTATION_MAX_UNITS];
  float cos_rot_table_[ROTATION_MAX_UNITS];
  float rotation_radians_[ROTATION_MAX_UNITS];
  float vls_128_laser_azimuth_cache_[16];
  int phase_;
  int max_pts_;
  double last_block_timestamp_;
  std::vector<std::vector<float>> timing_offsets_;
};

}  // namespace vls128
}  // namespace drivers
}  // namespace nebula