1
- // Copyright 2025 Tier IV, Inc.
1
+ // Copyright 2021 Tier IV, Inc.
2
2
//
3
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
4
// you may not use this file except in compliance with the License.
16
16
#define AUTOWARE__PLANNING_EVALUATOR__PLANNING_EVALUATOR_NODE_HPP_
17
17
18
18
#include " autoware/planning_evaluator/metrics_calculator.hpp"
19
- #include " autoware_utils/math/accumulator .hpp"
19
+ #include " autoware/planning_evaluator/stat .hpp"
20
20
#include " rclcpp/rclcpp.hpp"
21
21
#include " tf2_ros/buffer.h"
22
22
#include " tf2_ros/transform_listener.h"
23
23
24
- #include < autoware/route_handler/route_handler.hpp>
25
- #include < autoware_utils/ros/polling_subscriber.hpp>
26
- #include < autoware_utils/system/stop_watch.hpp>
27
- #include < autoware_vehicle_info_utils/vehicle_info_utils.hpp>
28
-
29
24
#include " autoware_perception_msgs/msg/predicted_objects.hpp"
30
25
#include " autoware_planning_msgs/msg/pose_with_uuid_stamped.hpp"
31
26
#include " autoware_planning_msgs/msg/trajectory.hpp"
32
27
#include " autoware_planning_msgs/msg/trajectory_point.hpp"
33
- #include " geometry_msgs /msg/accel_with_covariance_stamped .hpp"
28
+ #include " diagnostic_msgs /msg/diagnostic_array .hpp"
34
29
#include " nav_msgs/msg/odometry.hpp"
35
- #include < autoware_internal_debug_msgs/msg/float64_stamped.hpp>
36
- #include < autoware_planning_msgs/msg/lanelet_route.hpp>
37
- #include < tier4_metric_msgs/msg/metric.hpp>
38
- #include < tier4_metric_msgs/msg/metric_array.hpp>
39
30
40
31
#include < array>
41
32
#include < deque>
42
33
#include < memory>
43
34
#include < string>
44
35
#include < vector>
36
+
45
37
namespace planning_diagnostics
46
38
{
47
- using autoware::vehicle_info_utils::VehicleInfo;
48
39
using autoware_perception_msgs::msg::PredictedObjects;
49
40
using autoware_planning_msgs::msg::PoseWithUuidStamped;
50
41
using autoware_planning_msgs::msg::Trajectory;
51
42
using autoware_planning_msgs::msg::TrajectoryPoint;
52
- using autoware_utils::Accumulator;
53
- using MetricMsg = tier4_metric_msgs::msg::Metric;
54
- using MetricArrayMsg = tier4_metric_msgs::msg::MetricArray;
43
+ using diagnostic_msgs::msg::DiagnosticArray;
44
+ using diagnostic_msgs::msg::DiagnosticStatus;
55
45
using nav_msgs::msg::Odometry;
56
- using LaneletMapBin = autoware_map_msgs::msg::LaneletMapBin;
57
- using autoware_planning_msgs::msg::LaneletRoute;
58
- using geometry_msgs::msg::AccelWithCovarianceStamped;
59
46
/* *
60
47
* @brief Node for planning evaluation
61
48
*/
62
49
class PlanningEvaluatorNode : public rclcpp ::Node
63
50
{
64
51
public:
65
52
explicit PlanningEvaluatorNode (const rclcpp::NodeOptions & node_options);
66
- ~PlanningEvaluatorNode () override ;
53
+ ~PlanningEvaluatorNode ();
67
54
68
55
/* *
69
56
* @brief callback on receiving an odometry
@@ -75,8 +62,7 @@ class PlanningEvaluatorNode : public rclcpp::Node
75
62
* @brief callback on receiving a trajectory
76
63
* @param [in] traj_msg received trajectory message
77
64
*/
78
- void onTrajectory (
79
- const Trajectory::ConstSharedPtr traj_msg, const Odometry::ConstSharedPtr ego_state_ptr);
65
+ void onTrajectory (const Trajectory::ConstSharedPtr traj_msg);
80
66
81
67
/* *
82
68
* @brief callback on receiving a reference trajectory
@@ -94,81 +80,42 @@ class PlanningEvaluatorNode : public rclcpp::Node
94
80
* @brief callback on receiving a modified goal
95
81
* @param [in] modified_goal_msg received modified goal message
96
82
*/
97
- void onModifiedGoal (
98
- const PoseWithUuidStamped::ConstSharedPtr modified_goal_msg,
99
- const Odometry::ConstSharedPtr ego_state_ptr);
100
-
101
- /* *
102
- * @brief add the given metric statistic
103
- */
104
- void AddMetricMsg (const Metric & metric, const Accumulator<double > & metric_stat);
105
-
106
- /* *
107
- * @brief add current ego lane info
108
- */
109
- void AddLaneletMetricMsg (const Odometry::ConstSharedPtr ego_state_ptr);
83
+ void onModifiedGoal (const PoseWithUuidStamped::ConstSharedPtr modified_goal_msg);
110
84
111
85
/* *
112
- * @brief add current ego kinematic state
86
+ * @brief publish the given metric statistic
113
87
*/
114
- void AddKinematicStateMetricMsg (
115
- const AccelWithCovarianceStamped & accel_stamped , const Odometry::ConstSharedPtr ego_state_ptr) ;
88
+ DiagnosticStatus generateDiagnosticStatus (
89
+ const Metric & metric , const Stat< double > & metric_stat) const ;
116
90
117
91
private:
118
92
static bool isFinite (const TrajectoryPoint & p);
119
-
120
- /* *
121
- * @brief update route handler data
122
- */
123
- void getRouteData ();
124
-
125
- /* *
126
- * @brief fetch data and publish diagnostics
127
- */
128
- void onTimer ();
93
+ void publishModifiedGoalDeviationMetrics ();
129
94
130
95
// ROS
131
- autoware_utils::InterProcessPollingSubscriber<Trajectory> traj_sub_{this , " ~/input/trajectory" };
132
- autoware_utils::InterProcessPollingSubscriber<Trajectory> ref_sub_{
133
- this , " ~/input/reference_trajectory" };
134
- autoware_utils::InterProcessPollingSubscriber<PredictedObjects> objects_sub_{
135
- this , " ~/input/objects" };
136
- autoware_utils::InterProcessPollingSubscriber<PoseWithUuidStamped> modified_goal_sub_{
137
- this , " ~/input/modified_goal" };
138
- autoware_utils::InterProcessPollingSubscriber<Odometry> odometry_sub_{this , " ~/input/odometry" };
139
- autoware_utils::InterProcessPollingSubscriber<
140
- LaneletRoute, autoware_utils::polling_policy::Newest>
141
- route_subscriber_{this , " ~/input/route" , rclcpp::QoS{1 }.transient_local ()};
142
- autoware_utils::InterProcessPollingSubscriber<
143
- LaneletMapBin, autoware_utils::polling_policy::Newest>
144
- vector_map_subscriber_{this , " ~/input/vector_map" , rclcpp::QoS{1 }.transient_local ()};
145
- autoware_utils::InterProcessPollingSubscriber<AccelWithCovarianceStamped> accel_sub_{
146
- this , " ~/input/acceleration" };
147
-
148
- rclcpp::Publisher<autoware_internal_debug_msgs::msg::Float64Stamped>::SharedPtr
149
- processing_time_pub_;
150
- rclcpp::Publisher<MetricArrayMsg>::SharedPtr metrics_pub_;
96
+ rclcpp::Subscription<Trajectory>::SharedPtr traj_sub_;
97
+ rclcpp::Subscription<Trajectory>::SharedPtr ref_sub_;
98
+ rclcpp::Subscription<PredictedObjects>::SharedPtr objects_sub_;
99
+ rclcpp::Subscription<PoseWithUuidStamped>::SharedPtr modified_goal_sub_;
100
+ rclcpp::Subscription<Odometry>::SharedPtr odom_sub_;
101
+
102
+ rclcpp::Publisher<DiagnosticArray>::SharedPtr metrics_pub_;
151
103
std::shared_ptr<tf2_ros::TransformListener> transform_listener_{nullptr };
152
104
std::unique_ptr<tf2_ros::Buffer> tf_buffer_;
153
- autoware::route_handler::RouteHandler route_handler_;
154
-
155
- // Message to publish
156
- MetricArrayMsg metrics_msg_;
157
105
158
106
// Parameters
159
- bool output_metrics_ ;
107
+ std::string output_file_str_ ;
160
108
std::string ego_frame_str_;
161
109
162
110
// Calculator
163
111
MetricsCalculator metrics_calculator_;
164
112
// Metrics
165
113
std::vector<Metric> metrics_;
166
- std::array<std::array<Accumulator< double >, 3 >, static_cast < size_t >(Metric::SIZE)>
167
- metric_accumulators_; // 3(min, max, mean) * metric_size
114
+ std::deque<rclcpp::Time> stamps_;
115
+ std::array<std::deque<Stat< double >>, static_cast < size_t >(Metric::SIZE)> metric_stats_;
168
116
169
- rclcpp::TimerBase::SharedPtr timer_;
170
- VehicleInfo vehicle_info_;
171
- std::optional<AccelWithCovarianceStamped> prev_acc_stamped_{std::nullopt};
117
+ Odometry::ConstSharedPtr ego_state_ptr_;
118
+ PoseWithUuidStamped::ConstSharedPtr modified_goal_ptr_;
172
119
};
173
120
} // namespace planning_diagnostics
174
121
0 commit comments