Skip to content

Commit ba854fe

Browse files
committed
Organize imports, Fix Lint, Fix Init files
1 parent 60e8b55 commit ba854fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+411
-382
lines changed

src/compas_fab/backends/__init__.py

Lines changed: 78 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,24 @@
107107
import compas
108108

109109
# Base imports
110-
from .exceptions import *
110+
from .exceptions import (
111+
BackendError,
112+
BackendFeatureNotSupportedError,
113+
BackendTargetNotSupportedError,
114+
TargetModeMismatchError,
115+
PlanningGroupNotExistsError,
116+
InverseKinematicsError,
117+
KinematicsError,
118+
CollisionCheckError,
119+
MotionPlanningError,
120+
MPStartStateInCollisionError,
121+
MPTargetInCollisionError,
122+
MPInterpolationInCollisionError,
123+
MPSearchTimeOutError,
124+
MPNoIKSolutionError,
125+
MPNoPlanFoundError,
126+
MPMaxJumpError,
127+
)
111128

112129
from .tasks import (
113130
FutureResult,
@@ -123,19 +140,17 @@
123140
MoveItPlanner,
124141
)
125142

126-
# Analytic IK
143+
# Kinematics imports
127144
from .kinematics import (
145+
# Kinematics - Analytic IK
128146
AnalyticalInverseKinematics,
129147
AnalyticalPlanCartesianMotion,
130148
AnalyticalPyBulletPlanner,
131149
AnalyticalKinematicsPlanner,
132150
OffsetWristKinematics,
133151
SphericalWristKinematics,
134152
CartesianMotionError,
135-
)
136-
137-
# Robot-specific analytic IK
138-
from .kinematics import (
153+
# Kinematics - Robot-specific analytic IK
139154
UR3Kinematics,
140155
UR3eKinematics,
141156
UR5Kinematics,
@@ -146,8 +161,9 @@
146161
ABB_IRB4600_40_255Kinematics,
147162
)
148163

164+
# NOTE: IPY guard because PyBullet do not work in IronPython
165+
# PyBullet imports
149166
if not compas.IPY:
150-
# PyBullet do not work in IronPython
151167
from .pybullet import (
152168
PyBulletClient,
153169
PyBulletError,
@@ -156,45 +172,58 @@
156172
PlanningGroupNotSupported,
157173
)
158174

159-
# __all__ = [
160-
# # Base
161-
# "BackendError",
162-
# "BackendFeatureNotSupportedError",
163-
# "InverseKinematicsError",
164-
# "KinematicsError",
165-
# "CollisionCheckError",
166-
# "FutureResult",
167-
# "CancellableFutureResult",
168-
# "MPMaxJumpError",
169-
# # ROS
170-
# "RosClient",
171-
# "RosError",
172-
# "RosValidationError",
173-
# "RosFileServerLoader",
174-
# "MoveItPlanner",
175-
# # Analytic IK
176-
# "AnalyticalInverseKinematics",
177-
# "AnalyticalPlanCartesianMotion",
178-
# "AnalyticalPyBulletPlanner",
179-
# "AnalyticalKinematicsPlanner",
180-
# "OffsetWristKinematics",
181-
# "SphericalWristKinematics",
182-
# "CartesianMotionError",
183-
# # Robot-specific analytic IK
184-
# "UR3Kinematics",
185-
# "UR3eKinematics",
186-
# "UR5Kinematics",
187-
# "UR5eKinematics",
188-
# "UR10Kinematics",
189-
# "UR10eKinematics",
190-
# "Staubli_TX260LKinematics",
191-
# "ABB_IRB4600_40_255Kinematics",
192-
# ]
193-
194-
# if not compas.IPY:
195-
# __all__ += [
196-
# "PyBulletClient",
197-
# "PyBulletError",
198-
# "PyBulletPlanner",
199-
# "AnalyticalPyBulletClient",
200-
# ]
175+
__all__ = [
176+
# Exceptions
177+
"BackendError",
178+
"BackendFeatureNotSupportedError",
179+
"BackendTargetNotSupportedError",
180+
"TargetModeMismatchError",
181+
"PlanningGroupNotExistsError",
182+
"InverseKinematicsError",
183+
"KinematicsError",
184+
"CollisionCheckError",
185+
"MotionPlanningError",
186+
"MPStartStateInCollisionError",
187+
"MPTargetInCollisionError",
188+
"MPInterpolationInCollisionError",
189+
"MPSearchTimeOutError",
190+
"MPNoIKSolutionError",
191+
"MPNoPlanFoundError",
192+
"MPMaxJumpError",
193+
# Tasks
194+
"FutureResult",
195+
"CancellableFutureResult",
196+
# ROS
197+
"RosClient",
198+
"RosError",
199+
"RosValidationError",
200+
"RosFileServerLoader",
201+
"MoveItPlanner",
202+
# Kinematics
203+
"AnalyticalInverseKinematics",
204+
"AnalyticalPlanCartesianMotion",
205+
"AnalyticalPyBulletPlanner",
206+
"AnalyticalKinematicsPlanner",
207+
"OffsetWristKinematics",
208+
"SphericalWristKinematics",
209+
"CartesianMotionError",
210+
# Kinematics - Robot-specific analytic IK
211+
"UR3Kinematics",
212+
"UR3eKinematics",
213+
"UR5Kinematics",
214+
"UR5eKinematics",
215+
"UR10Kinematics",
216+
"UR10eKinematics",
217+
"Staubli_TX260LKinematics",
218+
"ABB_IRB4600_40_255Kinematics",
219+
]
220+
221+
# PyBullet
222+
if not compas.IPY:
223+
__all__ += [
224+
"PyBulletClient",
225+
"PyBulletError",
226+
"PyBulletPlanner",
227+
"AnalyticalPyBulletClient",
228+
"PlanningGroupNotSupported",
229+
]

src/compas_fab/backends/interfaces/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
import compas
66

7-
from compas_fab.robots import RobotCell
8-
from compas_fab.robots import RobotCellState
97

108
if compas.IPY:
119
from typing import TYPE_CHECKING
1210

1311
if TYPE_CHECKING:
14-
from compas_fab.robots import Robot
12+
from compas_fab.robots import Robot # noqa: F401
13+
from compas_fab.robots import RobotCell # noqa: F401
14+
from compas_fab.robots import RobotCellState # noqa: F401
1515

1616

1717
class ClientInterface(object):

src/compas_fab/backends/interfaces/planner.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,9 @@
1616
from typing import TYPE_CHECKING
1717

1818
if TYPE_CHECKING:
19-
from compas_fab.robots import Robot
20-
from compas_fab.robots import RobotCell
21-
from compas_fab.robots import RobotCellState
22-
from compas_fab.robots import Target
23-
from compas_fab.robots import Waypoints
24-
25-
from compas_fab.backends.interfaces import ClientInterface
26-
27-
from typing import List
28-
from typing import Optional
29-
from compas.geometry import Frame
19+
from typing import List # noqa: F401
20+
from compas_fab.robots import RobotCellState # noqa: F401
21+
from compas_fab.backends.interfaces import ClientInterface # noqa: F401
3022

3123

3224
class PlannerInterface(object):

src/compas_fab/backends/kinematics/backend_features/analytical_forward_kinematics.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from compas_fab.backends.exceptions import BackendError
21
from compas_fab.backends.interfaces import ForwardKinematics
32

43

@@ -12,8 +11,8 @@
1211
from compas_fab.robots import RobotCellState # noqa: F401
1312
from compas_fab.robots import Robot # noqa: F401
1413
from compas_fab.robots import TargetMode # noqa: F401
15-
from compas.geometry import Frame
16-
from typing import Dict, List, Optional, Tuple # noqa: F401
14+
from compas.geometry import Frame # noqa: F401
15+
from typing import Optional # noqa: F401
1716

1817

1918
class AnalyticalForwardKinematics(ForwardKinematics):

src/compas_fab/backends/kinematics/backend_features/analytical_inverse_kinematics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from compas_fab.backends.exceptions import BackendError
21
from compas_fab.backends.exceptions import BackendTargetNotSupportedError
32
from compas_fab.backends.exceptions import InverseKinematicsError
43
from compas_fab.backends.interfaces import InverseKinematics
@@ -16,7 +15,8 @@
1615
from compas_fab.robots import RobotCellState # noqa: F401
1716
from compas_fab.robots import Robot # noqa: F401
1817
from compas_fab.robots import Target # noqa: F401
19-
from typing import Dict, List, Optional, Tuple # noqa: F401
18+
from typing import Dict # noqa: F401
19+
from typing import Optional # noqa: F401
2020
from typing import Generator # noqa: F401
2121

2222
from ..utils import joint_angles_to_configurations

src/compas_fab/backends/kinematics/backend_features/analytical_plan_cartesian_motion.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from compas_fab.robots import JointTrajectoryPoint
1010
from compas_fab.robots import FrameWaypoints
1111
from compas_fab.robots import PointAxisWaypoints
12-
from compas_fab.utilities import from_tcf_to_t0cf
1312

1413

1514
class AnalyticalPlanCartesianMotion(PlanCartesianMotion):

src/compas_fab/backends/kinematics/backend_features/analytical_pybullet_inverse_kinematics.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
from compas_fab.robots import Robot # noqa: F401
1313
from compas_fab.robots import Target # noqa: F401
1414
from typing import Generator # noqa: F401
15-
from typing import Dict, List, Optional, Tuple # noqa: F401
15+
from compas_robots import Configuration # noqa: F401
16+
from typing import Dict # noqa: F401
17+
from typing import Optional # noqa: F401
1618
from compas_fab.backends import PyBulletClient # noqa: F401
1719

18-
from compas_robots import Configuration
1920

2021
from compas_fab.backends import CollisionCheckError
2122
from compas_fab.robots import FrameTarget
2223

23-
from ..utils import joint_angles_to_configurations
24-
from ..utils import try_to_fit_configurations_between_bounds
25-
2624

2725
class AnalyticalPybulletInverseKinematics(AnalyticalInverseKinematics):
2826
"""Callable to calculate the robot's inverse kinematics for a given frame.
@@ -73,7 +71,7 @@ def iter_inverse_kinematics_frame_target(self, target, start_state, group, optio
7371

7472
options = options or {}
7573
planner = self # type: AnalyticalPyBulletPlanner
76-
robot = planner.client.robot_cell.robot # type: Robot
74+
robot = planner.client.robot_cell.robot # type: Robot # noqa: F841
7775
client = self.client # type: PyBulletClient
7876

7977
# Set robot cell state to start state if provided
@@ -102,7 +100,7 @@ def iter_inverse_kinematics_frame_target(self, target, start_state, group, optio
102100
client.set_robot_configuration(configuration)
103101
# Passing the `_skip_set_robot_cell_state` option to the collision check function
104102
planner.check_collision(None, options={"_skip_set_robot_cell_state": True})
105-
except CollisionCheckError as e:
103+
except CollisionCheckError:
106104
# If keep order is true, yield a None to keep the order of the solutions
107105
if options.get("keep_order", True):
108106
yield None

src/compas_fab/backends/kinematics/backend_features/analytical_set_robot_cell_state.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
1-
from compas_fab.backends.interfaces import SetRobotCellState
2-
31
import compas
4-
from compas.geometry import Frame
2+
3+
from compas_fab.backends.interfaces import SetRobotCellState
54

65
if not compas.IPY:
76
from typing import TYPE_CHECKING
87

98
if TYPE_CHECKING:
10-
from typing import Optional # noqa: F401
11-
from typing import Dict # noqa: F401
12-
from typing import List # noqa: F401
13-
from typing import Tuple # noqa: F401
14-
15-
from compas_fab.robots import Robot # noqa: F401
16-
from compas_robots import Configuration # noqa: F401
17-
from compas.geometry import Frame # noqa: F401
18-
from compas_fab.backends.interfaces import ClientInterface # noqa: F401
19-
from compas_fab.robots import RobotCell # noqa: F401
20-
from compas_fab.robots import RobotCellState # noqa: F401
21-
from compas_fab.backends import PyBulletClient # noqa: F401
229

23-
from compas_fab.backends.pybullet.const import STATIC_MASS
10+
from compas_fab.robots import RobotCellState # noqa: F401
2411

2512

2613
class AnalyticalSetRobotCellState(SetRobotCellState):

src/compas_fab/backends/kinematics/planner.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
import compas
2-
from compas_fab.backends.interfaces.planner import PlannerInterface
3-
4-
from compas_fab.backends.pybullet.backend_features import *
5-
from compas_fab.backends.kinematics.backend_features import *
6-
from compas_fab.backends.kinematics.solvers import *
7-
8-
from compas_fab.backends.kinematics.client import AnalyticalKinematicsClient # noqa: F401
9-
from compas_fab.backends.pybullet.client import PyBulletClient # noqa: F401
1+
from compas import IPY
102

11-
if compas.IPY:
3+
from compas_fab.backends.interfaces.planner import PlannerInterface
4+
from compas_fab.backends.kinematics.backend_features import AnalyticalForwardKinematics
5+
from compas_fab.backends.kinematics.backend_features import AnalyticalInverseKinematics
6+
from compas_fab.backends.kinematics.backend_features import AnalyticalPlanCartesianMotion
7+
from compas_fab.backends.kinematics.backend_features import AnalyticalPybulletInverseKinematics
8+
from compas_fab.backends.kinematics.backend_features import AnalyticalSetRobotCell
9+
from compas_fab.backends.kinematics.backend_features import AnalyticalSetRobotCellState
10+
from compas_fab.backends.kinematics.client import AnalyticalKinematicsClient
11+
from compas_fab.backends.pybullet.backend_features import PyBulletCheckCollision
12+
from compas_fab.backends.pybullet.backend_features import PyBulletForwardKinematics
13+
from compas_fab.backends.pybullet.backend_features import PyBulletSetRobotCell
14+
from compas_fab.backends.pybullet.backend_features import PyBulletSetRobotCellState
15+
16+
if IPY:
1217
from typing import TYPE_CHECKING
1318

1419
if TYPE_CHECKING:
15-
from typing import Optional
20+
from typing import Optional # noqa: F401
21+
22+
from compas_fab.backends.kinematics.solvers import AnalyticalKinematics # noqa: F401
23+
from compas_fab.backends.pybullet.client import PyBulletClient # noqa: F401
1624

1725
__all__ = [
1826
"AnalyticalPyBulletPlanner",

src/compas_fab/backends/kinematics/solvers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from .analytical_kinematics import AnalyticalKinematics # noqa: F403
21
from .spherical_wrist_kinematics import * # noqa: F403
32
from .offset_wrist_kinematics import * # noqa: F403
43

0 commit comments

Comments
 (0)