21
21
#include " autoware/path_optimizer/common_structs.hpp"
22
22
#include " autoware/path_optimizer/state_equation_generator.hpp"
23
23
#include " autoware/path_optimizer/type_alias.hpp"
24
+ #include " autoware/path_optimizer/utils/conditional_timer.hpp"
24
25
#include " autoware_utils/geometry/geometry.hpp"
25
26
#include " autoware_utils/system/time_keeper.hpp"
26
27
#include " autoware_vehicle_info_utils/vehicle_info_utils.hpp"
@@ -57,6 +58,15 @@ struct Bounds
57
58
lower_bound -= offset;
58
59
upper_bound -= offset;
59
60
}
61
+
62
+ friend std::ostream & operator <<(std::ostream & os, const Bounds & bounds)
63
+ {
64
+ os << " Bounds: {\n " ;
65
+ os << " \t lower_bound: " << bounds.lower_bound << " ,\n " ;
66
+ os << " \t upper_bound: " << bounds.upper_bound << " \n " ;
67
+ os << " }\n " ;
68
+ return os;
69
+ }
60
70
};
61
71
62
72
struct KinematicState
@@ -65,6 +75,15 @@ struct KinematicState
65
75
double yaw{0.0 };
66
76
67
77
Eigen::Vector2d toEigenVector () const { return Eigen::Vector2d{lat, yaw}; }
78
+
79
+ friend std::ostream & operator <<(std::ostream & os, const KinematicState & state)
80
+ {
81
+ os << " KinematicState: {\n " ;
82
+ os << " \t lat: " << state.lat << " ,\n " ;
83
+ os << " \t yaw: " << state.yaw << " \n " ;
84
+ os << " }\n " ;
85
+ return os;
86
+ }
68
87
};
69
88
70
89
struct ReferencePoint
@@ -92,6 +111,57 @@ struct ReferencePoint
92
111
93
112
double getYaw () const { return tf2::getYaw (pose.orientation ); }
94
113
114
+
115
+ friend std::ostream & operator <<(std::ostream & os, const ReferencePoint & ref_point)
116
+ {
117
+ os << " ReferencePoint: {\n " ;
118
+ os << " \t pose: " << ref_point.pose .position .x << " , " << ref_point.pose .position .y << " ,\n " ;
119
+ os << " \t longitudinal_velocity_mps: " << ref_point.longitudinal_velocity_mps << " ,\n " ;
120
+ os << " \t curvature: " << ref_point.curvature << " ,\n " ;
121
+ os << " \t delta_arc_length: " << ref_point.delta_arc_length << " ,\n " ;
122
+ os << " \t alpha: " << ref_point.alpha << " ,\n " ;
123
+ os << " \t bounds: " << ref_point.bounds << " ,\n " ;
124
+ os << " \t beta: [" ;
125
+ for (const auto & b : ref_point.beta ) {
126
+ os << b << " , " ;
127
+ }
128
+ os << " ],\n " ;
129
+ os << " \t normalized_avoidance_cost: " << ref_point.normalized_avoidance_cost << " ,\n " ;
130
+ os << " \t bounds_on_constraints: [" ;
131
+ for (const auto & b : ref_point.bounds_on_constraints ) {
132
+ os << b << " , " ;
133
+ }
134
+ os << " ],\n " ;
135
+ os << " \t pose_on_constraints: [" ;
136
+ for (const auto & p : ref_point.pose_on_constraints ) {
137
+ os << " (" << p.position .x << " , " << p.position .y << " ) , " ;
138
+ }
139
+ os << " ],\n " ;
140
+ os << " \t fixed_kinematic_state: " ;
141
+ if (ref_point.fixed_kinematic_state ) {
142
+ os << *ref_point.fixed_kinematic_state ;
143
+ } else {
144
+ os << " nullopt" ;
145
+ }
146
+ os << " ,\n " ;
147
+ os << " \t optimized_kinematic_state: " << ref_point.optimized_kinematic_state
148
+ << " ,\n " ;
149
+ os << " \t optimized_input: " << ref_point.optimized_input << " ,\n " ;
150
+ os << " \t slack_variables: " ;
151
+ if (ref_point.slack_variables ) {
152
+ os << " [" ;
153
+ for (const auto & s : *ref_point.slack_variables ) {
154
+ os << s << " , " ;
155
+ }
156
+ os << " ]" ;
157
+ } else {
158
+ os << " nullopt" ;
159
+ }
160
+ os << " \n " ;
161
+ os << " }\n " ;
162
+ return os;
163
+ }
164
+
95
165
geometry_msgs::msg::Pose offsetDeviation (const double lat_dev, const double yaw_dev) const
96
166
{
97
167
auto pose_with_deviation = autoware_utils::calc_offset_pose (pose, 0.0 , lat_dev, 0.0 );
@@ -110,7 +180,7 @@ class MPTOptimizer
110
180
const TrajectoryParam & traj_param, const std::shared_ptr<DebugData> debug_data_ptr,
111
181
const std::shared_ptr<autoware_utils::TimeKeeper> time_keeper_);
112
182
113
- std::vector<TrajectoryPoint> optimizeTrajectory (const PlannerData & planner_data);
183
+ std::pair<std:: vector<TrajectoryPoint>, int > optimizeTrajectory (const PlannerData & planner_data);
114
184
std::optional<std::vector<TrajectoryPoint>> getPrevOptimizedTrajectoryPoints () const ;
115
185
116
186
void initialize (const bool enable_debug_info, const TrajectoryParam & traj_param);
@@ -126,19 +196,47 @@ class MPTOptimizer
126
196
{
127
197
Eigen::SparseMatrix<double > Q;
128
198
Eigen::SparseMatrix<double > R;
199
+
200
+ friend std::ostream & operator <<(std::ostream & os, const ValueMatrix & matrix)
201
+ {
202
+ os << " ValueMatrix: {\n " ;
203
+ os << " \t Q: (Sparse Matrix):" << matrix.Q ;
204
+ os << " \t R: (Sparse Matrix):" << matrix.R ;
205
+ os << " }\n " ;
206
+ return os;
207
+ }
129
208
};
130
209
131
210
struct ObjectiveMatrix
132
211
{
133
212
Eigen::MatrixXd hessian;
134
213
Eigen::VectorXd gradient;
214
+
215
+ friend std::ostream & operator <<(std::ostream & os, const ObjectiveMatrix & matrix)
216
+ {
217
+ os << " ObjectiveMatrix: {\n " ;
218
+ os << " \t hessian:\n " << matrix.hessian << " \n " ;
219
+ os << " \t gradient:\n " << matrix.gradient << " \n " ;
220
+ os << " }\n " ;
221
+ return os;
222
+ }
135
223
};
136
224
137
225
struct ConstraintMatrix
138
226
{
139
227
Eigen::MatrixXd linear;
140
228
Eigen::VectorXd lower_bound;
141
229
Eigen::VectorXd upper_bound;
230
+
231
+ friend std::ostream & operator <<(std::ostream & os, const ConstraintMatrix & matrix)
232
+ {
233
+ os << " ConstraintMatrix: {\n " ;
234
+ os << " \t linear:\n " << matrix.linear << " \n " ;
235
+ os << " \t lower_bound:\n " << matrix.lower_bound << " \n " ;
236
+ os << " \t upper_bound:\n " << matrix.upper_bound << " \n " ;
237
+ os << " }\n " ;
238
+ return os;
239
+ }
142
240
};
143
241
144
242
struct MPTParam
0 commit comments