Skip to content

Commit

Permalink
CHORE(ROBOSENSE): FIX CASE STYLE
Browse files Browse the repository at this point in the history
Signed-off-by: Max SCHMELLER <[email protected]>
  • Loading branch information
mojomex committed Oct 2, 2024
1 parent 0ce6677 commit f5127b4
Show file tree
Hide file tree
Showing 26 changed files with 349 additions and 347 deletions.
24 changes: 12 additions & 12 deletions nebula_common/include/nebula_common/robosense/robosense_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace drivers
{

// Flag for detecting Bpearl version
constexpr uint8_t BPEARL_V4_FLAG = 0x04;
constexpr uint8_t bpearl_v4_flag = 0x04;

/// @brief struct for Robosense sensor configuration
struct RobosenseSensorConfiguration : LidarConfigurationBase
Expand All @@ -56,7 +56,7 @@ inline std::ostream & operator<<(std::ostream & os, RobosenseSensorConfiguration
/// @brief Convert return mode name to ReturnMode enum (Robosense-specific return_mode_from_string)
/// @param return_mode Return mode name (Upper and lower case letters must match)
/// @return Corresponding ReturnMode
inline ReturnMode ReturnModeFromStringRobosense(const std::string & return_mode)
inline ReturnMode return_mode_from_string_robosense(const std::string & return_mode)
{
if (return_mode == "Dual") return ReturnMode::DUAL;
if (return_mode == "Strongest") return ReturnMode::SINGLE_STRONGEST;
Expand All @@ -80,10 +80,10 @@ struct RobosenseCalibrationConfiguration : CalibrationConfigurationBase
{
std::vector<ChannelCorrection> calibration;

void SetChannelSize(const size_t channel_num) { calibration.resize(channel_num); }
void set_channel_size(const size_t channel_num) { calibration.resize(channel_num); }

template <typename stream_t>
inline nebula::Status LoadFromStream(stream_t & stream)
inline nebula::Status load_from_stream(stream_t & stream)
{
std::string header;
std::getline(stream, header);
Expand Down Expand Up @@ -134,36 +134,36 @@ struct RobosenseCalibrationConfiguration : CalibrationConfigurationBase
return load_status;
}

inline nebula::Status LoadFromFile(const std::string & calibration_file)
inline nebula::Status load_from_file(const std::string & calibration_file)
{
std::ifstream ifs(calibration_file);
if (!ifs) {
return Status::INVALID_CALIBRATION_FILE;
}

const auto status = LoadFromStream(ifs);
const auto status = load_from_stream(ifs);
ifs.close();
return status;
}

/// @brief Loading calibration data (not used)
/// @param calibration_content
/// @return Resulting status
inline nebula::Status LoadFromString(const std::string & calibration_content)
inline nebula::Status load_from_string(const std::string & calibration_content)
{
std::stringstream ss;
ss << calibration_content;

const auto status = LoadFromStream(ss);
const auto status = load_from_stream(ss);
return status;
}

// inline nebula::Status LoadFromDifop(const std::string & calibration_file)
// inline nebula::Status load_from_difop(const std::string & calibration_file)

/// @brief Saving calibration data (not used)
/// @param calibration_file
/// @return Resulting status
inline nebula::Status SaveFile(const std::string & calibration_file)
inline nebula::Status save_file(const std::string & calibration_file)
{
std::ofstream ofs(calibration_file);
if (!ofs) {
Expand All @@ -182,12 +182,12 @@ struct RobosenseCalibrationConfiguration : CalibrationConfigurationBase
return Status::OK;
}

[[nodiscard]] inline ChannelCorrection GetCorrection(const size_t channel_id) const
[[nodiscard]] inline ChannelCorrection get_correction(const size_t channel_id) const
{
return calibration[channel_id];
}

void CreateCorrectedChannels()
void create_corrected_channels()
{
for (auto & correction : calibration) {
uint16_t channel = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ class AngleCorrector
/// angle unit
/// @param channel_id The laser channel's id
/// @return The corrected angles (azimuth, elevation) in radians and their sin/cos values
virtual CorrectedAngleData getCorrectedAngleData(uint32_t block_azimuth, uint32_t channel_id) = 0;
virtual CorrectedAngleData get_corrected_angle_data(
uint32_t block_azimuth, uint32_t channel_id) = 0;

/// @brief Returns true if the current azimuth lies in a different (new) scan compared to the last
/// azimuth
/// @param current_azimuth The current azimuth value in the sensor's angle resolution
/// @param last_azimuth The last azimuth in the sensor's angle resolution
/// @return true if the current azimuth is in a different scan than the last one, false otherwise
virtual bool hasScanned(int current_azimuth, int last_azimuth) = 0;
virtual bool has_scanned(int current_azimuth, int last_azimuth) = 0;
};

} // namespace drivers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ template <size_t ChannelN, size_t AngleUnit>
class AngleCorrectorCalibrationBased : public AngleCorrector
{
private:
static constexpr size_t MAX_AZIMUTH = 360 * AngleUnit;
static constexpr size_t max_azimuth = 360 * AngleUnit;

std::array<float, ChannelN> elevation_angle_rad_{};
std::array<float, ChannelN> azimuth_offset_rad_{};
std::array<float, MAX_AZIMUTH> block_azimuth_rad_{};
std::array<float, max_azimuth> block_azimuth_rad_{};

std::array<float, ChannelN> elevation_cos_{};
std::array<float, ChannelN> elevation_sin_{};
std::array<std::array<float, ChannelN>, MAX_AZIMUTH> azimuth_cos_{};
std::array<std::array<float, ChannelN>, MAX_AZIMUTH> azimuth_sin_{};
std::array<std::array<float, ChannelN>, max_azimuth> azimuth_cos_{};
std::array<std::array<float, ChannelN>, max_azimuth> azimuth_sin_{};

public:
explicit AngleCorrectorCalibrationBased(
Expand All @@ -51,7 +51,7 @@ class AngleCorrectorCalibrationBased : public AngleCorrector
}

for (size_t channel_id = 0; channel_id < ChannelN; ++channel_id) {
const auto correction = sensor_calibration->GetCorrection(channel_id);
const auto correction = sensor_calibration->get_correction(channel_id);
float elevation_angle_deg = correction.elevation;
float azimuth_offset_deg = correction.azimuth;

Expand All @@ -62,7 +62,7 @@ class AngleCorrectorCalibrationBased : public AngleCorrector
elevation_sin_[channel_id] = sinf(elevation_angle_rad_[channel_id]);
}

for (size_t block_azimuth = 0; block_azimuth < MAX_AZIMUTH; block_azimuth++) {
for (size_t block_azimuth = 0; block_azimuth < max_azimuth; block_azimuth++) {
block_azimuth_rad_[block_azimuth] = deg2rad(block_azimuth / static_cast<double>(AngleUnit));

for (size_t channel_id = 0; channel_id < ChannelN; ++channel_id) {
Expand All @@ -75,7 +75,7 @@ class AngleCorrectorCalibrationBased : public AngleCorrector
}
}

CorrectedAngleData getCorrectedAngleData(uint32_t block_azimuth, uint32_t channel_id) override
CorrectedAngleData get_corrected_angle_data(uint32_t block_azimuth, uint32_t channel_id) override
{
float azimuth_rad = block_azimuth_rad_[block_azimuth] + azimuth_offset_rad_[channel_id];
float elevation_rad = elevation_angle_rad_[channel_id];
Expand All @@ -90,7 +90,7 @@ class AngleCorrectorCalibrationBased : public AngleCorrector
sensor_calibration_->calibration[channel_id].channel};
}

bool hasScanned(int current_azimuth, int last_azimuth) override
bool has_scanned(int current_azimuth, int last_azimuth) override
{
return current_azimuth < last_azimuth;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct Header

struct Packet : public PacketBase<12, 32, 2, 100>
{
typedef Body<Block<Unit, Packet::N_CHANNELS>, Packet::N_BLOCKS> body_t;
typedef Body<Block<Unit, Packet::n_channels>, Packet::n_blocks> body_t;
Header header;
body_t body;
big_uint48_buf_t tail;
Expand Down Expand Up @@ -163,7 +163,7 @@ class BpearlV3 : public RobosenseSensor<
robosense_packet::bpearl_v3::Packet, robosense_packet::bpearl_v3::InfoPacket>
{
private:
static constexpr int firing_time_offset_ns_single_[12][32]{
static constexpr int firing_time_offset_ns_single[12][32]{
{0, 256, 512, 768, 1024, 1280, 1536, 1792, 2568, 2824, 3080, 3336, 3592, 3848, 4104, 4360,
128, 384, 640, 896, 1152, 1408, 1664, 1920, 2696, 2952, 3208, 3464, 3720, 3976, 4232, 4488},
{5552, 5808, 6064, 6320, 6576, 6832, 7088, 7344, 8120, 8376, 8632,
Expand Down Expand Up @@ -200,7 +200,7 @@ class BpearlV3 : public RobosenseSensor<
64408, 64664, 64920, 65176, 65432, 61200, 61456, 61712, 61968, 62224, 62480,
62736, 62992, 63768, 64024, 64280, 64536, 64792, 65048, 65304, 65560}};

static constexpr int firing_time_offset_ns_dual_[12][32]{
static constexpr int firing_time_offset_ns_dual[12][32]{
{0, 256, 512, 768, 1024, 1280, 1536, 1792, 2568, 2824, 3080, 3336, 3592, 3848, 4104, 4360,
128, 384, 640, 896, 1152, 1408, 1664, 1920, 2696, 2952, 3208, 3464, 3720, 3976, 4232, 4488},
{0, 256, 512, 768, 1024, 1280, 1536, 1792, 2568, 2824, 3080, 3336, 3592, 3848, 4104, 4360,
Expand Down Expand Up @@ -236,69 +236,69 @@ class BpearlV3 : public RobosenseSensor<
31096, 31352, 31608, 31864, 32120, 27888, 28144, 28400, 28656, 28912, 29168,
29424, 29680, 30456, 30712, 30968, 31224, 31480, 31736, 31992, 32248}};

static constexpr uint8_t DUAL_RETURN_FLAG = 0x00;
static constexpr uint8_t STRONGEST_RETURN_FLAG = 0x01;
static constexpr uint8_t LAST_RETURN_FLAG = 0x02;
static constexpr uint8_t dual_return_flag = 0x00;
static constexpr uint8_t strongest_return_flag = 0x01;
static constexpr uint8_t last_return_flag = 0x02;

static constexpr uint8_t SYNC_MODE_GPS_FLAG = 0x00;
static constexpr uint8_t SYNC_MODE_E2E_FLAG = 0x01;
static constexpr uint8_t SYNC_MODE_P2P_FLAG = 0x02;
static constexpr uint8_t SYNC_MODE_GPTP_FLAG = 0x03;
static constexpr uint8_t sync_mode_gps_flag = 0x00;
static constexpr uint8_t sync_mode_e2_e_flag = 0x01;
static constexpr uint8_t sync_mode_p2_p_flag = 0x02;
static constexpr uint8_t sync_mode_gptp_flag = 0x03;

static constexpr uint8_t SYNC_STATUS_INVALID_FLAG = 0x00;
static constexpr uint8_t SYNC_STATUS_GPS_SUCCESS_FLAG = 0x01;
static constexpr uint8_t SYNC_STATUS_PTP_SUCCESS_FLAG = 0x02;
static constexpr uint8_t sync_status_invalid_flag = 0x00;
static constexpr uint8_t sync_status_gps_success_flag = 0x01;
static constexpr uint8_t sync_status_ptp_success_flag = 0x02;

public:
static constexpr float MIN_RANGE = 0.1f;
static constexpr float MAX_RANGE = 30.f;
static constexpr size_t MAX_SCAN_BUFFER_POINTS = 1152000;
static constexpr float min_range = 0.1f;
static constexpr float max_range = 30.f;
static constexpr size_t max_scan_buffer_points = 1152000;

int getPacketRelativePointTimeOffset(
int get_packet_relative_point_time_offset(
const uint32_t block_id, const uint32_t channel_id,
const std::shared_ptr<const RobosenseSensorConfiguration> & sensor_configuration) override
{
if (sensor_configuration->return_mode == ReturnMode::DUAL)
return firing_time_offset_ns_dual_[block_id][channel_id];
return firing_time_offset_ns_dual[block_id][channel_id];
else
return firing_time_offset_ns_single_[block_id][channel_id];
return firing_time_offset_ns_single[block_id][channel_id];
}

ReturnMode getReturnMode(const robosense_packet::bpearl_v3::InfoPacket & info_packet) override
ReturnMode get_return_mode(const robosense_packet::bpearl_v3::InfoPacket & info_packet) override
{
switch (info_packet.return_mode.value()) {
case DUAL_RETURN_FLAG:
case dual_return_flag:
return ReturnMode::DUAL;
case STRONGEST_RETURN_FLAG:
case strongest_return_flag:
return ReturnMode::SINGLE_STRONGEST;
case LAST_RETURN_FLAG:
case last_return_flag:
return ReturnMode::SINGLE_LAST;
default:
return ReturnMode::UNKNOWN;
}
}

RobosenseCalibrationConfiguration getSensorCalibration(
RobosenseCalibrationConfiguration get_sensor_calibration(
const robosense_packet::bpearl_v3::InfoPacket & info_packet) override
{
return info_packet.sensor_calibration.getCalibration();
return info_packet.sensor_calibration.get_calibration();
}

bool getSyncStatus(const robosense_packet::bpearl_v3::InfoPacket & info_packet) override
bool get_sync_status(const robosense_packet::bpearl_v3::InfoPacket & info_packet) override
{
switch (info_packet.sync_status.value()) {
case SYNC_STATUS_INVALID_FLAG:
case sync_status_invalid_flag:
return false;
case SYNC_STATUS_GPS_SUCCESS_FLAG:
case sync_status_gps_success_flag:
return true;
case SYNC_STATUS_PTP_SUCCESS_FLAG:
case sync_status_ptp_success_flag:
return true;
default:
return false;
}
}

std::map<std::string, std::string> getSensorInfo(
std::map<std::string, std::string> get_sensor_info(
const robosense_packet::bpearl_v3::InfoPacket & info_packet) override
{
std::map<std::string, std::string> sensor_info;
Expand Down Expand Up @@ -326,13 +326,13 @@ class BpearlV3 : public RobosenseSensor<
sensor_info["zero_angle_offset"] = std::to_string(info_packet.zero_angle_offset.value());

switch (info_packet.return_mode.value()) {
case DUAL_RETURN_FLAG:
case dual_return_flag:
sensor_info["return_mode"] = "dual";
break;
case STRONGEST_RETURN_FLAG:
case strongest_return_flag:
sensor_info["return_mode"] = "strongest";
break;
case LAST_RETURN_FLAG:
case last_return_flag:
sensor_info["return_mode"] = "last";
break;
default:
Expand All @@ -341,16 +341,16 @@ class BpearlV3 : public RobosenseSensor<
}

switch (info_packet.time_sync_mode.value()) {
case SYNC_MODE_GPS_FLAG:
case sync_mode_gps_flag:
sensor_info["time_sync_mode"] = "gps";
break;
case SYNC_MODE_E2E_FLAG:
case sync_mode_e2_e_flag:
sensor_info["time_sync_mode"] = "e2e";
break;
case SYNC_MODE_P2P_FLAG:
case sync_mode_p2_p_flag:
sensor_info["time_sync_mode"] = "p2p";
break;
case SYNC_MODE_GPTP_FLAG:
case sync_mode_gptp_flag:
sensor_info["time_sync_mode"] = "gptp";
break;
default:
Expand All @@ -359,13 +359,13 @@ class BpearlV3 : public RobosenseSensor<
}

switch (info_packet.sync_status.value()) {
case SYNC_STATUS_INVALID_FLAG:
case sync_status_invalid_flag:
sensor_info["sync_status"] = "time_sync_invalid";
break;
case SYNC_STATUS_GPS_SUCCESS_FLAG:
case sync_status_gps_success_flag:
sensor_info["sync_status"] = "gps_time_sync_successful";
break;
case SYNC_STATUS_PTP_SUCCESS_FLAG:
case sync_status_ptp_success_flag:
sensor_info["sync_status"] = "ptp_time_sync_successful";
break;
default:
Expand Down
Loading

0 comments on commit f5127b4

Please sign in to comment.