GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/rbprm-device.cc Lines: 28 43 65.1 %
Date: 2024-02-02 12:21:48 Branches: 14 50 28.0 %

Line Branch Exec Source
1
// Copyright (c) 2014, LAAS-CNRS
2
// Authors: Steve Tonneau (steve.tonneau@laas.fr)
3
//
4
// This file is part of hpp-rbprm.
5
// hpp-rbprm is free software: you can redistribute it
6
// and/or modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation, either version
8
// 3 of the License, or (at your option) any later version.
9
//
10
// hpp-rbprm is distributed in the hope that it will be
11
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
// General Lesser Public License for more details.  You should have
14
// received a copy of the GNU Lesser General Public License along with
15
// hpp-rbprm. If not, see <http://www.gnu.org/licenses/>.
16
17
#include <hpp/rbprm/rbprm-device.hh>
18
19
namespace hpp {
20
namespace pinocchio {
21
22
RbPrmDevicePtr_t RbPrmDevice::create(const std::string& name,
23
                                     DevicePtr_t& robotRom) {
24
  hpp::pinocchio::T_Rom roms;
25
  roms.insert(std::make_pair(robotRom->name(), robotRom));
26
  RbPrmDevice* rbprmDevice = new RbPrmDevice(name, roms);
27
  RbPrmDevicePtr_t res(rbprmDevice);
28
  res->init(res);
29
  return res;
30
}
31
32
15
RbPrmDevicePtr_t RbPrmDevice::create(const std::string& name,
33
                                     const hpp::pinocchio::T_Rom& robotRoms) {
34
15
  RbPrmDevice* rbprmDevice = new RbPrmDevice(name, robotRoms);
35
15
  RbPrmDevicePtr_t res(rbprmDevice);
36
15
  res->init(res);
37
15
  return res;
38
}
39
40
RbPrmDevice::~RbPrmDevice() {
41
  // NOTHING
42
}
43
44
// ========================================================================
45
46
15
void RbPrmDevice::init(const RbPrmDeviceWkPtr_t& weakPtr) {
47
15
  Device::init(weakPtr);
48
15
  weakPtr_ = weakPtr;
49
15
}
50
51
bool RbPrmDevice::currentConfiguration(ConfigurationIn_t configuration) {
52
  for (hpp::pinocchio::T_Rom::const_iterator cit = robotRoms_.begin();
53
       cit != robotRoms_.end(); ++cit) {
54
    cit->second->currentConfiguration(configuration);
55
  }
56
  return Device::currentConfiguration(configuration);
57
}
58
59
13
void RbPrmDevice::setDimensionExtraConfigSpace(const size_type& dimension) {
60
13
  Device::setDimensionExtraConfigSpace(dimension);  // call inherited method
61
  // call method for each robotRoms :
62
43
  for (hpp::pinocchio::T_Rom::const_iterator cit = robotRoms_.begin();
63
73
       cit != robotRoms_.end(); ++cit) {
64
30
    cit->second->setDimensionExtraConfigSpace(dimension);
65
  }
66
13
}
67
68
43479
vector3_t RbPrmDevice::getEffectorReference(std::string romName) {
69
  std::map<std::string, vector3_t>::iterator it =
70
43479
      effectorsReferences_.find(romName);
71
43479
  if (it == effectorsReferences_.end())
72
    return vector3_t();
73
  else
74
43479
    return it->second;
75
}
76
77
36
void RbPrmDevice::setEffectorReference(std::string romName, vector3_t ref) {
78
  std::map<std::string, vector3_t>::iterator it =
79
36
      effectorsReferences_.find(romName);
80
36
  if (it == effectorsReferences_.end())
81

36
    effectorsReferences_.insert(std::make_pair(romName, ref));
82
  else
83
    it->second = ref;
84
36
}
85
86
15
RbPrmDevice::RbPrmDevice(const std::string& name,
87
15
                         const hpp::pinocchio::T_Rom& robotRoms)
88
15
    : Device(name), robotRoms_(robotRoms), effectorsReferences_(), weakPtr_() {
89
  // NOTHING
90
15
}
91
}  // namespace pinocchio
92
}  // namespace hpp