Skip to content

Commit

Permalink
feat: add processing time to behavior package
Browse files Browse the repository at this point in the history
Signed-off-by: tanaka3 <ttatcoder@outlook.jp>
  • Loading branch information
taikitanaka3 committed May 24, 2022
1 parent 705df15 commit fe6a8be
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include <route_handler/route_handler.hpp>
#include <tier4_autoware_utils/ros/self_pose_listener.hpp>
#include <tier4_autoware_utils/ros/debug_publisher.hpp>
#include <tier4_autoware_utils/system/stop_watch.hpp>

#include <autoware_auto_mapping_msgs/msg/had_map_bin.hpp>
#include <autoware_auto_perception_msgs/msg/predicted_objects.hpp>
Expand Down Expand Up @@ -175,6 +177,10 @@ class BehaviorPathPlannerNode : public rclcpp::Node
rclcpp::Publisher<AvoidanceDebugMsgArray>::SharedPtr debug_avoidance_msg_array_publisher_;
rclcpp::Publisher<MarkerArray>::SharedPtr debug_marker_publisher_;
void publishDebugMarker(const std::vector<MarkerArray> & debug_markers);

/** \brief processing time publisher. **/
std::unique_ptr<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_;
std::unique_ptr<tier4_autoware_utils::DebugPublisher> debug_publisher_;
};
} // namespace behavior_path_planner

Expand Down
14 changes: 14 additions & 0 deletions planning/behavior_path_planner/src/behavior_path_planner_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ BehaviorPathPlannerNode::BehaviorPathPlannerNode(const rclcpp::NodeOptions & nod
timer_ = rclcpp::create_timer(
this, get_clock(), period_ns, std::bind(&BehaviorPathPlannerNode::run, this));
}
// initialize debug tool
{
using tier4_autoware_utils::DebugPublisher;
using tier4_autoware_utils::StopWatch;
stop_watch_ptr_ = std::make_unique<StopWatch<std::chrono::milliseconds>>();
debug_publisher_ = std::make_unique<DebugPublisher>(this, "behavior_path_planner");
stop_watch_ptr_->tic();
}
}

BehaviorPathPlannerParameters BehaviorPathPlannerNode::getCommonParam()
Expand Down Expand Up @@ -515,6 +523,12 @@ void BehaviorPathPlannerNode::waitForData()

void BehaviorPathPlannerNode::run()
{
// add processing time for debug
if (debug_publisher_) {
const double processing_time_ms = stop_watch_ptr_->toc(true);
debug_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
"debug/processing_time_ms", processing_time_ms);
}
RCLCPP_DEBUG(get_logger(), "----- BehaviorPathPlannerNode start -----");
mutex_bt_.lock(); // for bt_manager_
mutex_pd_.lock(); // for planner_data_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <tier4_api_msgs/msg/crosswalk_status.hpp>
#include <tier4_api_msgs/msg/intersection_status.hpp>
#include <tier4_planning_msgs/msg/velocity_limit.hpp>
#include <tier4_autoware_utils/ros/debug_publisher.hpp>
#include <tier4_autoware_utils/system/stop_watch.hpp>

#include <tf2_ros/buffer.h>
#include <tf2_ros/transform_listener.h>
Expand Down Expand Up @@ -113,6 +115,11 @@ class BehaviorVelocityPlannerNode : public rclcpp::Node
// function
geometry_msgs::msg::PoseStamped getCurrentPose();
bool isDataReady(const PlannerData planner_data) const;

// debug
std::unique_ptr<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_;
std::unique_ptr<tier4_autoware_utils::DebugPublisher> debug_publisher_;

};
} // namespace behavior_velocity_planner

Expand Down
7 changes: 7 additions & 0 deletions planning/behavior_velocity_planner/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,13 @@ void BehaviorVelocityPlannerNode::onTrigger(
if (debug_viz_pub_->get_subscription_count() > 0) {
publishDebugMarker(output_path_msg);
}

// add processing time for debug
if (debug_publisher_) {
const double processing_time_ms = stop_watch_ptr_->toc(true);
debug_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
"debug/processing_time_ms", processing_time_ms);
}
}

void BehaviorVelocityPlannerNode::publishDebugMarker(
Expand Down

0 comments on commit fe6a8be

Please sign in to comment.