Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
pinocchio
Commits
92031d0d
Commit
92031d0d
authored
Sep 30, 2016
by
jcarpent
Browse files
[Python] Add copyable method to create a raw copy of Spatial classes
parent
6228f196
Changes
7
Hide whitespace changes
Inline
Side-by-side
bindings/python/CMakeLists.txt
View file @
92031d0d
...
...
@@ -63,6 +63,7 @@ SET(${PYWRAP}_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/${PROJECT_NA
SET
(
${
PROJECT_NAME
}
_PYTHON_HEADERS
utils/eigen_container.hpp
utils/handler.hpp
utils/copyable.hpp
python.hpp
spatial/se3.hpp
spatial/force.hpp
...
...
bindings/python/multibody/frame.hpp
View file @
92031d0d
...
...
@@ -26,6 +26,7 @@
#include
"pinocchio/multibody/frame.hpp"
#include
"pinocchio/multibody/model.hpp"
#include
"pinocchio/container/aligned-vector.hpp"
#include
"pinocchio/bindings/python/utils/copyable.hpp"
namespace
se3
{
...
...
@@ -81,8 +82,9 @@ namespace se3
"A Plucker coordinate frame related to a parent joint inside a kinematic tree.
\n\n
"
,
bp
::
no_init
)
.
def
(
FramePythonVisitor
())
;
.
def
(
FramePythonVisitor
())
.
def
(
CopyableVisitor
<
Frame
>
())
;
bp
::
class_
<
std
::
vector
<
Frame
>
>
(
"StdVec_Frame"
)
.
def
(
bp
::
vector_indexing_suite
<
container
::
aligned_vector
<
Frame
>
>
());
...
...
bindings/python/spatial/force.hpp
View file @
92031d0d
...
...
@@ -24,6 +24,7 @@
#include
<eigenpy/memory.hpp>
#include
"pinocchio/spatial/force.hpp"
#include
"pinocchio/bindings/python/utils/copyable.hpp"
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
se3
::
Force
)
...
...
@@ -98,6 +99,7 @@ namespace se3
"Supported operations ..."
,
bp
::
init
<>
())
.
def
(
ForcePythonVisitor
<
Force
>
())
.
def
(
CopyableVisitor
<
Force
>
())
;
}
...
...
bindings/python/spatial/inertia.hpp
View file @
92031d0d
...
...
@@ -24,6 +24,7 @@
#include
<eigenpy/memory.hpp>
#include
"pinocchio/spatial/inertia.hpp"
#include
"pinocchio/bindings/python/utils/copyable.hpp"
namespace
se3
{
...
...
@@ -124,6 +125,7 @@ namespace se3
"Supported operations ..."
,
bp
::
init
<>
())
.
def
(
InertiaPythonVisitor
<
Inertia
>
())
.
def
(
CopyableVisitor
<
Inertia
>
())
;
}
...
...
bindings/python/spatial/motion.hpp
View file @
92031d0d
...
...
@@ -25,6 +25,7 @@
#include
"pinocchio/spatial/motion.hpp"
#include
"pinocchio/spatial/force.hpp"
#include
"pinocchio/bindings/python/utils/copyable.hpp"
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
se3
::
Motion
)
...
...
@@ -106,6 +107,7 @@ namespace se3
"Supported operations ..."
,
bp
::
init
<>
())
.
def
(
MotionPythonVisitor
<
Motion
>
())
.
def
(
CopyableVisitor
<
Motion
>
())
;
}
...
...
bindings/python/spatial/se3.hpp
View file @
92031d0d
...
...
@@ -24,6 +24,7 @@
#include
<eigenpy/memory.hpp>
#include
"pinocchio/spatial/se3.hpp"
#include
"pinocchio/bindings/python/utils/copyable.hpp"
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
se3
::
SE3
)
...
...
@@ -110,6 +111,7 @@ namespace se3
"Supported operations ..."
,
bp
::
init
<>
())
.
def
(
SE3PythonVisitor
<
SE3
>
())
.
def
(
CopyableVisitor
<
SE3
>
())
;
}
...
...
bindings/python/utils/copyable.hpp
0 → 100644
View file @
92031d0d
//
// Copyright (c) 2016 CNRS
//
// This file is part of Pinocchio
// Pinocchio is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// Pinocchio is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// Pinocchio If not, see
// <http://www.gnu.org/licenses/>.
#ifndef __se3_python_utils_copyable_hpp__
#define __se3_python_utils_copyable_hpp__
#include
<boost/python.hpp>
namespace
se3
{
namespace
python
{
namespace
bp
=
boost
::
python
;
///
/// \brief Add the Python method copy to allow a copy of this by calling the copy constructor.
///
template
<
class
C
>
struct
CopyableVisitor
:
public
bp
::
def_visitor
<
CopyableVisitor
<
C
>
>
{
template
<
class
PyClass
>
void
visit
(
PyClass
&
cl
)
const
{
cl
.
def
(
"copy"
,
&
copy
,
"Returns a copy of *this."
);
}
private:
static
C
copy
(
const
C
&
self
)
{
return
C
(
self
);
}
};
}
// namespace python
}
// namespace se3
#endif // ifndef __se3_python_utils_copyable_hpp__
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment