-
Notifications
You must be signed in to change notification settings - Fork 493
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
OccupancyMapMonitor tests using Dependency Injection #569
OccupancyMapMonitor tests using Dependency Injection #569
Conversation
Codecov Report
@@ Coverage Diff @@
## main #569 +/- ##
==========================================
+ Coverage 54.22% 54.28% +0.06%
==========================================
Files 190 191 +1
Lines 20063 20084 +21
==========================================
+ Hits 10878 10901 +23
+ Misses 9185 9183 -2
Continue to review full report at Codecov.
|
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.
My initial review. I think I want to leave another round of comments later when I have time to go through it more thoroughly.
moveit_ros/occupancy_map_monitor/test/occupancy_map_monitor_tests.cpp
Outdated
Show resolved
Hide resolved
|
||
OccupancyMapMonitor::OccupancyMapMonitor(const rclcpp::Node::SharedPtr& node, double map_resolution) | ||
: map_resolution_(map_resolution), debug_info_(false), mesh_handle_count_(0), node_(node), active_(false) | ||
namespace |
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.
Nit: Should this namespace be outside the occupancy_map_monitor namespace for better readability? My personal preference is to have them be outside any namespace to underscore their "anonymousness".
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'm just copying a pattern I've seen in other parts of the MoveIt code base. I would prefer consistency, although I agree that having a separate anonymous namespace seems to be clearer. For consistency sake I want to leave this as is.
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.
https://en.cppreference.com/w/cpp/language/namespace#Unnamed_namespaces
I ... think that the difference might be if someone wrote using namespace occupancy_map_monitor;
, then another variable named LOGGER
would conflict... I think.
While users shouldn't do that https://abseil.io/tips/153, we might consider not leaving a trap for them if my suspicion is correct.
but I guess all of this is in the cpp
so... do they not export?
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.
This is in the cpp so I would assume they wouldn't export
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.
But do they?
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.
Well, as cppreference points out, things in anonymous namespaces can be imported.
In your gtest, I would try to access something in your anon namespace defined in your cpp
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.
cppreference:
Even though names in an unnamed namespace may be declared with external linkage, they are never accessible from other translation units because their namespace name is unique.
If that's what you mean by export here. But I guess you knew that before.
This only affects the individual cpp file and if anyone defines a second LOGGER there, you should change the names anyway to reflect the different meanings.
Usually I prefer anonymous namespaces inside file-wide namespaces to avoid having to spell out the file-wide namespace each time I need to access other symbols from there. While this is not used here, it makes some sense to keep the style consistent.
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.
Yeah, it didn't seem likely that anything would be exported if declared in the cpp because of the external linkage. I guess it was a bit of sticker shock since I didn't know that anon-namespace anything could be exported.
file-wide namespace?
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.
file-wide namespace?
It's not a technical term. Some maintainers introduced namespace declarations that span virtually the whole file for many packages in MoveIt (e.g., this one) to avoid the full namespace declaration for each symbol.
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.
oic
moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h
Outdated
Show resolved
Hide resolved
moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h
Outdated
Show resolved
Hide resolved
moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h
Show resolved
Hide resolved
moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h
Outdated
Show resolved
Hide resolved
moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h
Outdated
Show resolved
Hide resolved
moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h
Outdated
Show resolved
Hide resolved
moveit_ros/occupancy_map_monitor/src/occupancy_map_monitor_middleware_handle.cpp
Outdated
Show resolved
Hide resolved
moveit_ros/occupancy_map_monitor/src/occupancy_map_monitor_middleware_handle.cpp
Outdated
Show resolved
Hide resolved
moveit_ros/occupancy_map_monitor/src/occupancy_map_monitor_middleware_handle.cpp
Show resolved
Hide resolved
84aca38
to
3f6d539
Compare
moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h
Outdated
Show resolved
Hide resolved
moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h
Outdated
Show resolved
Hide resolved
moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h
Outdated
Show resolved
Hide resolved
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.
Added comments. Also, not having the ability to resolve things is very frustrating 🚀
993dd37
to
614c8e3
Compare
I agree, this seems like a github bug. https://twitter.com/weaveringrally/status/1420517755380436997 I couldn't find a github issue and found someone saying that tweeting at github has worked for them before at getting their attention. I updated all the files I've touched with the same format for includes and consistent doxygen comments with descriptions as best as I understand. |
0e29002
to
5b9fbae
Compare
3b3eb95
to
8637b7b
Compare
It seems that re-ordering the includes broke the Foxy CI run. I've installed foxy locally and am working on figuring this one out. |
8637b7b
to
0489a5b
Compare
std::unique_ptr<MiddlewareHandle> middleware_handle_; /*!< The abstract interface to ros */ | ||
std::shared_ptr<tf2_ros::Buffer> tf_buffer_; /*!< TF buffer */ | ||
Parameters parameters_; | ||
std::mutex parameters_lock_; /*!< Mutex for synchronizing access to parameters */ |
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 just realized that sometimes the access to parameters is protected by mutex but most of the time it isn't. Is that a bug or am I just reading the code wrong?
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.
This mutex is never actually used to synchronize anything. I think someone had a plan to do that but didn't. I am separately working on implementing dynamic parameters for moveit2 and will clean this up in an unrelated change.
moveit_ros/occupancy_map_monitor/src/occupancy_map_monitor_middleware_handle.cpp
Outdated
Show resolved
Hide resolved
|
||
OccupancyMapMonitor::OccupancyMapMonitor(const rclcpp::Node::SharedPtr& node, double map_resolution) | ||
: map_resolution_(map_resolution), debug_info_(false), mesh_handle_count_(0), node_(node), active_(false) | ||
namespace |
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.
oic
Description
Dependency Injection for OccupancyMapMonitor. More tests to come.
Checklist