GCC Code Coverage Report


Directory: ./
File: src/gripper.cc
Date: 2025-05-04 12:09:19
Exec Total Coverage
Lines: 0 20 0.0%
Branches: 0 26 0.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2016 CNRS
3 // Authors: Joseph Mirabel from Florent Lamiraux
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 #include <hpp/pinocchio/device.hh>
32 #include <hpp/pinocchio/gripper.hh>
33 #include <hpp/pinocchio/joint.hh>
34 #include <pinocchio/multibody/model.hpp>
35 #include <pinocchio/spatial/se3.hpp>
36
37 namespace hpp {
38 namespace pinocchio {
39 Gripper::Gripper(const std::string& name, const DeviceWkPtr_t& device)
40 : name_(name), device_(device), clearance_(0) {
41 DevicePtr_t d = this->device();
42 fid_ = d->model().getFrameId(name);
43 hppDout(info, "Creating gripper " << name << " with frame id " << fid_);
44 joint_ = Joint::create(d, d->model().frames[fid_].parent);
45 }
46
47 const Transform3s& Gripper::objectPositionInJoint() const {
48 // Check that the rank of the gripper frame has not been modified after
49 // appending other models
50 const Model& model(this->device()->model());
51 if (model.frames[fid_].name != name_) fid_ = model.getFrameId(name_);
52 return model.frames[fid_].placement;
53 }
54
55 GripperPtr_t Gripper::clone() const { return Gripper::create(name_, device_); }
56
57 std::ostream& Gripper::print(std::ostream& os) const {
58 os << "name :" << name() << std::endl;
59 os << "Position in joint :" << objectPositionInJoint();
60 os << "Joint :" << (joint() ? joint()->name() : "universe") << std::endl;
61 os << std::endl;
62 return os;
63 }
64
65 DevicePtr_t Gripper::device() const {
66 DevicePtr_t d = device_.lock();
67 assert(d);
68 return d;
69 }
70 } // namespace pinocchio
71 } // namespace hpp
72