GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: bindings/python/crocoddyl/multibody/impulses/impulse-6d.cpp Lines: 34 36 94.4 %
Date: 2024-02-13 11:12:33 Branches: 25 50 50.0 %

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
#include "crocoddyl/multibody/impulses/impulse-6d.hpp"
11
12
#include "python/crocoddyl/multibody/multibody.hpp"
13
#include "python/crocoddyl/utils/copyable.hpp"
14
15
namespace crocoddyl {
16
namespace python {
17
18
10
void exposeImpulse6D() {
19
10
  bp::register_ptr_to_python<boost::shared_ptr<ImpulseModel6D> >();
20
21
10
  bp::class_<ImpulseModel6D, bp::bases<ImpulseModelAbstract> >(
22
      "ImpulseModel6D",
23
      "Rigid 6D impulse model.\n\n"
24
      "It defines a rigid 6D impulse models based on acceleration-based "
25
      "holonomic constraints.\n"
26
      "The calc and calcDiff functions compute the impulse Jacobian and drift "
27
      "(holonomic constraint) or\n"
28
      "the derivatives of the holonomic constraint, respectively.",
29
10
      bp::init<boost::shared_ptr<StateMultibody>, std::size_t,
30
               bp::optional<pinocchio::ReferenceFrame> >(
31
20
          bp::args("self", "state", "frame", "type"),
32
          "Initialize the impulse model.\n\n"
33
          ":param state: state of the multibody system\n"
34
          ":param type: type of impulse\n"
35
          ":param frame: reference frame id"))
36
20
      .def("calc", &ImpulseModel6D::calc, bp::args("self", "data", "x"),
37
           "Compute the 6D impulse Jacobian and drift.\n\n"
38
           "The rigid impulse model throught acceleration-base holonomic "
39
           "constraint\n"
40
           "of the impulse frame placement.\n"
41
           ":param data: impulse data\n"
42
10
           ":param x: state point (dim. state.nx)")
43
20
      .def("calcDiff", &ImpulseModel6D::calcDiff, bp::args("self", "data", "x"),
44
           "Compute the derivatives of the 6D impulse holonomic constraint.\n\n"
45
           "The rigid impulse model throught acceleration-base holonomic "
46
           "constraint\n"
47
           "of the impulse frame placement.\n"
48
           "It assumes that calc has been run first.\n"
49
           ":param data: cost data\n"
50
10
           ":param x: state point (dim. state.nx)")
51
      .def("updateForce", &ImpulseModel6D::updateForce,
52
20
           bp::args("self", "data", "force"),
53
           "Convert the force into a stack of spatial forces.\n\n"
54
           ":param data: cost data\n"
55
10
           ":param lambda: force vector (dimension 6)")
56
      .def("createData", &ImpulseModel6D::createData,
57
           bp::with_custodian_and_ward_postcall<0, 2>(),
58
20
           bp::args("self", "data"),
59
           "Create the 6D impulse data.\n\n"
60
           "Each impulse model has its own data that needs to be allocated. "
61
           "This function\n"
62
           "returns the allocated data for a predefined cost.\n"
63
           ":param data: Pinocchio data\n"
64
10
           ":return impulse data.")
65
10
      .def(CopyableVisitor<ImpulseModel6D>());
66
67
10
  bp::register_ptr_to_python<boost::shared_ptr<ImpulseData6D> >();
68
69
10
  bp::class_<ImpulseData6D, bp::bases<ImpulseDataAbstract> >(
70
      "ImpulseData6D", "Data for 6D impulse.\n\n",
71
10
      bp::init<ImpulseModel6D*, pinocchio::Data*>(
72
10
          bp::args("self", "model", "data"),
73
          "Create 6D impulse data.\n\n"
74
          ":param model: 6D impulse model\n"
75
10
          ":param data: Pinocchio data")[bp::with_custodian_and_ward<
76
20
          1, 2, bp::with_custodian_and_ward<1, 3> >()])
77
      .add_property("dv0_local_dq",
78
10
                    bp::make_getter(&ImpulseData6D::dv0_local_dq,
79
                                    bp::return_internal_reference<>()),
80
20
                    bp::make_setter(&ImpulseData6D::dv0_local_dq),
81
10
                    "Jacobian of the desired local contact velocity")
82
      .add_property("fJf",
83
10
                    bp::make_getter(&ImpulseData6D::fJf,
84
10
                                    bp::return_internal_reference<>()),
85
10
                    "local Jacobian of the impulse frame")
86
      .add_property("v_partial_dq",
87
10
                    bp::make_getter(&ImpulseData6D::v_partial_dq,
88
10
                                    bp::return_internal_reference<>()),
89
10
                    "Jacobian of the spatial body velocity")
90
      .add_property("v_partial_dv",
91
10
                    bp::make_getter(&ImpulseData6D::v_partial_dv,
92
10
                                    bp::return_internal_reference<>()),
93
10
                    "Jacobian of the spatial body velocity")
94
10
      .def(CopyableVisitor<ImpulseData6D>());
95
10
}
96
97
}  // namespace python
98
}  // namespace crocoddyl