Skip to content

Commit 800e73e

Browse files
GiulioRomualdiStéphane Caron
authored andcommitted
Move load_robot_description method in _package_dirs
1 parent d99713b commit 800e73e

File tree

3 files changed

+41
-22
lines changed

3 files changed

+41
-22
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright 2022 Giulio Romualdi
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
import os.path
19+
from typing import List
20+
21+
def get_package_dirs(module) -> List[str]:
22+
"""
23+
Get package directories for a given module.
24+
25+
Args:
26+
module: Robot description module.
27+
28+
Returns:
29+
Package directories.
30+
"""
31+
return [
32+
module.PACKAGE_PATH,
33+
module.REPOSITORY_PATH,
34+
os.path.dirname(module.PACKAGE_PATH),
35+
os.path.dirname(module.REPOSITORY_PATH),
36+
os.path.dirname(module.URDF_PATH), # e.g. laikago_description
37+
]

robot_descriptions/loaders/idyntree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from importlib import import_module # type: ignore
2323
from typing import List, Optional
24-
from .pinocchio import get_package_dirs
24+
from .._package_dirs import get_package_dirs
2525

2626
import idyntree.swig as idyn
2727

robot_descriptions/loaders/pinocchio.py

100644100755
Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
Load a robot description in Pinocchio.
2020
"""
2121

22-
import os.path
2322
from importlib import import_module # type: ignore
24-
from typing import List, Optional, Union
23+
from typing import Optional, Union
24+
from .._package_dirs import get_package_dirs
25+
2526

2627
import pinocchio as pin
2728

@@ -40,25 +41,6 @@
4041
]
4142

4243

43-
def get_package_dirs(module) -> List[str]:
44-
"""
45-
Get package directories for a given module.
46-
47-
Args:
48-
module: Robot description module.
49-
50-
Returns:
51-
Package directories.
52-
"""
53-
return [
54-
module.PACKAGE_PATH,
55-
module.REPOSITORY_PATH,
56-
os.path.dirname(module.PACKAGE_PATH),
57-
os.path.dirname(module.REPOSITORY_PATH),
58-
os.path.dirname(module.URDF_PATH), # e.g. laikago_description
59-
]
60-
61-
6244
def load_robot_description(
6345
description_name: str,
6446
root_joint: Optional[PinocchioJoint] = None,

0 commit comments

Comments
 (0)