Crocoddyl
Loading...
Searching...
No Matches
callbacks.hpp
1
2// BSD 3-Clause License
3//
4// Copyright (C) 2019-2025, LAAS-CNRS, University of Oxford,
5// Heriot-Watt University
6// Copyright note valid unless otherwise stated in individual files.
7// All rights reserved.
9
10#ifndef CROCODDYL_CORE_UTILS_CALLBACKS_HPP_
11#define CROCODDYL_CORE_UTILS_CALLBACKS_HPP_
12
13#include "crocoddyl/core/solver-base.hpp"
14
15namespace crocoddyl {
16
17enum VerboseLevel {
18 _0 = 0, //<! Zero print level that doesn't contain merit-function and
19 // constraints information
20 _1, //<! First print level that includes level-0, merit-function and
21 // dynamics-constraints information
22 _2, //<! Second print level that includes level-1 and dual-variable
23 // regularization
24 _3, //<! Third print level that includes level-2, and equality and inequality
25 // constraints information
26 _4, //<! Fourht print level that includes expected and current improvements
27 // in the merit function
28};
29
30template <typename _Scalar>
31class CallbackVerboseTpl : public CallbackAbstractTpl<_Scalar> {
32 public:
33 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
34 CROCODDYL_DERIVED_FLOATINGPOINT_CAST(CallbackBase, CallbackVerboseTpl)
35
36 typedef _Scalar Scalar;
37 typedef CallbackAbstractTpl<Scalar> CallbackAbstract;
38 typedef SolverAbstractTpl<Scalar> SolverAbstract;
39
40 explicit CallbackVerboseTpl(VerboseLevel level = _4, int precision = 3);
41 ~CallbackVerboseTpl() = default;
42
43 void operator()(SolverAbstract& solver) override;
44
45 VerboseLevel get_level() const;
46 void set_level(VerboseLevel level);
47
48 int get_precision() const;
49 void set_precision(int precision);
50
60 template <typename NewScalar>
61 CallbackVerboseTpl<NewScalar> cast() const;
62
63 private:
64 VerboseLevel level_;
65 int precision_;
66 std::string header_;
67 std::string separator_;
68 std::string separator_short_;
69
70 void update_header();
71};
72
73} // namespace crocoddyl
74
75/* --- Details -------------------------------------------------------------- */
76/* --- Details -------------------------------------------------------------- */
77/* --- Details -------------------------------------------------------------- */
78#include "crocoddyl/core/utils/callbacks.hxx"
79
80#endif // CROCODDYL_CORE_UTILS_CALLBACKS_HPP_
CallbackAbstractTpl()
Initialize the callback function.
CallbackVerboseTpl< NewScalar > cast() const
Cast the verbose callback.
void operator()(SolverAbstract &solver) override
Run the callback function given a solver.
Abstract class for optimal control solvers.