GCC Code Coverage Report


Directory: ./
File: include/hpp/manipulation/device.hh
Date: 2025-03-07 11:10:46
Exec Total Coverage
Lines: 11 16 68.8%
Branches: 3 8 37.5%

Line Branch Exec Source
1 ///
2 /// Copyright (c) 2014 CNRS
3 /// Authors: Florent Lamiraux, Joseph Mirabel
4 ///
5 ///
6
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are
9 // met:
10 //
11 // 1. Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //
14 // 2. Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 // DAMAGE.
30
31 #ifndef HPP_MANIPULATION_DEVICE_HH
32 #define HPP_MANIPULATION_DEVICE_HH
33
34 #include <hpp/core/container.hh>
35 #include <hpp/manipulation/config.hh>
36 #include <hpp/manipulation/fwd.hh>
37 #include <hpp/pinocchio/humanoid-robot.hh>
38
39 namespace hpp {
40 namespace manipulation {
41 /// Device with handles.
42 ///
43 /// As a deriving class of hpp::pinocchio::HumanoidRobot,
44 /// it is compatible with hpp::pinocchio::urdf::loadHumanoidRobot
45 ///
46 /// This class also contains pinocchio::Gripper, Handle and \ref
47 /// JointAndShapes_t
48 class HPP_MANIPULATION_DLLAPI Device : public pinocchio::HumanoidRobot {
49 public:
50 typedef pinocchio::HumanoidRobot Parent_t;
51
52 /// Constructor
53 /// \param name of the new instance,
54 2 static DevicePtr_t create(const std::string& name) {
55
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 Device* ptr = new Device(name);
56 2 DevicePtr_t shPtr(ptr);
57
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 ptr->init(shPtr);
58 2 return shPtr;
59 }
60
61 DevicePtr_t self() const { return self_.lock(); }
62
63 /// Print object in a stream
64 virtual std::ostream& print(std::ostream& os) const;
65
66 void setRobotRootPosition(const std::string& robotName,
67 const Transform3s& positionWRTParentJoint);
68
69 virtual pinocchio::DevicePtr_t clone() const;
70
71 std::vector<std::string> robotNames() const;
72
73 FrameIndices_t robotFrames(const std::string& robotName) const;
74
75 void removeJoints(const std::vector<std::string>& jointNames,
76 Configuration_t referenceConfig);
77
78 core::Container<HandlePtr_t> handles;
79 core::Container<GripperPtr_t> grippers;
80 core::Container<JointAndShapes_t> jointAndShapes;
81
82 protected:
83 /// Constructor
84 /// \param name of the new instance,
85 /// \param robot Robots that manipulate objects,
86 /// \param objects Set of objects manipulated by the robot.
87 2 Device(const std::string& name) : Parent_t(name) {}
88
89 2 void init(const DeviceWkPtr_t& self) {
90
1/2
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 Parent_t::init(self);
91 2 self_ = self;
92 2 }
93
94 void initCopy(const DeviceWkPtr_t& self, const Device& other) {
95 Parent_t::initCopy(self, other);
96 self_ = self;
97 }
98
99 /// For serialization only
100 Device() {}
101
102 private:
103 DeviceWkPtr_t self_;
104
105 HPP_SERIALIZABLE();
106 }; // class Device
107 } // namespace manipulation
108 } // namespace hpp
109
110 1 BOOST_CLASS_EXPORT_KEY(hpp::manipulation::Device)
111
112 #endif // HPP_MANIPULATION_DEVICE_HH
113