From f8a9997ea6b9c771ca063559cbaadb51ff06d6b1 Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Thu, 29 Sep 2016 13:34:53 +0200 Subject: [PATCH] Add Device::clone --- include/hpp/manipulation/device.hh | 8 ++++++++ src/device.cc | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/hpp/manipulation/device.hh b/include/hpp/manipulation/device.hh index ac91cfd..1008087 100644 --- a/include/hpp/manipulation/device.hh +++ b/include/hpp/manipulation/device.hh @@ -68,6 +68,8 @@ namespace hpp { void setRobotRootPosition (const std::string& robotName, const Transform3f& positionWRTParentJoint); + virtual pinocchio::DevicePtr_t clone () const; + /// \name Collisions /// \{ @@ -95,6 +97,12 @@ namespace hpp { self_ = self; } + void initCopy (const DeviceWkPtr_t& self, const Device& other) + { + Parent_t::initCopy (self, other); + self_ = self; + } + private: DeviceWkPtr_t self_; diff --git a/src/device.cc b/src/device.cc index 75e9c72..19a83f1 100644 --- a/src/device.cc +++ b/src/device.cc @@ -32,6 +32,14 @@ namespace hpp { using se3::Frame; using se3::FrameIndex; + pinocchio::DevicePtr_t Device::clone () const + { + Device* ptr = new Device(*this); + DevicePtr_t shPtr (ptr); + ptr->initCopy (shPtr, *this); + return shPtr; + } + void Device::setRobotRootPosition (const std::string& rn, const Transform3f& t) { @@ -99,6 +107,5 @@ namespace hpp { Containers_t::print <GripperPtr_t> (os); return os; } - } // namespace manipulation } // namespace hpp -- GitLab