Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain hardcoded values #12

Merged
merged 5 commits into from
May 8, 2023
Merged

Explain hardcoded values #12

merged 5 commits into from
May 8, 2023

Conversation

ClemensLinnhoff
Copy link
Contributor

@ClemensLinnhoff ClemensLinnhoff commented May 5, 2023

Reference to a related issue in the repository
#11

Add a description

  • Remove unused functions
  • Add explanation to hardcoded values, which are waiting for implementation in OSI standard
  • Move remaining hardcoded values to profile with an explanation of the value

Take this checklist as orientation for yourself, if this PR is ready for Maintainer Review

  • My suggestion follows the governance rules.
  • All commits of this PR are signed.
  • My changes generate no errors when passing CI tests.
  • I updated all documentation (readmes incl. figures) according to my changes.
  • I have successfully implemented and tested my fix/feature locally.
  • Appropriate reviewer(s) are assigned.

@ClemensLinnhoff ClemensLinnhoff self-assigned this May 5, 2023
@ClemensLinnhoff ClemensLinnhoff linked an issue May 5, 2023 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented May 5, 2023

📜 Run clang-format on the following files

  • src/model/strategies/lidar-environmental-effects-strategy/src/DetectionEnvironmentalEffects.cpp

💬 Output from clang-tidy

src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp
/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:124:22: warning: [readability-identifier-naming]

invalid case style for local variable 'signal_strength_in_dBm'

                auto signal_strength_in_dBm = rendering_result.received_signal().signal_strength();
                     ^~~~~~~~~~~~~~~~~~~~~~
                     signal_strength_in_d_bm

/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:176:24: warning: [readability-function-cognitive-complexity]

function 'process_collected_beam_cells' has cognitive complexity of 52 (threshold 50)

void DetectionSensing::process_collected_beam_cells(LidarDetectionData* current_sensor,
                       ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:187:15: note: nesting level increased to 1
              [](const DetectionSensing::LidarBeamCellmW& first, const DetectionSensing::LidarBeamCellmW& second) { return first.dist_cell_idx < second.dist_cell_idx; });
              ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:195:5: note: +1, including nesting penalty of 0, nesting level increased to 1
    for (auto& lidar_cuboid_cell_of_beam : lidar_cuboid_cells_of_beam)
    ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:197:9: note: +2, including nesting penalty of 1, nesting level increased to 2
        if (lidar_cuboid_cell_of_beam.dist_cell_idx == summed_dist_cell_of_beam.dist_cell_idx)
        ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:201:9: note: +1, nesting level increased to 2
        else
        ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:210:5: note: +1, including nesting penalty of 0, nesting level increased to 1
    if (!thresholded_summed_dist_cells.empty())
    ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:227:9: note: +2, including nesting penalty of 1, nesting level increased to 2
        for (size_t thresholded_summed_dist_cell_dB_idx = 1; thresholded_summed_dist_cell_dB_idx < thresholded_summed_dist_cells.size(); thresholded_summed_dist_cell_dB_idx++)
        ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:230:13: note: +3, including nesting penalty of 2, nesting level increased to 3
            if ((float)thresholded_summed_dist_cells[thresholded_summed_dist_cell_dB_idx].dist_cell_idx >
            ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:236:17: note: +4, including nesting penalty of 3, nesting level increased to 4
                if (no_of_peaks_in_beam > profile.detection_sensing_parameters.max_echos_per_beam)
                ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:252:13: note: +1, nesting level increased to 3
            else
            ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:258:17: note: +4, including nesting penalty of 3, nesting level increased to 4
                if (thresholded_summed_dist_cells[thresholded_summed_dist_cell_dB_idx].signal_strength_in_dBm > peaks_in_beam[no_of_peaks_in_beam - 1].signal_strength_in_dBm)
                ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:269:9: note: +2, including nesting penalty of 1, nesting level increased to 2
        for (auto& current_peak : peaks_in_beam)
        ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:275:13: note: +3, including nesting penalty of 2, nesting level increased to 3
            if (profile.detection_sensing_parameters.echo_determination_mode == "peak")
            ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:279:13: note: +1, nesting level increased to 3
            else
            ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:287:13: note: +3, including nesting penalty of 2, nesting level increased to 3
            if ((profile.vertical_angle_clamping != "center") && (profile.beam_step_elevation > 0))
            ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:287:63: note: +1
            if ((profile.vertical_angle_clamping != "center") && (profile.beam_step_elevation > 0))
                                                              ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:289:17: note: +4, including nesting penalty of 3, nesting level increased to 4
                if (profile.vertical_angle_clamping == "max_abs")
                ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:294:22: note: +1, nesting level increased to 4
                else if (profile.vertical_angle_clamping == "top")
                     ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:298:22: note: +1, nesting level increased to 4
                else if (profile.vertical_angle_clamping == "bottom")
                     ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:305:13: note: +3, including nesting penalty of 2, nesting level increased to 3
            if (profile.detection_sensing_parameters.distance_stddev > 0.0)
            ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:321:13: note: +3, including nesting penalty of 2, nesting level increased to 3
            if (profile.detection_sensing_parameters.intensity_or_epw == 0)
            ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:324:17: note: +4, including nesting penalty of 3, nesting level increased to 4
                if (profile.detection_sensing_parameters.range_compensate_intensity)
                ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:335:17: note: +1, nesting level increased to 4
                else
                ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:358:13: note: +1, nesting level increased to 3
            else
            ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:373:17: note: +4, including nesting penalty of 3, nesting level increased to 4
                while ((count < signal_strength_to_epw.size() - 1) &&
                ^
/home/runner/work/sl-1-2-reflection-based-lidar-object-model/sl-1-2-reflection-based-lidar-object-model/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:373:68: note: +1
                while ((count < signal_strength_to_epw.size() - 1) &&
                                                                   ^

/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:227:21: warning: [readability-identifier-naming]

invalid case style for local variable 'thresholded_summed_dist_cell_dB_idx'

        for (size_t thresholded_summed_dist_cell_dB_idx = 1; thresholded_summed_dist_cell_dB_idx < thresholded_summed_dist_cells.size(); thresholded_summed_dist_cell_dB_idx++)
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    thresholded_summed_dist_cell_d_b_idx     thresholded_summed_dist_cell_d_b_idx                                        thresholded_summed_dist_cell_d_b_idx

/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:326:28: warning: [readability-identifier-naming]

invalid case style for local variable 'signal_strength_in_mW'

                    double signal_strength_in_mW = pow(10, current_peak.signal_strength_in_dBm / 10);
                           ^~~~~~~~~~~~~~~~~~~~~
                           signal_strength_in_m_w

/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:327:28: warning: [readability-identifier-naming]

invalid case style for local variable 'signal_strength_in_mW_range_compensated'

                    double signal_strength_in_mW_range_compensated = signal_strength_in_mW * (pow(detection->position().distance(), 2));
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                           signal_strength_in_m_w_range_compensated

/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:329:28: warning: [readability-identifier-naming]

invalid case style for local variable 'emitted_signal_strength_mW'

                    double emitted_signal_strength_mW = pow(10.0, profile.max_emitted_signal_strength_in_dBm / 10.0);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
                           emitted_signal_strength_m_w

/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:393:10: warning: [readability-identifier-naming]

invalid case style for local variable 'summed_signal_strength_in_dBm'

    auto summed_signal_strength_in_dBm = 10 * std::log10(summed_dist_cell_of_beam_ptr->signal_strength_in_mW);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         summed_signal_strength_in_d_bm

/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:401:20: warning: [readability-identifier-naming]

invalid case style for local variable 'threshold_mW'

            double threshold_mW = pow(10.0, threshold / 10.0) * pow(thres_distance_m, 2) / pow(range, 2);
                   ^~~~~~~~~~~~
                   threshold_m_w

/src/model/strategies/lidar-detection-sensing-strategy/src/DetectionSensing.cpp:408:26: warning: [readability-identifier-naming]

invalid case style for local variable 'thresholded_summed_dist_cell_dBm'

        LidarBeamCelldBm thresholded_summed_dist_cell_dBm;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         thresholded_summed_dist_cell_d_bm


src/model/strategies/lidar-environmental-effects-strategy/src/DetectionEnvironmentalEffects.cpp
/src/model/strategies/lidar-environmental-effects-strategy/src/DetectionEnvironmentalEffects.cpp:337:26: warning: [readability-identifier-naming]

invalid case style for local constant 'Gamma'

            const double Gamma = existing_detection.intensity() / 100.0 * 255.0 / 100.0;    //todo: calibrated to intensity values of Velodyne sensor. Change for other lidar types.
                         ^~~~~
                         gamma

/src/model/strategies/lidar-environmental-effects-strategy/src/DetectionEnvironmentalEffects.cpp:747:20: warning: [readability-identifier-naming]

invalid case style for local variable 'emitted_signal_strength_mW'

            double emitted_signal_strength_mW = pow(10.0, profile.max_emitted_signal_strength_in_dBm / 10.0);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
                   emitted_signal_strength_m_w

/src/model/strategies/lidar-environmental-effects-strategy/src/DetectionEnvironmentalEffects.cpp:749:20: warning: [readability-identifier-naming]

invalid case style for local variable 'attenuated_power_mW'

            double attenuated_power_mW =
                   ^~~~~~~~~~~~~~~~~~~
                   attenuated_power_m_w

/src/model/strategies/lidar-environmental-effects-strategy/src/DetectionEnvironmentalEffects.cpp:754:20: warning: [readability-identifier-naming]

invalid case style for local variable 'attenuated_power_noise_mW'

            double attenuated_power_noise_mW = noise_distribution(generator);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~
                   attenuated_power_noise_m_w

/src/model/strategies/lidar-environmental-effects-strategy/src/DetectionEnvironmentalEffects.cpp:755:20: warning: [readability-identifier-naming]

invalid case style for local variable 'attenuated_power_dBm'

            double attenuated_power_dBm = 10 * log10(attenuated_power_noise_mW);
                   ^~~~~~~~~~~~~~~~~~~~
                   attenuated_power_d_bm

/src/model/strategies/lidar-environmental-effects-strategy/src/DetectionEnvironmentalEffects.cpp:762:28: warning: [readability-identifier-naming]

invalid case style for local variable 'threshold_mW'

                    double threshold_mW = pow(10.0, threshold / 10.0) * pow(profile.detection_sensing_parameters.thres_distance_m, 2) / pow(range, 2);
                           ^~~~~~~~~~~~
                           threshold_m_w

@ClemensLinnhoff ClemensLinnhoff marked this pull request as ready for review May 5, 2023 11:22
@ClemensLinnhoff ClemensLinnhoff requested a review from a team May 5, 2023 11:22
@ClemensLinnhoff ClemensLinnhoff merged commit 35082e3 into main May 8, 2023
@ClemensLinnhoff ClemensLinnhoff deleted the explain-hardcoded-values branch May 8, 2023 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Explain hardcoded values
2 participants