Skip to content

Convert to ROS2 Logging #21

Closed
Closed

Description

@davetcoleman

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.

Activity

  1. wjwwood commented on Feb 23, 2019

    @wjwwood
    Contributor

    That sounds right to me. I imagine something like moveit_core::get_logger() -> rclcpp::Logger which can be called from anywhere to get a logger to be used locally and a way to set that from something ros specific in main function or core constructor, e.g. moveit_ros::set_logger(my_node->get_logger()) which internally might call moveit_core::set_logger().

  2. vmayoral commented on Feb 24, 2019

    @vmayoral
    Contributor

    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 moveit_ros package, right?

    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 main function while following the guidelines of @wjwwood? That'll speed things up significantly on our side.

  3. davetcoleman commented on Feb 24, 2019

    @davetcoleman
    MemberAuthor

    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.

  4. vmayoral commented on Feb 26, 2019

    @vmayoral
    Contributor

    @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.

  5. davetcoleman commented on Feb 27, 2019

    @davetcoleman
    MemberAuthor

    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 LOGNAME. Its also more space efficient.

    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?

  6. wjwwood commented on Feb 28, 2019

    @wjwwood
    Contributor

    Looks fine to me, only thing I'd say is that the global logger may also be static and const.

  7. mlautman commented on Mar 4, 2019

    @mlautman
    Contributor

    (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,
    https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables)

    I think we can still use constexpr and store the name as char*'s at the top of the cpp's and create loggers as needed.

    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 RCUTILS_LOG_INFO(LOGNAME, "....");.

  8. 36 remaining items

  9. vmayoral commented on Apr 2, 2019

    @vmayoral
    Contributor

    ros2/rclcpp#680 fixes it. Thanks @wjwwood.

  10. added a commit that references this issue on May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions