Skip to content

Commit 38b60aa

Browse files
Replace assertions in clearpath_generator_common with specific exceptions. Include error messages (#271)
1 parent 7676353 commit 38b60aa

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clearpath_generator_common/clearpath_generator_common/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ def __init__(self,
336336
setup_path: str = '/etc/clearpath/') -> None:
337337
# Define paths
338338
self.config_path = os.path.join(setup_path, 'robot.yaml')
339-
assert os.path.exists(self.config_path)
339+
if not os.path.exists(self.config_path):
340+
raise FileNotFoundError(f'Config path {self.config_path} does not exist')
340341

341342
self.setup_path = setup_path
342343
self.sensors_params_path = os.path.join(

clearpath_generator_common/clearpath_generator_common/description/manipulators.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
# of Clearpath Robotics.
3232
from typing import List
3333

34+
from clearpath_config.common.types.exception import (
35+
UnsupportedAccessoryException,
36+
)
3437
from clearpath_config.manipulators.types.arms import (
3538
BaseArm,
3639
Franka,
@@ -145,7 +148,10 @@ def __init__(self, gripper: FrankaGripper):
145148
class BaseRobotiqGripperDescription(BaseDescription):
146149

147150
def __init__(self, gripper: BaseGripper):
148-
assert isinstance(gripper, Robotiq2F85) or isinstance(gripper, Robotiq2F140)
151+
if not (isinstance(gripper, Robotiq2F85) or isinstance(gripper, Robotiq2F140)):
152+
raise UnsupportedAccessoryException(
153+
f'Gripper must be of type "Robotiq2F85" or "Robotiq2F140", not "{type(gripper)}"' # noqa: E501
154+
)
149155
super().__init__(gripper)
150156
if (gripper.arm.MANIPULATOR_MODEL == KinovaGen3Dof6.MANIPULATOR_MODEL or
151157
gripper.arm.MANIPULATOR_MODEL == KinovaGen3Dof7.MANIPULATOR_MODEL):

0 commit comments

Comments
 (0)