Skip to content

Commit ab3ffbb

Browse files
AdrianZwclalancette
authored andcommitted
Port kdl_parser_py to ROS 2
1 parent 5820cee commit ab3ffbb

File tree

13 files changed

+207
-300464
lines changed

13 files changed

+207
-300464
lines changed

kdl_parser_py/CMakeLists.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2019 Open Source Robotics Foundation, Inc.
2+
# All rights reserved.
3+
#
4+
# Software License Agreement (BSD License 2.0)
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions
8+
# are met:
9+
#
10+
# * Redistributions of source code must retain the above copyright
11+
# notice, this list of conditions and the following disclaimer.
12+
# * Redistributions in binary form must reproduce the above
13+
# copyright notice, this list of conditions and the following
14+
# disclaimer in the documentation and/or other materials provided
15+
# with the distribution.
16+
# * Neither the name of the copyright holder nor the names of its
17+
# contributors may be used to endorse or promote products derived
18+
# from this software without specific prior written permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23+
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24+
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30+
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
# POSSIBILITY OF SUCH DAMAGE.
32+
33+
from kdl_parser_py import *

kdl_parser_py/kdl_parser_py/urdf.py

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
# Copyright 2019 Open Source Robotics Foundation, Inc.
2+
# All rights reserved.
3+
#
4+
# Software License Agreement (BSD License 2.0)
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions
8+
# are met:
9+
#
10+
# * Redistributions of source code must retain the above copyright
11+
# notice, this list of conditions and the following disclaimer.
12+
# * Redistributions in binary form must reproduce the above
13+
# copyright notice, this list of conditions and the following
14+
# disclaimer in the documentation and/or other materials provided
15+
# with the distribution.
16+
# * Neither the name of the copyright holder nor the names of its
17+
# contributors may be used to endorse or promote products derived
18+
# from this software without specific prior written permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23+
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24+
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30+
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
# POSSIBILITY OF SUCH DAMAGE.
32+
133
from __future__ import print_function
234

335
import urdf_parser_py.urdf as urdf
@@ -7,26 +39,18 @@
739
def treeFromFile(filename):
840
"""
941
Construct a PyKDL.Tree from an URDF file.
42+
1043
:param filename: URDF file path
1144
"""
12-
1345
with open(filename) as urdf_file:
1446
return treeFromUrdfModel(urdf.URDF.from_xml_string(urdf_file.read()))
1547

16-
def treeFromParam(param):
17-
"""
18-
Construct a PyKDL.Tree from an URDF in a ROS parameter.
19-
:param param: Parameter name, ``str``
20-
"""
21-
22-
return treeFromUrdfModel(urdf.URDF.from_parameter_server())
23-
2448
def treeFromString(xml):
2549
"""
2650
Construct a PyKDL.Tree from an URDF xml string.
51+
2752
:param xml: URDF xml string, ``str``
2853
"""
29-
3054
return treeFromUrdfModel(urdf.URDF.from_xml_string(xml))
3155

3256
def _toKdlPose(pose):
@@ -49,8 +73,7 @@ def _toKdlInertia(i):
4973
kdl.RotationalInertia(inertia.ixx, inertia.iyy, inertia.izz, inertia.ixy, inertia.ixz, inertia.iyz));
5074

5175
def _toKdlJoint(jnt):
52-
53-
fixed = lambda j,F: kdl.Joint(j.name, kdl.Joint.None)
76+
fixed = lambda j,F: kdl.Joint(j.name, kdl.Joint.JointType(8))
5477
rotational = lambda j,F: kdl.Joint(j.name, F.p, F.M * kdl.Vector(*j.axis), kdl.Joint.RotAxis)
5578
translational = lambda j,F: kdl.Joint(j.name, F.p, F.M * kdl.Vector(*j.axis), kdl.Joint.TransAxis)
5679

@@ -67,8 +90,6 @@ def _toKdlJoint(jnt):
6790
return type_map[jnt.type](jnt, _toKdlPose(jnt.origin))
6891

6992
def _add_children_to_tree(robot_model, root, tree):
70-
71-
7293
# constructs the optional inertia
7394
inert = kdl.RigidBodyInertia(0)
7495
if root.inertial:
@@ -108,7 +129,6 @@ def treeFromUrdfModel(robot_model, quiet=False):
108129
:param robot_model: URDF xml string, ``str``
109130
:param quiet: If true suppress messages to stdout, ``bool``
110131
"""
111-
112132
root = robot_model.link_map[robot_model.get_root()]
113133

114134
if root.inertial and not quiet:
@@ -122,5 +142,5 @@ def treeFromUrdfModel(robot_model, quiet=False):
122142
if not _add_children_to_tree(robot_model, robot_model.link_map[child], tree):
123143
ok = False
124144
break
125-
145+
126146
return (ok, tree)

kdl_parser_py/package.xml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<package>
1+
<package format="3">
22
<name>kdl_parser_py</name>
33
<version>2.6.2</version>
44
<description>
@@ -19,15 +19,17 @@
1919
<url type="repository">https://github.com/ros2/kdl_parser</url>
2020
<url type="bugtracker">https://github.com/ros2/kdl_parser/issues</url>
2121

22-
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
23-
<buildtool_depend>python-catkin-pkg</buildtool_depend>
22+
<depend>python_orocos_kdl_vendor</depend>
23+
<depend>urdf</depend>
24+
<depend>rostest</depend>
25+
<depend>urdfdom_py</depend>
2426

25-
<build_depend>python_orocos_kdl_vendor</build_depend>
26-
<build_depend>urdf</build_depend>
27-
<build_depend>rostest</build_depend>
28-
29-
<run_depend>python_orocos_kdl_vendor</run_depend>
30-
<run_depend>urdf</run_depend>
31-
<run_depend>urdfdom_py</run_depend>
27+
<test_depend>ament_copyright</test_depend>
28+
<test_depend>ament_flake8</test_depend>
29+
<test_depend>ament_pep257</test_depend>
30+
<test_depend>python3-pytest</test_depend>
3231

32+
<export>
33+
<build_type>ament_python</build_type>
34+
</export>
3335
</package>
File renamed without changes.

kdl_parser_py/setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[develop]
2+
script_dir=$base/lib/kdl_parser_py
3+
[install]
4+
install_scripts=$base/lib/kdl_parser_py

kdl_parser_py/setup.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1-
#!/usr/bin/env python
1+
from setuptools import setup
22

3-
from distutils.core import setup
4-
from catkin_pkg.python_setup import generate_distutils_setup
3+
package_name = 'kdl_parser_py'
54

6-
d = generate_distutils_setup(
7-
packages=['kdl_parser_py'],
8-
package_dir={'': ''}
5+
setup(
6+
name=package_name,
7+
version='2.6.2',
8+
packages=[package_name],
9+
data_files=[
10+
('share/ament_index/resource_index/packages',
11+
['resource/' + package_name]),
12+
('share/' + package_name, ['package.xml']),
13+
('share/' + package_name, ['test/test.urdf'])
14+
],
15+
install_requires=['setuptools'],
16+
zip_safe=True,
17+
maintainer='Chris Lalancette',
18+
maintainer_email='clalancette@osrfoundation.org"',
19+
description='The Kinematics and Dynamics Library (KDL)'
20+
'defines a tree structure to represent the kinematic and'
21+
'dynamic parameters of a robot mechanism. <tt>kdl_parser_py</tt>'
22+
'provides Python tools to construct a KDL tree from an XML robot representation in URDF.',
23+
license='BSD',
24+
tests_require=['pytest'],
25+
entry_points={
26+
'console_scripts': [
27+
],
28+
},
929
)
10-
11-
setup(**d)

0 commit comments

Comments
 (0)