diff --git a/nav2_amcl/src/amcl_node.cpp b/nav2_amcl/src/amcl_node.cpp
index a0f4c3f1813244d9d1637d29dbb26f07c218a06e..75e5b07b0ac4472835045c4c3bfadb339211810d 100644
--- a/nav2_amcl/src/amcl_node.cpp
+++ b/nav2_amcl/src/amcl_node.cpp
@@ -252,7 +252,7 @@ AmclNode::checkLaserReceived()
return;
}
- rclcpp::Duration d = rclcpp_node_->now() - last_laser_received_ts_;
+ rclcpp::Duration d = now() - last_laser_received_ts_;
if (d.nanoseconds() * 1e-9 > laser_check_interval_.count()) {
RCLCPP_WARN(
get_logger(), "No laser scan received (and thus no pose updates have been published) for %f"
@@ -264,7 +264,7 @@ AmclNode::checkLaserReceived()
bool
AmclNode::checkElapsedTime(std::chrono::seconds check_interval, rclcpp::Time last_time)
{
- rclcpp::Duration elapsed_time = rclcpp_node_->now() - last_time;
+ rclcpp::Duration elapsed_time = now() - last_time;
if (elapsed_time.nanoseconds() * 1e-9 > check_interval.count()) {
return true;
}
@@ -411,7 +411,7 @@ AmclNode::handleInitialPose(geometry_msgs::msg::PoseWithCovarianceStamped::Share
// intervening odometric change.
geometry_msgs::msg::TransformStamped tx_odom;
try {
- rclcpp::Time rclcpp_time = rclcpp_node_->now();
+ rclcpp::Time rclcpp_time = now();
tf2::TimePoint tf2_time(std::chrono::nanoseconds(rclcpp_time.nanoseconds()));
// Check if the transform is available
@@ -439,7 +439,7 @@ AmclNode::handleInitialPose(geometry_msgs::msg::PoseWithCovarianceStamped::Share
// Transform into the global frame
RCLCPP_INFO(get_logger(), "Setting pose (%.6f): %.3f %.3f %.3f",
- rclcpp_node_->now().nanoseconds() * 1e-9,
+ now().nanoseconds() * 1e-9,
pose_new.getOrigin().x(),
pose_new.getOrigin().y(),
tf2::getYaw(pose_new.getRotation()));
@@ -474,7 +474,7 @@ AmclNode::laserReceived(sensor_msgs::msg::LaserScan::ConstSharedPtr laser_scan)
if (!active_) {return;}
std::string laser_scan_frame_id = nav2_util::strip_leading_slash(laser_scan->header.frame_id);
- last_laser_received_ts_ = rclcpp_node_->now();
+ last_laser_received_ts_ = now();
int laser_index = -1;
geometry_msgs::msg::PoseStamped laser_pose;
diff --git a/nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp b/nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp
index 7f30e1184c95c7b149dda651868cad5663bf2a89..e737cc8691f6fc90caa4dfa0af6e475b905f9286 100644
--- a/nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp
+++ b/nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_ros.hpp
@@ -127,7 +127,7 @@ public:
* @param global_pose Will be set to the pose of the robot in the global frame of the costmap
* @return True if the pose was set successfully, false otherwise
*/
- bool getRobotPose(geometry_msgs::msg::PoseStamped & global_pose) const;
+ bool getRobotPose(geometry_msgs::msg::PoseStamped & global_pose);
/** @brief Returns costmap name */
std::string getName() const
diff --git a/nav2_costmap_2d/src/costmap_2d_ros.cpp b/nav2_costmap_2d/src/costmap_2d_ros.cpp
index 3c4e2d60bf0cac4d4a7b69c47ae2c7445dbf7406..0d57196a6a691ad7b26eb50c5ccbad506846456a 100644
--- a/nav2_costmap_2d/src/costmap_2d_ros.cpp
+++ b/nav2_costmap_2d/src/costmap_2d_ros.cpp
@@ -365,7 +365,7 @@ Costmap2DROS::mapUpdateLoop(double frequency)
layered_costmap_->getBounds(&x0, &xn, &y0, &yn);
costmap_publisher_->updateBounds(x0, xn, y0, yn);
- auto current_time = rclcpp_node_->now();
+ auto current_time = now();
if ((last_publish_ + publish_cycle_ < current_time) || // publish_cycle_ is due
(current_time < last_publish_)) // time has moved backwards, probably due to a switch to sim_time // NOLINT
{
@@ -406,7 +406,7 @@ Costmap2DROS::updateMap()
geometry_msgs::msg::PolygonStamped footprint;
footprint.header.frame_id = global_frame_;
- footprint.header.stamp = rclcpp_node_->now();
+ footprint.header.stamp = now();
transformFootprint(x, y, yaw, padded_footprint_, footprint);
@@ -495,7 +495,7 @@ Costmap2DROS::resetLayers()
}
bool
-Costmap2DROS::getRobotPose(geometry_msgs::msg::PoseStamped & global_pose) const
+Costmap2DROS::getRobotPose(geometry_msgs::msg::PoseStamped & global_pose)
{
geometry_msgs::msg::PoseStamped robot_pose;
@@ -506,7 +506,7 @@ Costmap2DROS::getRobotPose(geometry_msgs::msg::PoseStamped & global_pose) const
robot_pose.header.stamp = rclcpp::Time();
// Save time for checking tf delay later
- rclcpp::Time current_time = rclcpp_node_->now();
+ rclcpp::Time current_time = now();
// Get the global pose of the robot
try {