Skip to content

Commit

Permalink
Reverting default behavior to not remove onshape's <n> tags. Adding d…
Browse files Browse the repository at this point in the history
…efault joint limits to revolute joints.
  • Loading branch information
senthurayyappan committed Jan 17, 2025
1 parent 54d4e92 commit 764b998
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 31 deletions.
11 changes: 10 additions & 1 deletion onshape_robotics_toolkit/models/joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,16 @@ def from_xml(cls, element: ET.Element) -> "RevoluteJoint":
mimic_element = element.find("mimic")
mimic = JointMimic.from_xml(mimic_element) if mimic_element is not None else None

return cls(name, parent, child, origin, axis, limits, dynamics, mimic)
return cls(
name=name,
parent=parent,
child=child,
origin=origin,
axis=axis,
limits=limits,
dynamics=dynamics,
mimic=mimic,
)

@property
def joint_type(self) -> str:
Expand Down
50 changes: 25 additions & 25 deletions onshape_robotics_toolkit/urdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
BaseJoint,
DummyJoint,
FixedJoint,
JointLimits,
# JointDynamics,
# JointLimits,
JointMimic,
PrismaticJoint,
RevoluteJoint,
Expand Down Expand Up @@ -233,12 +233,12 @@ def get_robot_joint(
parent=parent,
child=child,
origin=origin,
# limits=JointLimits(
# effort=1.0,
# velocity=1.0,
# lower=-np.pi,
# upper=np.pi,
# ),
limits=JointLimits(
effort=1.0,
velocity=1.0,
lower=-2 * np.pi,
upper=2 * np.pi,
),
axis=Axis((0.0, 0.0, -1.0)),
# dynamics=JointDynamics(damping=0.1, friction=0.1),
mimic=mimic,
Expand Down Expand Up @@ -293,12 +293,12 @@ def get_robot_joint(
parent=parent,
child=dummy_x.name,
origin=origin,
# limits=JointLimits(
# effort=1.0,
# velocity=1.0,
# lower=-np.pi,
# upper=np.pi,
# ),
limits=JointLimits(
effort=1.0,
velocity=1.0,
lower=-2 * np.pi,
upper=2 * np.pi,
),
axis=Axis((1.0, 0.0, 0.0)),
# dynamics=JointDynamics(damping=0.1, friction=0.1),
mimic=mimic,
Expand All @@ -308,12 +308,12 @@ def get_robot_joint(
parent=dummy_x.name,
child=dummy_y.name,
origin=Origin.zero_origin(),
# limits=JointLimits(
# effort=1.0,
# velocity=1.0,
# lower=-np.pi,
# upper=np.pi,
# ),
limits=JointLimits(
effort=1.0,
velocity=1.0,
lower=-2 * np.pi,
upper=2 * np.pi,
),
axis=Axis((0.0, 1.0, 0.0)),
# dynamics=JointDynamics(damping=0.1, friction=0.1),
mimic=mimic,
Expand All @@ -323,12 +323,12 @@ def get_robot_joint(
parent=dummy_y.name,
child=child,
origin=Origin.zero_origin(),
# limits=JointLimits(
# effort=1.0,
# velocity=1.0,
# lower=-np.pi,
# upper=np.pi,
# ),
limits=JointLimits(
effort=1.0,
velocity=1.0,
lower=-2 * np.pi,
upper=2 * np.pi,
),
axis=Axis((0.0, 0.0, -1.0)),
# dynamics=JointDynamics(damping=0.1, friction=0.1),
mimic=mimic,
Expand Down
10 changes: 5 additions & 5 deletions onshape_robotics_toolkit/utilities/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def make_unique_name(name: str, existing_names: set[str]) -> str:
return f"{name}-{count}"


def get_sanitized_name(name: str, replace_with: str = "_", remove_onshape_tags: bool = True) -> str:
def get_sanitized_name(name: str, replace_with: str = "_", remove_onshape_tags: bool = False) -> str:
"""
Sanitize a name by removing special characters, preserving only the specified
replacement character, and replacing spaces with it. Ensures no consecutive
Expand All @@ -289,18 +289,18 @@ def get_sanitized_name(name: str, replace_with: str = "_", remove_onshape_tags:
Args:
name (str): Name to sanitize.
replace_with (str): Character to replace spaces and other special characters with (default is '_').
remove_onshape_tags (bool): If True, removes a trailing " <n>" tag where n is a number. Default is True.
remove_onshape_tags (bool): If True, removes a trailing " <n>" tag where n is a number. Default is False.
Returns:
str: Sanitized name.
Examples:
>>> get_sanitized_name("wheel1 <3>")
"wheel1"
>>> get_sanitized_name("wheel1 <3>", remove_onshape_tags=False)
"wheel1_3"
>>> get_sanitized_name("wheel1 <3>", remove_onshape_tags=True)
"wheel1"
>>> get_sanitized_name("wheel1 <3>", replace_with='-', remove_onshape_tags=False)
"wheel1-3"
"""
Expand Down

0 comments on commit 764b998

Please sign in to comment.