GCC Code Coverage Report


Directory: ./
File: bindings/python/crocoddyl/multibody/contact-base.hpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 4 22 18.2%
Branches: 1 52 1.9%

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_CONTACT_BASE_HPP_
11 #define BINDINGS_PYTHON_CROCODDYL_MULTIBODY_CONTACT_BASE_HPP_
12
13 #include "crocoddyl/core/utils/exception.hpp"
14 #include "crocoddyl/multibody/contact-base.hpp"
15 #include "python/crocoddyl/multibody/multibody.hpp"
16
17 namespace crocoddyl {
18 namespace python {
19
20 class ContactModelAbstract_wrap : public ContactModelAbstract,
21 public bp::wrapper<ContactModelAbstract> {
22 public:
23 1 ContactModelAbstract_wrap(boost::shared_ptr<StateMultibody> state,
24 const pinocchio::ReferenceFrame type,
25 std::size_t nc, std::size_t nu)
26 1 : ContactModelAbstract(state, type, nc, nu) {}
27 9 ContactModelAbstract_wrap(boost::shared_ptr<StateMultibody> state,
28 const pinocchio::ReferenceFrame type,
29 std::size_t nc)
30
1/2
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 : ContactModelAbstract(state, type, nc) {}
31
32 void calc(const boost::shared_ptr<ContactDataAbstract>& data,
33 const Eigen::Ref<const Eigen::VectorXd>& x) {
34 assert_pretty(static_cast<std::size_t>(x.size()) == state_->get_nx(),
35 "x has wrong dimension");
36 return bp::call<void>(this->get_override("calc").ptr(), data,
37 (Eigen::VectorXd)x);
38 }
39
40 void calcDiff(const boost::shared_ptr<ContactDataAbstract>& data,
41 const Eigen::Ref<const Eigen::VectorXd>& x) {
42 assert_pretty(static_cast<std::size_t>(x.size()) == state_->get_nx(),
43 "x has wrong dimension");
44 return bp::call<void>(this->get_override("calcDiff").ptr(), data,
45 (Eigen::VectorXd)x);
46 }
47
48 void updateForce(const boost::shared_ptr<ContactDataAbstract>& data,
49 const Eigen::VectorXd& force) {
50 assert_pretty(static_cast<std::size_t>(force.size()) == nc_,
51 "force has wrong dimension");
52 return bp::call<void>(this->get_override("updateForce").ptr(), data, force);
53 }
54
55 boost::shared_ptr<ContactDataAbstract> createData(
56 pinocchio::DataTpl<Scalar>* const data) {
57 enableMultithreading() = false;
58 if (boost::python::override createData = this->get_override("createData")) {
59 return bp::call<boost::shared_ptr<ContactDataAbstract> >(
60 createData.ptr(), boost::ref(data));
61 }
62 return ContactModelAbstract::createData(data);
63 }
64
65 boost::shared_ptr<ContactDataAbstract> default_createData(
66 pinocchio::DataTpl<Scalar>* const data) {
67 return this->ContactModelAbstract::createData(data);
68 }
69 };
70
71 } // namespace python
72 } // namespace crocoddyl
73
74 #endif // BINDINGS_PYTHON_CROCODDYL_MULTIBODY_CONTACT_BASE_HPP_
75