How to get sim time in nav2 behavior tree.

asked 2022-07-26 05:16:11 -0600

stu00608 gravatar image

Hi everyone,

recently using nav2 behavior tree galactic release 1.12.0 in c++, running turtlebot3 simulation.

I want to publish a path msg to /plan inside the behavior tree node, This message contains header, so I need to take the time in gazebo (/clock). But when I use node_->get_clock()->now(), it returns my system wall time.

First one comes from global planner, and the second one is from my bt node, so on.

$ ros2 topic echo /plan --field header

stamp:
  sec: 19
  nanosec: 518000000
frame_id: map
---
stamp:
  sec: 1658829679
  nanosec: 110900249
frame_id: map
---
stamp:
  sec: 1658829680
  nanosec: 123199445
frame_id: map
---

In the bt node node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node");

Is there some ways to get sim time in bt node class? If I'm doing something wrong please tell me. Thank you!

edit retag flag offensive close merge delete