trajectory_optimization v1.3.1
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
28 double cycle_ms = 0.0;
29 double preprocessing_ms = 0.0;
30 double solve_wall_ms = 0.0;
31 double postprocessing_ms = 0.0;
32 double acados_total_ms = 0.0;
33 double acados_lin_ms = 0.0;
34 double acados_sim_ms = 0.0;
35 double acados_qp_ms = 0.0;
36 double acados_qp_solver_ms = 0.0;
37 double acados_qp_xcond_ms = 0.0;
38 double acados_reg_ms = 0.0;
39 double acados_glob_ms = 0.0;
41 double acados_feedback_ms = 0.0;
42
43 double cost_value = 0.0;
44 double nlp_res = 0.0;
45 double kkt_norm_inf = 0.0;
46 double res_stat = 0.0;
47 double res_eq = 0.0;
48 double res_ineq = 0.0;
49 double res_comp = 0.0;
50};
51
53 public:
59 explicit PerformanceLogger(const std::string& node_name);
60
65
70
77
82
89
95 void write(const PerformanceMetrics& metrics);
96
107 static void collectSolverStatistics(PerformanceMetrics& metrics,
108 ocp_nlp_solver* solver,
109 ocp_nlp_config* config,
110 ocp_nlp_dims* dims,
111 ocp_nlp_in* input,
112 ocp_nlp_out* output);
113
119 const std::filesystem::path& path() const { return path_; }
120
121 private:
122 static constexpr uint64_t FLUSH_INTERVAL = 100;
123
124 std::filesystem::path path_;
125 std::ofstream stream_;
127};
128
129} // 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.
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 void collectSolverStatistics(PerformanceMetrics &metrics, ocp_nlp_solver *solver, ocp_nlp_config *config, ocp_nlp_dims *dims, ocp_nlp_in *input, ocp_nlp_out *output)
Reads timing, iteration, cost, and residual statistics from acados.
~PerformanceLogger()
Flushes and closes the performance log.
Namespace for trajectory_optimization package.