-
Notifications
You must be signed in to change notification settings - Fork 664
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
refactor(autoware_image_projection_based_fusion): organize 2d-detection related members #9789
base: main
Are you sure you want to change the base?
refactor(autoware_image_projection_based_fusion): organize 2d-detection related members #9789
Conversation
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
36a57fb
to
73147c8
Compare
Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
Export the `exportProcess()` method in `fusion_node.cpp` to handle the post-processing and publishing of the fused messages. This method cancels the timer, performs the necessary post-processing steps, publishes the output message, and resets the flags. It also adds processing time for debugging purposes. This change improves the organization and readability of the code. Signed-off-by: Taekjin LEE <[email protected]>
Refactor the `fusion_node.hpp` and `fusion_node.cpp` files to improve code organization and readability. This includes exporting the `exportProcess()` method in `fusion_node.cpp` to handle post-processing and publishing of fused messages, adding comments on each process step, organizing methods, and fusing the main message with cached ROI messages. These changes enhance the overall quality of the codebase. Signed-off-by: Taekjin LEE <[email protected]>
…zation and readability Signed-off-by: Taekjin LEE <[email protected]>
…zation and readability Signed-off-by: Taekjin LEE <[email protected]>
…dability Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
…zation and readability Signed-off-by: Taekjin LEE <[email protected]>
…zation and readability Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
…zation and readability Signed-off-by: Taekjin LEE <[email protected]>
…zation and readability Signed-off-by: Taekjin LEE <[email protected]>
…zation and readability Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
e079772
to
f5a5a56
Compare
Signed-off-by: Taekjin LEE <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9789 +/- ##
==========================================
- Coverage 30.08% 30.08% -0.01%
==========================================
Files 1451 1452 +1
Lines 108854 108864 +10
Branches 42744 42724 -20
==========================================
+ Hits 32752 32753 +1
- Misses 72900 72907 +7
- Partials 3202 3204 +2
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…zation and readability Signed-off-by: Taekjin LEE <[email protected]>
@technolojin Are you sure this is "refactor" and not "feat" nor "fix"? At least the logic around mutex is changed, so I think it is risky to name it "refactor". |
using tier4_perception_msgs::msg::DetectedObjectWithFeature; | ||
using PointCloud = pcl::PointCloud<pcl::PointXYZ>; | ||
using autoware::image_projection_based_fusion::CameraProjection; | ||
using autoware_perception_msgs::msg::ObjectClassification; | ||
|
||
template <class TargetMsg3D, class ObjType, class Msg2D> | ||
template <class Msg2D> | ||
struct Det2dManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fan of "Manager" naming since it is not self contained. Would you consider something else?
Maybe something like
CameraStatus
ArrivedCameraStatus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I partially got your idea.
I think "status" is more suitable naming. Thank you.
fixed 3c73ba9
double input_offset_ms = 0.0; | ||
// cache | ||
std::map<int64_t, typename Msg2D::ConstSharedPtr> cached_det2d_msgs; | ||
std::unique_ptr<std::mutex> mtx_ptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I commented in slack, I don't understand why there is a mutex in this node after all, since all callbacks in this node is executed in a single thread. So I think it is better to remove this instead of including it in a new Struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed mutex related changes a01f84f
mutex related topic may will be treated in different pr
void exportProcess(); | ||
|
||
// 2d detection management methods | ||
bool checkAllDet2dFused() | ||
{ | ||
std::lock_guard<std::mutex> lock_det2d_flags(mutex_det2d_flags_); | ||
for (const auto & det2d : det2d_list_) { | ||
if (!det2d.is_fused) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
void setDet2dFused(Det2dManager<Msg2D> & det2d) | ||
{ | ||
std::lock_guard<std::mutex> lock_det2d_flags(mutex_det2d_flags_); | ||
det2d.is_fused = true; | ||
} | ||
void clearAllDet2dFlags() | ||
{ | ||
std::lock_guard<std::mutex> lock_det2d_flags(mutex_det2d_flags_); | ||
for (auto & det2d : det2d_list_) { | ||
det2d.is_fused = false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move this functions to private
instead of protected
since it is not intended to be used by the inherited classes. (BTW I think it is applicable to other functions such as cameraInfoCallback
, subCallback
, etc... 🫠 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed member and method access range
fixed 18bf3d0
template <class Msg2D> | ||
struct Det2dManager | ||
{ | ||
// camera index | ||
std::size_t id = 0; | ||
// camera projection | ||
std::unique_ptr<CameraProjection> camera_projector_ptr; | ||
bool project_to_unrectified_image = false; | ||
bool approximate_camera_projection = false; | ||
// process flags | ||
bool is_fused = false; | ||
// timing | ||
double input_offset_ms = 0.0; | ||
// cache | ||
std::map<int64_t, typename Msg2D::ConstSharedPtr> cached_det2d_msgs; | ||
std::unique_ptr<std::mutex> mtx_ptr; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it's better to explicitly separate mutable and immutable variables. For instance id
, project_to_unrectified_image
, or approximate_camera_projection
is immutable while cached_det2d_msgs
or is_fused
is mutable, right?
(Below is just a random implementation proposal, but maybe there is a better way to achieve this)
template <class Msg2D> | |
struct Det2dManager | |
{ | |
// camera index | |
std::size_t id = 0; | |
// camera projection | |
std::unique_ptr<CameraProjection> camera_projector_ptr; | |
bool project_to_unrectified_image = false; | |
bool approximate_camera_projection = false; | |
// process flags | |
bool is_fused = false; | |
// timing | |
double input_offset_ms = 0.0; | |
// cache | |
std::map<int64_t, typename Msg2D::ConstSharedPtr> cached_det2d_msgs; | |
std::unique_ptr<std::mutex> mtx_ptr; | |
}; | |
template <class Msg2D> | |
struct Det2dManager | |
{ | |
// camera index | |
const std::size_t id; | |
// camera projection | |
const std::unique_ptr<CameraProjection> camera_projector_ptr; | |
const bool project_to_unrectified_image; | |
const bool approximate_camera_projection; | |
// process flags | |
bool is_fused = false; | |
// timing | |
const double input_offset_ms; | |
// cache | |
std::map<int64_t, typename Msg2D::ConstSharedPtr> cached_det2d_msgs; | |
std::unique_ptr<std::mutex> mtx_ptr; | |
Det2dManager(std::size_t id_, ...): id(id_), ... {} | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a struct
and replaces vector of variables.
In terms of readability, the current struct
approach is appropriate.
I expect developers use it properly.
Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
Since the mutex related changes are removed, this PR became a pure refactoring. |
Signed-off-by: Taekjin LEE <[email protected]>
Signed-off-by: Taekjin LEE <[email protected]>
Description
Avoid to use index-based member management.
Det2dStatus
replaces vector of variables related to roi/camera.This PR do not contain any logical change.
Related links
Parent Issue:
How was this PR tested?
TIER IV INTERNAL 1
TIER IV INTERNAL 2
Notes for reviewers
None.
Interface changes
None.
Effects on system behavior
None.