Line |
Branch |
Exec |
Source |
1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2019-2022, LAAS-CNRS, University of Edinburgh |
5 |
|
|
// Copyright note valid unless otherwise stated in individual files. |
6 |
|
|
// All rights reserved. |
7 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
8 |
|
|
|
9 |
|
|
#ifndef BINDINGS_PYTHON_CROCODDYL_CORE_ACTIVATION_BASE_HPP_ |
10 |
|
|
#define BINDINGS_PYTHON_CROCODDYL_CORE_ACTIVATION_BASE_HPP_ |
11 |
|
|
|
12 |
|
|
#include "crocoddyl/core/activation-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 ActivationModelAbstract_wrap |
20 |
|
|
: public ActivationModelAbstract, |
21 |
|
|
public bp::wrapper<ActivationModelAbstract> { |
22 |
|
|
public: |
23 |
|
✗ |
explicit ActivationModelAbstract_wrap(const std::size_t nr) |
24 |
|
✗ |
: ActivationModelAbstract(nr), bp::wrapper<ActivationModelAbstract>() {} |
25 |
|
|
|
26 |
|
✗ |
void calc(const boost::shared_ptr<ActivationDataAbstract>& data, |
27 |
|
|
const Eigen::Ref<const Eigen::VectorXd>& r) { |
28 |
|
✗ |
if (static_cast<std::size_t>(r.size()) != nr_) { |
29 |
|
✗ |
throw_pretty( |
30 |
|
|
"Invalid argument: " << "r has wrong dimension (it should be " + |
31 |
|
|
std::to_string(nr_) + ")"); |
32 |
|
|
} |
33 |
|
✗ |
return bp::call<void>(this->get_override("calc").ptr(), data, |
34 |
|
✗ |
(Eigen::VectorXd)r); |
35 |
|
|
} |
36 |
|
|
|
37 |
|
✗ |
void calcDiff(const boost::shared_ptr<ActivationDataAbstract>& data, |
38 |
|
|
const Eigen::Ref<const Eigen::VectorXd>& r) { |
39 |
|
✗ |
if (static_cast<std::size_t>(r.size()) != nr_) { |
40 |
|
✗ |
throw_pretty( |
41 |
|
|
"Invalid argument: " << "r has wrong dimension (it should be " + |
42 |
|
|
std::to_string(nr_) + ")"); |
43 |
|
|
} |
44 |
|
✗ |
return bp::call<void>(this->get_override("calcDiff").ptr(), data, |
45 |
|
✗ |
(Eigen::VectorXd)r); |
46 |
|
|
} |
47 |
|
|
|
48 |
|
✗ |
boost::shared_ptr<ActivationDataAbstract> createData() { |
49 |
|
✗ |
enableMultithreading() = false; |
50 |
|
✗ |
if (boost::python::override createData = this->get_override("createData")) { |
51 |
|
|
return bp::call<boost::shared_ptr<ActivationDataAbstract> >( |
52 |
|
✗ |
createData.ptr()); |
53 |
|
|
} |
54 |
|
✗ |
return ActivationModelAbstract::createData(); |
55 |
|
|
} |
56 |
|
|
|
57 |
|
✗ |
boost::shared_ptr<ActivationDataAbstract> default_createData() { |
58 |
|
✗ |
return this->ActivationModelAbstract::createData(); |
59 |
|
|
} |
60 |
|
|
}; |
61 |
|
|
|
62 |
|
|
} // namespace python |
63 |
|
|
} // namespace crocoddyl |
64 |
|
|
|
65 |
|
|
#endif // BINDINGS_PYTHON_CROCODDYL_CORE_ACTIVATION_BASE_HPP_ |
66 |
|
|
|