Skip to content

Commit

Permalink
chore(nebula_common): add function to get number of channels for a gi…
Browse files Browse the repository at this point in the history
…ven sensor model
  • Loading branch information
mojomex committed Sep 4, 2024
1 parent 17c156e commit c5aefb6
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions nebula_common/include/nebula_common/nebula_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
#ifndef NEBULA_COMMON_H
#define NEBULA_COMMON_H

#include "nebula_common/util/expected.hpp"

#include <nebula_common/point_types.hpp>

#include <boost/tokenizer.hpp>

#include <algorithm>
#include <cstdint>
#include <ostream>
#include <string>
#include <vector>
Expand All @@ -28,6 +31,9 @@ namespace nebula
{
namespace drivers
{

using std::string_literals::operator""s;

/// @brief Coordinate mode for Velodyne's setting (need to check)
enum class CoordinateMode { UNKNOWN = 0, CARTESIAN, SPHERICAL, CYLINDRICAL };

Expand Down Expand Up @@ -636,6 +642,47 @@ inline std::string SensorModelToString(const SensorModel & sensor_model)
}
}

/**
* @brief Get the number of channels a specific sensor model has. A string error message is returned
* for sensors that do not have a meaningful channel number.
*
* @param sensor_model The sensor model of interest
* @return nebula::util::expected<uint32_t, std::string> The number of channels on success, or a
* string error message.
*/
inline nebula::util::expected<uint32_t, std::string> get_n_channels(
const SensorModel & sensor_model)
{
switch (sensor_model) {
case SensorModel::VELODYNE_VLP16:
return 16;
case SensorModel::VELODYNE_VLP32:
case SensorModel::VELODYNE_VLP32MR:
case SensorModel::VELODYNE_HDL32:
case SensorModel::HESAI_PANDARXT32:
case SensorModel::HESAI_PANDARXT32M:
case SensorModel::ROBOSENSE_HELIOS:
case SensorModel::ROBOSENSE_BPEARL_V3:
case SensorModel::ROBOSENSE_BPEARL_V4:
return 32;
case SensorModel::HESAI_PANDAR40P:
case SensorModel::HESAI_PANDAR40M:
return 40;
case SensorModel::VELODYNE_HDL64:
case SensorModel::HESAI_PANDAR64:
case SensorModel::HESAI_PANDARQT64:
return 64;
case SensorModel::VELODYNE_VLS128:
case SensorModel::HESAI_PANDARQT128:
case SensorModel::HESAI_PANDARAT128:
case SensorModel::HESAI_PANDAR128_E3X:
case SensorModel::HESAI_PANDAR128_E4X:
return 128;
default:
return "unsupported sensor model"s;
}
}

/// @brief Convert return mode name to ReturnMode enum
/// @param return_mode Return mode name (Upper and lower case letters must match)
/// @return Corresponding ReturnMode
Expand Down

0 comments on commit c5aefb6

Please sign in to comment.