Line |
Branch |
Exec |
Source |
1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2019-2023, LAAS-CNRS, University of Edinburgh, |
5 |
|
|
// Heriot-Watt University |
6 |
|
|
// Copyright note valid unless otherwise stated in individual files. |
7 |
|
|
// All rights reserved. |
8 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
9 |
|
|
|
10 |
|
|
#ifndef BINDINGS_PYTHON_CROCODDYL_MULTIBODY_IMPULSE_BASE_HPP_ |
11 |
|
|
#define BINDINGS_PYTHON_CROCODDYL_MULTIBODY_IMPULSE_BASE_HPP_ |
12 |
|
|
|
13 |
|
|
#include "crocoddyl/core/utils/exception.hpp" |
14 |
|
|
#include "crocoddyl/multibody/impulse-base.hpp" |
15 |
|
|
#include "python/crocoddyl/multibody/multibody.hpp" |
16 |
|
|
|
17 |
|
|
namespace crocoddyl { |
18 |
|
|
namespace python { |
19 |
|
|
|
20 |
|
|
class ImpulseModelAbstract_wrap : public ImpulseModelAbstract, |
21 |
|
|
public bp::wrapper<ImpulseModelAbstract> { |
22 |
|
|
public: |
23 |
|
6 |
ImpulseModelAbstract_wrap(std::shared_ptr<StateMultibody> state, |
24 |
|
|
const pinocchio::ReferenceFrame type, |
25 |
|
|
std::size_t nc) |
26 |
|
6 |
: ImpulseModelAbstract(state, type, nc) {} |
27 |
|
|
|
28 |
|
✗ |
ImpulseModelAbstract_wrap(std::shared_ptr<StateMultibody> state, |
29 |
|
|
std::size_t nc) |
30 |
|
✗ |
: ImpulseModelAbstract(state, pinocchio::ReferenceFrame::LOCAL, nc) { |
31 |
|
|
std::cerr << "Deprecated: Use constructor that passes the type of contact, " |
32 |
|
✗ |
"this assumes is pinocchio::LOCAL." |
33 |
|
✗ |
<< std::endl; |
34 |
|
|
} |
35 |
|
|
|
36 |
|
✗ |
void calc(const std::shared_ptr<ImpulseDataAbstract>& data, |
37 |
|
|
const Eigen::Ref<const Eigen::VectorXd>& x) { |
38 |
|
✗ |
assert_pretty(static_cast<std::size_t>(x.size()) == state_->get_nx(), |
39 |
|
|
"x has wrong dimension"); |
40 |
|
✗ |
return bp::call<void>(this->get_override("calc").ptr(), data, |
41 |
|
✗ |
(Eigen::VectorXd)x); |
42 |
|
|
} |
43 |
|
|
|
44 |
|
✗ |
void calcDiff(const std::shared_ptr<ImpulseDataAbstract>& data, |
45 |
|
|
const Eigen::Ref<const Eigen::VectorXd>& x) { |
46 |
|
✗ |
assert_pretty(static_cast<std::size_t>(x.size()) == state_->get_nx(), |
47 |
|
|
"x has wrong dimension"); |
48 |
|
✗ |
return bp::call<void>(this->get_override("calcDiff").ptr(), data, |
49 |
|
✗ |
(Eigen::VectorXd)x); |
50 |
|
|
} |
51 |
|
|
|
52 |
|
✗ |
void updateForce(const std::shared_ptr<ImpulseDataAbstract>& data, |
53 |
|
|
const Eigen::VectorXd& force) { |
54 |
|
✗ |
assert_pretty(static_cast<std::size_t>(force.size()) == nc_, |
55 |
|
|
"force has wrong dimension"); |
56 |
|
✗ |
return bp::call<void>(this->get_override("updateForce").ptr(), data, force); |
57 |
|
|
} |
58 |
|
|
|
59 |
|
✗ |
std::shared_ptr<ImpulseDataAbstract> createData( |
60 |
|
|
pinocchio::DataTpl<Scalar>* const data) { |
61 |
|
✗ |
enableMultithreading() = false; |
62 |
|
✗ |
if (boost::python::override createData = this->get_override("createData")) { |
63 |
|
|
return bp::call<std::shared_ptr<ImpulseDataAbstract> >(createData.ptr(), |
64 |
|
✗ |
boost::ref(data)); |
65 |
|
|
} |
66 |
|
✗ |
return ImpulseModelAbstract::createData(data); |
67 |
|
|
} |
68 |
|
|
|
69 |
|
✗ |
std::shared_ptr<ImpulseDataAbstract> default_createData( |
70 |
|
|
pinocchio::DataTpl<Scalar>* const data) { |
71 |
|
✗ |
return this->ImpulseModelAbstract::createData(data); |
72 |
|
|
} |
73 |
|
|
}; |
74 |
|
|
|
75 |
|
|
} // namespace python |
76 |
|
|
} // namespace crocoddyl |
77 |
|
|
|
78 |
|
|
#endif // BINDINGS_PYTHON_CROCODDYL_MULTIBODY_IMPULSE_BASE_HPP_ |
79 |
|
|
|