-
Notifications
You must be signed in to change notification settings - Fork 554
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
Convert to ROS2 Logging #21
Comments
That sounds right to me. I imagine something like |
Thanks for the input @wjwwood. @davetcoleman as pointed out at #7 (comment), I think we should address this issue in a separate PR since it'll touch submodules of several of the packages. I presume that changes will need to be made in It'll be really helpful to get the logging somewhat addressed before we port the rest of the code. @davetcoleman since you know best the code, can you make an initial prototype extending MoveGroup |
I don't think I'll be able to get to this in the next week due to travel, and I don't think I'm the most qualified to prototype this for ROS2. |
@davetcoleman, we finished a prototype in the kinematic_contraints submodule available at https://github.com/AcutronicRobotics/moveit2/blob/master/moveit_core/kinematic_constraints/src/kinematic_constraint.cpp#L52 and used across the code as https://github.com/AcutronicRobotics/moveit2/blob/master/moveit_core/kinematic_constraints/src/kinematic_constraint.cpp#L131. We are systematically porting packages while verifying that things compile (as opposed to porting changes across all moveit2 packages, we don't know the code well enough to be doing so confidently and such ). Given the discussion above where you'd like to have a global variable (I guess in MoveGroup from what's been discussed in other threads), this approach won't the final however it'll be easily changed in the future and makes now use of RCLPP APIs which will hopefully unblock several PRs which are pending such as #7 or #9. Let me know if that's acceptable and we'll get it done. |
Thanks for putting together this prototype! I'd like some level of buy in from @wjwwood but it seems good to me. To keep our style guideline roughly the same in moveit2 (see the ROS section of that page), I'd like to keep the namespace variable the same name of In this new approach you're proposing, I assume you'll also delete your logging.h ? I was actually a fan of that approach as it would minimize the diff, for now, between ROS1 & 2. Though that isn't super important to me. Rather than links to lines of code, it's easiest to discuss the proposed change in a PR that targets logging, could you all do that please? |
Looks fine to me, only thing I'd say is that the global logger may also be |
Follow guidelines discussed at moveit#21
Follows from moveit#21 Changes in the code structure were required given the new macros used for logging.
Follows from moveit#21 Changes in the code structure were required given the new macros used for logging.
Follows from moveit#21 Changes in the code, particularly in the for loops are required due to the use of rclcpp macros
Follows from moveit#21 Changes in the code, particularly in the for loops are required due to the use of rclcpp macros
(copied and heavily modified from #12 ) According to the ROS/Google style guides, "Objects with static storage duration are forbidden unless they are trivially destructible." It would seem that a global logger like the one in the kinematic_constraints example would violate that. (see: http://wiki.ros.org/CppStyleGuide#Globals, I think we can still use I think a good rule would be to use class variables for loggers whenever possible. When this is not possible, we should be generating the logger on the fly from c-style strings with eg |
Adapt code to new logging system as discussed at moveit#21
Follows from moveit#21
I finished changing all the submodules of moveit_core in our master branch to the logging primitives recommended by @wjwwood. Changes follow from the prototype presented before at #21 (comment). This took quite a bit of time and effort.
I went through the style guide and will keep it in mind. Do you intent do have a const variable only used once to define the logger? Even if that complies with the current style, I'd argue that it can probably change as well. Specially, given the fact that the whole logging structure (and how it's used) has also changed. Maybe I'm missing something and I don't quite see how you'd like to have this so I leave it up to you. I can see @mlautman has further ideas and change suggestions however I don't think we'll be able to put more time into this in the short term since we want to move forward. I let @mlautman, @davetcoleman and others submit further improvements if you consider them necessary. Upcoming submodules ported will include the changes discussed above. |
From the style guide:
This implies to me that At any rate, I think it's safe and more efficient to statically create the logger object rather than statically store a It's up to you guys. |
I'm frustrated by the lack of tangible PRs to have these discussions on - links to code is much more difficult to iterate on and discuss inline. I re-reviewed all the discussions so far on logging am proposing a simple example that I believe scales easily to the whole code base: Feel free to comment inline there if you see issues with it. Or make a new PR with an alternative suggestion. |
@vmayoral I may have been being overly critical. I think the prototypes at #21 (comment) and #33 offer a good path forward and if the logging infrastructure changes in the future, we can reassess. |
Follows from moveit#21
* Port exceptions submodule of moveit_core * Remove dead code * Reverting change As required by https://github.com/ros-planning/moveit2/pull/7/files/eaa7cf2273745737d3c27b011a240d40b78c74ca#r259640729 * Exceptions submodule, fix logging Follows from #21 * Address error log concerns Follows from #7 (review)
* Port transforms submodule of moveit_core of ROS 2 * transforms submodule, add tests Added tests to moveit_core submodule * Cleanup transforms submodule meta-files * moveit_core, transforms submodule, back to Isometry3d Revert the changes in transform and use Isometry3d after changes in geometry2 ros2/geometry2#93 * transforms, fix logging Follows from #21 Changes in the code, particularly in the for loops are required due to the use of rclcpp macros
* Port transforms submodule of moveit_core of ROS 2 * transforms submodule, add tests Added tests to moveit_core submodule * Cleanup transforms submodule meta-files * moveit_core, transforms submodule, back to Isometry3d Revert the changes in transform and use Isometry3d after changes in geometry2 ros2/geometry2#93 * transforms, fix logging Follows from moveit#21 Changes in the code, particularly in the for loops are required due to the use of rclcpp macros
I think that's a bug in our template magic that supposed to detect when you're passing something other than a logger and instead should give a better error. It needs to be updated to remove const-ness before comparing with I just made a new issue for it here: ros2/rclcpp#679 It would be a good first contribution to |
ros2/rclcpp#680 fixes it. Thanks @wjwwood. |
* Port dynamics_solver to ROS 2 * Adapt dynamics_solver to logging #21
* Port planning_interface to ROS 2 * planning_interface, adapt logger to #21
* Port planning_request_adapter to ROS 2 * planning_request_adapter, adapt logging to #21
* kinematics_metrics, port to ROS 2 * kinematics_metrics, adapt logging to #21
* Port kinematics_base submodule moveit_core * kinematics_base, use spaces instead of tabs * Remove unnecessary cmake lines Addressed in the top level CMakeLists.txt * kinematics_base, remove redundancy in CMakeLists.txt * Undo documentation removal * Remove dead code * remove dead code in kinematics_base upon request * kinematics_base, apply clang-format * Use underscores for node names to increase readability Reviewed by @mlautman * Adapt logging Follows from #21 * Reverting change in CMakeLists.txt Keep PROPERTIES VERSION * Meet the LOGGER indications Follows from #8 (comment) taking into account that recommendations do currently fail to compile given the structure of RCLCPP macros * kinematics_base, clang format * Remove leftover in kinematics_base * Fix kinematics_base namespaces * Do not use auto Follows from review at #8 (comment) * Comply partially with review request #8 (review) * Simplify lookupParam() in KinematicsBase * Fix result param array access
* Port moveit_core/utils to ROS 2 * moveit_core/utils adapt to logging #21 * moveit_core utils - xmlrpc_casts.cpp will not be used anymore since XML-RPC is not supported in ROS 2 * moveit_core utils - fixing CmakeLists.txt * moveit_core utils - restoring addLinkCollision headers
* moveit_core, remove logging submodule Follows from #21 * Removing logging
* distance_field, adapt logging #21 * moveit_core distance field - library as SHARED * Fixing distance_field tests * moveit_core distance field - Fixing logger variable * moveit_core distance_field - converting time to seconds
* Port trajectory_processing to ROS 2 * trajectory_processing, fix logging according to #21 * moveit_core trajectory processing - library as SHARED * Fixing trajectory_processing tests * moveit_core trajectory_processing - fixing time
Added migration instructions to https://github.com/ros-planning/moveit2/blob/master/doc/MIGRATION_GUIDE.md |
My understanding of the situation: logging in ROS2 is different than ROS1 due to the lack of a singleton (the assumption that there is one ROS node per process). In ROS2 each call to the logger requires you pass in a logger handle, or the node handle. See this discussion to get the full background.
In order to achieve the MVP of moveit2, I recommend we create the ROS2 node as a global variable, or at least the logger handle as a global variable. This will limit moveit2 from having more than one instance in the same process, but we can fix that in the future.
So, in MoveGroup
main
function we'll need to create this singleton.This issue is to track the modification of logging in moveit2. @wjwwood is the lead contact for us who is expert on this issue.
The text was updated successfully, but these errors were encountered: