Skip to content

File continental_ars548_decoder.hpp

File List > decoders > continental_ars548_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_continental/decoders/continental_packets_decoder.hpp"

#include <nebula_common/continental/continental_ars548.hpp>

#include <continental_msgs/msg/continental_ars548_detection_list.hpp>
#include <continental_msgs/msg/continental_ars548_object_list.hpp>
#include <diagnostic_msgs/msg/diagnostic_array.hpp>
#include <nebula_msgs/msg/nebula_packet.hpp>
#include <nebula_msgs/msg/nebula_packets.hpp>

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

namespace nebula::drivers::continental_ars548
{
class ContinentalARS548Decoder : public ContinentalPacketsDecoder
{
public:
  explicit ContinentalARS548Decoder(
    const std::shared_ptr<const ContinentalARS548SensorConfiguration> & sensor_configuration);

  Status get_status() override;

  bool process_packet(std::unique_ptr<nebula_msgs::msg::NebulaPacket> packet_msg) override;

  Status register_detection_list_callback(
    std::function<void(std::unique_ptr<continental_msgs::msg::ContinentalArs548DetectionList>)>
      detection_list_callback);

  Status register_object_list_callback(
    std::function<void(std::unique_ptr<continental_msgs::msg::ContinentalArs548ObjectList>)>
      object_list_callback);

  Status register_sensor_status_callback(
    std::function<void(const ContinentalARS548Status & status)> sensor_status_callback);

  Status register_packets_callback(
    std::function<void(std::unique_ptr<nebula_msgs::msg::NebulaPackets>)> packets_callback);

private:
  bool parse_detections_list_packet(const nebula_msgs::msg::NebulaPacket & packet_msg);

  bool parse_objects_list_packet(const nebula_msgs::msg::NebulaPacket & packet_msg);

  bool parse_sensor_status_packet(const nebula_msgs::msg::NebulaPacket & packet_msg);

  std::function<void(std::unique_ptr<continental_msgs::msg::ContinentalArs548DetectionList> msg)>
    detection_list_callback_{};
  std::function<void(std::unique_ptr<continental_msgs::msg::ContinentalArs548ObjectList> msg)>
    object_list_callback_{};
  std::function<void(const ContinentalARS548Status & status)> sensor_status_callback_{};
  std::function<void(std::unique_ptr<nebula_msgs::msg::NebulaPackets> msg)>
    nebula_packets_callback_{};

  ContinentalARS548Status radar_status_{};

  std::shared_ptr<const continental_ars548::ContinentalARS548SensorConfiguration> config_ptr_{};
};

}  // namespace nebula::drivers::continental_ars548