GCC Code Coverage Report


Directory: ./
File: unittest/factory/contact.hpp
Date: 2025-01-16 08:47:40
Exec Total Coverage
Lines: 6 6 100.0%
Branches: 4 6 66.7%

Line Branch Exec Source
1 ///////////////////////////////////////////////////////////////////////////////
2 // BSD 3-Clause License
3 //
4 // Copyright (C) 2019-2023, University of Edinburgh, Heriot-Watt University
5 // Copyright note valid unless otherwise stated in individual files.
6 // All rights reserved.
7 ///////////////////////////////////////////////////////////////////////////////
8
9 #ifndef CROCODDYL_CONTACTS_FACTORY_HPP_
10 #define CROCODDYL_CONTACTS_FACTORY_HPP_
11
12 #include <iostream>
13 #include <limits>
14
15 #include "crocoddyl/multibody/contact-base.hpp"
16 #include "crocoddyl/multibody/contacts/multiple-contacts.hpp"
17 #include "crocoddyl/multibody/numdiff/contact.hpp"
18 #include "state.hpp"
19
20 namespace crocoddyl {
21 namespace unittest {
22
23 struct ContactModelTypes {
24 enum Type {
25 ContactModel1D_LOCAL,
26 ContactModel1D_WORLD,
27 ContactModel1D_LWA,
28 ContactModel2D,
29 ContactModel3D_LOCAL,
30 ContactModel3D_WORLD,
31 ContactModel3D_LWA,
32 ContactModel6D_LOCAL,
33 ContactModel6D_WORLD,
34 ContactModel6D_LWA,
35 NbContactModelTypes
36 };
37 23 static std::vector<Type> init_all() {
38 23 std::vector<Type> v;
39
1/2
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 v.reserve(NbContactModelTypes);
40
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 23 times.
253 for (int i = 0; i < NbContactModelTypes; ++i) {
41
1/2
✓ Branch 1 taken 230 times.
✗ Branch 2 not taken.
230 v.push_back((Type)i);
42 }
43 23 return v;
44 }
45 static const std::vector<Type> all;
46 };
47
48 std::ostream& operator<<(std::ostream& os, const ContactModelTypes::Type& type);
49
50 class ContactModelFactory {
51 public:
52 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
53
54 explicit ContactModelFactory();
55 ~ContactModelFactory();
56
57 boost::shared_ptr<crocoddyl::ContactModelAbstract> create(
58 ContactModelTypes::Type contact_type,
59 PinocchioModelTypes::Type model_type, Eigen::Vector2d gains,
60 const std::string frame_name = std::string(""),
61 const std::size_t nu = std::numeric_limits<std::size_t>::max()) const;
62 };
63
64 boost::shared_ptr<crocoddyl::ContactModelAbstract> create_random_contact();
65
66 } // namespace unittest
67 } // namespace crocoddyl
68
69 #endif // CROCODDYL_CONTACTS_FACTORY_HPP_
70