GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/core/integ-action-base.hpp
Date: 2025-01-30 11:01:55
Exec Total Coverage
Lines: 0 28 0.0%
Branches: 0 98 0.0%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2021-2022, LAAS-CNRS, University of Edinburgh, University of
5 // Trento Copyright note valid unless otherwise stated in individual files. All
6 // rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #ifndef BINDINGS_PYTHON_CROCODDYL_CORE_INTEGRATED_ACTION_BASE_HPP_
10 #define BINDINGS_PYTHON_CROCODDYL_CORE_INTEGRATED_ACTION_BASE_HPP_
11
12 #include "crocoddyl/core/integ-action-base.hpp"
13 #include "crocoddyl/core/utils/exception.hpp"
14 #include "python/crocoddyl/core/core.hpp"
15
16 namespace crocoddyl {
17 namespace python {
18
19 class IntegratedActionModelAbstract_wrap
20 : public IntegratedActionModelAbstract,
21 public bp::wrapper<IntegratedActionModelAbstract> {
22 public:
23 IntegratedActionModelAbstract_wrap(
24 std::shared_ptr<DifferentialActionModelAbstract> model,
25 const double timestep = 1e-3, const bool with_cost_residual = true)
26 : IntegratedActionModelAbstract(model, timestep, with_cost_residual),
27 bp::wrapper<IntegratedActionModelAbstract>() {}
28
29 IntegratedActionModelAbstract_wrap(
30 std::shared_ptr<DifferentialActionModelAbstract> model,
31 std::shared_ptr<ControlParametrizationModelAbstract> control,
32 const double timestep = 1e-3, const bool with_cost_residual = true)
33 : IntegratedActionModelAbstract(model, control, timestep,
34 with_cost_residual),
35 bp::wrapper<IntegratedActionModelAbstract>() {}
36
37 void calc(const std::shared_ptr<ActionDataAbstract>& data,
38 const Eigen::Ref<const Eigen::VectorXd>& x,
39 const Eigen::Ref<const Eigen::VectorXd>& u) {
40 if (static_cast<std::size_t>(x.size()) != state_->get_nx()) {
41 throw_pretty(
42 "Invalid argument: " << "x has wrong dimension (it should be " +
43 std::to_string(state_->get_nx()) + ")");
44 }
45 if (static_cast<std::size_t>(u.size()) != nu_) {
46 throw_pretty(
47 "Invalid argument: " << "u has wrong dimension (it should be " +
48 std::to_string(nu_) + ")");
49 }
50 return bp::call<void>(this->get_override("calc").ptr(), data,
51 (Eigen::VectorXd)x, (Eigen::VectorXd)u);
52 }
53
54 void calcDiff(const std::shared_ptr<ActionDataAbstract>& data,
55 const Eigen::Ref<const Eigen::VectorXd>& x,
56 const Eigen::Ref<const Eigen::VectorXd>& u) {
57 if (static_cast<std::size_t>(x.size()) != state_->get_nx()) {
58 throw_pretty(
59 "Invalid argument: " << "x has wrong dimension (it should be " +
60 std::to_string(state_->get_nx()) + ")");
61 }
62 if (static_cast<std::size_t>(u.size()) != nu_) {
63 throw_pretty(
64 "Invalid argument: " << "u has wrong dimension (it should be " +
65 std::to_string(nu_) + ")");
66 }
67 return bp::call<void>(this->get_override("calcDiff").ptr(), data,
68 (Eigen::VectorXd)x, (Eigen::VectorXd)u);
69 }
70
71 std::shared_ptr<ActionDataAbstract> createData() {
72 enableMultithreading() = false;
73 if (boost::python::override createData = this->get_override("createData")) {
74 return bp::call<std::shared_ptr<IntegratedActionDataAbstract> >(
75 createData.ptr());
76 }
77 return IntegratedActionModelAbstract::createData();
78 }
79
80 std::shared_ptr<ActionDataAbstract> default_createData() {
81 return this->IntegratedActionModelAbstract::createData();
82 }
83 };
84
85 } // namespace python
86 } // namespace crocoddyl
87
88 #endif // BINDINGS_PYTHON_CROCODDYL_CORE_INTEGRATED_ACTION_BASE_HPP_
89