trajectory_optimization v1.5.0
Loading...
Searching...
No Matches
performance_logger.hpp
Go to the documentation of this file.
1// Copyright Institute for Automotive Engineering (ika), RWTH Aachen University
2// SPDX-License-Identifier: Apache-2.0
3
4#pragma once
5
6#include <cstdint>
7#include <filesystem>
8#include <fstream>
9#include <string>
10
11#include <acados_c/ocp_nlp_interface.h>
12
14
16 uint64_t cycle = 0;
17 int64_t ego_stamp_ns = 0;
18 int64_t reference_stamp_ns = 0;
19 int64_t route_stamp_ns = 0;
20 int status = 0;
21 int sqp_iter = 0;
22 int qp_iter = 0;
23 int qp_status = 0;
25 int objects = 0;
26 bool published = false;
27 bool relaxed_attempted = false;
28 std::string failure_phase = "none";
30
31 double cycle_ms = 0.0;
32 double preprocessing_ms = 0.0;
33 double solve_wall_ms = 0.0;
34 double postprocessing_ms = 0.0;
37 double acados_total_ms = 0.0;
38 double acados_lin_ms = 0.0;
39 double acados_sim_ms = 0.0;
40 double acados_qp_ms = 0.0;
41 double acados_qp_solver_ms = 0.0;
42 double acados_qp_xcond_ms = 0.0;
43 double acados_reg_ms = 0.0;
44 double acados_glob_ms = 0.0;
46 double acados_feedback_ms = 0.0;
47
48 double cost_value = 0.0;
49 double nlp_res = 0.0;
50 double kkt_norm_inf = 0.0;
51 double res_stat = 0.0;
52 double res_eq = 0.0;
53 double res_ineq = 0.0;
54 double res_comp = 0.0;
55
56 double max_ineq_violation = 0.0;
58 std::string max_ineq_type = "none";
60 std::string max_ineq_side = "none";
61 double max_eq_violation = 0.0;
62 int max_eq_stage = -1;
63 int max_eq_state = -1;
67};
68
70 public:
76 explicit PerformanceLogger(const std::string& node_name);
77
82
87
94
99
106
112 void write(const PerformanceMetrics& metrics);
113
124 static void collectSolverStatistics(PerformanceMetrics& metrics,
125 ocp_nlp_solver* solver,
126 ocp_nlp_config* config,
127 ocp_nlp_dims* dims,
128 ocp_nlp_in* input,
129 ocp_nlp_out* output,
130 bool collect_details);
131
141 ocp_nlp_solver* solver,
142 const ocp_nlp_dims* dims,
143 int object_boxes);
144
157 static bool collectSlackStatistics(PerformanceMetrics& metrics,
158 ocp_nlp_config* config,
159 ocp_nlp_dims* dims,
160 ocp_nlp_in* input,
161 ocp_nlp_out* output,
162 int object_boxes,
163 bool collect_details);
164
170 const std::filesystem::path& path() const { return path_; }
171
172 private:
173 static constexpr uint64_t FLUSH_INTERVAL = 100;
174
175 std::filesystem::path path_;
176 std::ofstream stream_;
178};
179
180} // namespace trajectory_optimization
PerformanceLogger & operator=(PerformanceLogger &&)=delete
Move assignment is disabled to keep the log stream bound to one logger.
PerformanceLogger(const std::string &node_name)
Creates a CSV performance log for the given node.
static void collectConstraintDiagnostics(PerformanceMetrics &metrics, ocp_nlp_solver *solver, const ocp_nlp_dims *dims, int object_boxes)
Collects the largest equality and inequality constraint violations from acados.
PerformanceLogger(const PerformanceLogger &)=delete
Copy construction is disabled because the logger owns a file stream.
const std::filesystem::path & path() const
Returns the path of the CSV performance log.
PerformanceLogger(PerformanceLogger &&)=delete
Move construction is disabled to keep the log stream bound to one logger.
PerformanceLogger & operator=(const PerformanceLogger &)=delete
Copy assignment is disabled because the logger owns a file stream.
void write(const PerformanceMetrics &metrics)
Appends one set of performance metrics to the CSV log.
static bool collectSlackStatistics(PerformanceMetrics &metrics, ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *input, ocp_nlp_out *output, int object_boxes, bool collect_details)
Checks all slacks for finiteness and optionally collects desired-clearance statistics.
~PerformanceLogger()
Flushes and closes the performance log.
static void collectSolverStatistics(PerformanceMetrics &metrics, ocp_nlp_solver *solver, ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *input, ocp_nlp_out *output, bool collect_details)
Reads timing, iteration, cost, and residual statistics from acados.
Namespace for trajectory_optimization package.