1 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
2 |
|
|
// BSD 3-Clause License |
3 |
|
|
// |
4 |
|
|
// Copyright (C) 2021-2023, University of Edinburgh, LAAS-CNRS, INRIA, |
5 |
|
|
// Heriot-Watt University |
6 |
|
|
// Copyright note valid unless otherwise stated in individual files. |
7 |
|
|
// All rights reserved. |
8 |
|
|
/////////////////////////////////////////////////////////////////////////////// |
9 |
|
|
|
10 |
|
|
#ifdef PINOCCHIO_WITH_HPP_FCL |
11 |
|
|
|
12 |
|
|
#include "crocoddyl/multibody/residuals/pair-collision.hpp" |
13 |
|
|
|
14 |
|
|
#include "python/crocoddyl/multibody/multibody.hpp" |
15 |
|
|
#include "python/crocoddyl/utils/copyable.hpp" |
16 |
|
|
|
17 |
|
|
namespace crocoddyl { |
18 |
|
|
namespace python { |
19 |
|
|
|
20 |
|
10 |
void exposeResidualPairCollision() { |
21 |
|
10 |
bp::register_ptr_to_python<boost::shared_ptr<ResidualModelPairCollision> >(); |
22 |
|
|
|
23 |
✓✗ |
10 |
bp::class_<ResidualModelPairCollision, bp::bases<ResidualModelAbstract> >( |
24 |
|
|
"ResidualModelPairCollision", |
25 |
✓✗ |
10 |
bp::init<boost::shared_ptr<StateMultibody>, std::size_t, |
26 |
|
|
boost::shared_ptr<pinocchio::GeometryModel>, |
27 |
|
|
pinocchio::PairIndex, pinocchio::JointIndex>( |
28 |
|
20 |
bp::args("self", "state", "nu", "geom_model", "pair_id", "joint_id"), |
29 |
|
|
"Initialize the pair collision residual model.\n\n" |
30 |
|
|
":param state: state of the multibody system\n" |
31 |
|
|
":param nu: dimension of control vector\n" |
32 |
|
|
":param geom_model: geometric model of the multibody system\n" |
33 |
|
|
":param pair_id: id of the pair of colliding objects\n" |
34 |
|
|
":param joint_id: used to calculate the Jacobian at the joint")) |
35 |
|
|
.def<void (ResidualModelPairCollision::*)( |
36 |
|
|
const boost::shared_ptr<ResidualDataAbstract>&, |
37 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&, |
38 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&)>( |
39 |
|
|
"calc", &ResidualModelPairCollision::calc, |
40 |
✓✗ |
20 |
bp::args("self", "data", "x", "u"), |
41 |
|
|
"Compute the pair collision residual.\n\n" |
42 |
|
|
":param data: residual data\n" |
43 |
|
|
":param x: state point (dim. state.nx)\n" |
44 |
✓✗ |
10 |
":param u: control input (dim. nu)") |
45 |
|
|
.def<void (ResidualModelPairCollision::*)( |
46 |
|
|
const boost::shared_ptr<ResidualDataAbstract>&, |
47 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&)>( |
48 |
✓✗ |
20 |
"calc", &ResidualModelAbstract::calc, bp::args("self", "data", "x")) |
49 |
|
|
.def<void (ResidualModelPairCollision::*)( |
50 |
|
|
const boost::shared_ptr<ResidualDataAbstract>&, |
51 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&, |
52 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&)>( |
53 |
|
|
"calcDiff", &ResidualModelPairCollision::calcDiff, |
54 |
✓✗ |
20 |
bp::args("self", "data", "x", "u"), |
55 |
|
|
"Compute the Jacobians of the pair collision residual.\n\n" |
56 |
|
|
"It assumes that calc has been run first.\n" |
57 |
|
|
":param data: action data\n" |
58 |
|
|
":param x: state point (dim. state.nx)\n" |
59 |
✓✗✓✗
|
20 |
":param u: control input (dim. nu)") |
60 |
|
|
.def<void (ResidualModelPairCollision::*)( |
61 |
|
|
const boost::shared_ptr<ResidualDataAbstract>&, |
62 |
|
|
const Eigen::Ref<const Eigen::VectorXd>&)>( |
63 |
|
|
"calcDiff", &ResidualModelAbstract::calcDiff, |
64 |
✓✗ |
20 |
bp::args("self", "data", "x")) |
65 |
|
|
.def("createData", &ResidualModelPairCollision::createData, |
66 |
|
|
bp::with_custodian_and_ward_postcall<0, 2>(), |
67 |
✓✗ |
20 |
bp::args("self", "data"), |
68 |
|
|
"Create the pair collision residual data.\n\n" |
69 |
|
|
":param data: shared data\n" |
70 |
✓✗✓✗
|
20 |
":return residual data.") |
71 |
✓✗ |
10 |
.def(CopyableVisitor<ResidualModelPairCollision>()); |
72 |
|
|
|
73 |
|
10 |
bp::register_ptr_to_python<boost::shared_ptr<ResidualDataPairCollision> >(); |
74 |
|
|
|
75 |
✓✗ |
10 |
bp::class_<ResidualDataPairCollision, bp::bases<ResidualDataAbstract> >( |
76 |
|
|
"ResidualDataPairCollision", "Data for pair collision residual.\n\n", |
77 |
✓✗ |
10 |
bp::init<ResidualModelPairCollision*, DataCollectorAbstract*>( |
78 |
✓✗ |
10 |
bp::args("self", "model", "data"), |
79 |
|
|
"Create pair collision residual data.\n\n" |
80 |
|
|
":param model: pair collision residual model\n" |
81 |
|
10 |
":param data: shared data")[bp::with_custodian_and_ward< |
82 |
✓✗ |
20 |
1, 2, bp::with_custodian_and_ward<1, 3> >()]) |
83 |
|
|
.add_property("pinocchio", |
84 |
✓✗ |
10 |
bp::make_getter(&ResidualDataPairCollision::pinocchio, |
85 |
|
10 |
bp::return_internal_reference<>()), |
86 |
✓✗ |
10 |
"pinocchio data") |
87 |
|
|
.add_property("geometry", |
88 |
✓✗ |
10 |
bp::make_getter(&ResidualDataPairCollision::geometry, |
89 |
|
10 |
bp::return_internal_reference<>()), |
90 |
✓✗ |
10 |
"pinocchio geometry data") |
91 |
|
|
.add_property("J", |
92 |
✓✗ |
10 |
bp::make_getter(&ResidualDataPairCollision::J, |
93 |
|
10 |
bp::return_internal_reference<>()), |
94 |
✓✗ |
10 |
"Jacobian of the collision joint") |
95 |
|
|
.add_property("d", |
96 |
✓✗ |
10 |
bp::make_getter(&ResidualDataPairCollision::d, |
97 |
|
10 |
bp::return_internal_reference<>()), |
98 |
✓✗ |
10 |
"vector from joint to collision point in world frame") |
99 |
✓✗ |
10 |
.def(CopyableVisitor<ResidualDataPairCollision>()); |
100 |
|
10 |
} |
101 |
|
|
|
102 |
|
|
} // namespace python |
103 |
|
|
} // namespace crocoddyl |
104 |
|
|
|
105 |
|
|
#endif // PINOCCHIO_WITH_HPP_FCL |