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

feat(ars548): updated the driver according to new documentation #253

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

knzo25
Copy link
Collaborator

@knzo25 knzo25 commented Jan 20, 2025

PR Type

  • Improvement

Related Links

Description

  • Added a frequency check on the input signals
  • Refactored radar configuration

Review Procedure

Remarks

Pre-Review Checklist for the PR Author

PR Author should check the checkboxes below when creating the PR.

  • Assign PR to reviewer

Checklist for the PR Reviewer

Reviewers should check the checkboxes below before approval.

  • Commits are properly organized and messages are according to the guideline
  • (Optional) Unit tests have been written for new behavior
  • PR title describes the changes

Post-Review Checklist for the PR Author

PR Author should check the checkboxes below before merging.

  • All open points are addressed and tracked via issues or tickets

CI Checks

  • Build and test for PR: Required to pass before the merge.

@knzo25 knzo25 requested a review from mojomex January 20, 2025 07:23
@knzo25 knzo25 self-assigned this Jan 20, 2025
@knzo25 knzo25 marked this pull request as draft January 20, 2025 07:24
@knzo25
Copy link
Collaborator Author

knzo25 commented Jan 20, 2025

Will open the PR once I confirm it works on the bench (need to delete some prints as well)

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 0% with 75 lines in your changes missing coverage. Please review.

Project coverage is 27.00%. Comparing base (33e77cf) to head (a22a695).

Files with missing lines Patch % Lines
...nental/continental_ars548_hw_interface_wrapper.cpp 0.00% 42 Missing ⚠️
..._hw_interfaces/continental_ars548_hw_interface.cpp 0.00% 21 Missing ⚠️
..._common/include/nebula_common/util/ring_buffer.hpp 0.00% 11 Missing ⚠️
...ontinental/decoders/continental_ars548_decoder.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #253      +/-   ##
==========================================
- Coverage   27.18%   27.00%   -0.18%     
==========================================
  Files         104      105       +1     
  Lines        9464     9527      +63     
  Branches     2326     2339      +13     
==========================================
  Hits         2573     2573              
- Misses       6455     6518      +63     
  Partials      436      436              
Flag Coverage Δ
differential 27.00% <0.00%> (?)
total ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@knzo25 knzo25 marked this pull request as ready for review January 21, 2025 10:00
Signed-off-by: Kenzo Lobos-Tsunekawa <[email protected]>
Copy link
Collaborator

@mojomex mojomex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!
Functionality looks good (I still have to test it with real HW), I just have a few style-related comments 🙏

Comment on lines +67 to +68
std::size_t capacity_;
std::size_t size_{0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are already members of buffer_, so storing them here is redundant and I'd suggest removing them.

Comment on lines +251 to +252
print_info("cycle_time = " + std::to_string(cycle_time_ms));
print_info("time_slot = " + std::to_string(time_slot_ms));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be more readable to print " ms" after these values

Comment on lines +128 to +152
using nebula::drivers::continental_ars548::max_odometry_hz;
using nebula::drivers::continental_ars548::min_odometry_hz;

if (last_odometry_stamp_ == 0.0) {
last_odometry_stamp_ = msg->header.stamp.sec + msg->header.stamp.nanosec * 1e-9;
} else {
double current_time = msg->header.stamp.sec + msg->header.stamp.nanosec * 1e-9;
double dt = current_time - last_odometry_stamp_;
last_odometry_stamp_ = current_time;
odometry_ring_buffer_.push_back(dt);
}

double estimated_hz = 1.0 / odometry_ring_buffer_.get_average();

if (
odometry_ring_buffer_.is_full() && (estimated_hz < static_cast<double>(min_odometry_hz) ||
estimated_hz > static_cast<double>(max_odometry_hz))) {
rclcpp::Clock clock{RCL_ROS_TIME};
RCLCPP_WARN_THROTTLE(
logger_, clock, 5000,
"The current odometry rate is %.2f Hz. The sensor requires a rate in the range of 10Hz to "
"50Hz",
estimated_hz);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is duplicated two more times below, so I'd suggest to refactor this into its own class (including last_odometry_stamp_ and odometry_ring_buffer_, called something like CallbackRateLimiter or similar).

Comment on lines +148 to +149
"The current odometry rate is %.2f Hz. The sensor requires a rate in the range of 10Hz to "
"50Hz",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please print the actual constants here instead of hard-coded 10Hz and 50Hz.

class RingBuffer
{
public:
explicit RingBuffer(std::size_t capacity) : capacity_(capacity) { buffer_.resize(capacity_); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resize initializes all values to T's default initialization (0 for numeric types) and could be replaced by reserve instead, removing the need for size_ = std::min(size_ + 1, capacity_); in L39.

uint16 cycle_time
uint16 time_slot
uint16 country_code
string frequency_band
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For usability, could you add string constants like string FREQUENCY_BAND_LOW="low" etc. to this definition?
Same for country_code 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants