Skip to content

Commit

Permalink
feat: add deepcopy: bool option to spec.get_robot_model
Browse files Browse the repository at this point in the history
  • Loading branch information
HiroIshida committed Feb 27, 2025
1 parent 34b02f3 commit f1c19f4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/plainmp/robot_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
_loaded_kin: "OrderedDict[str, KinematicModel]" = OrderedDict()


def load_urdf_model_using_cache(file_path: Path, deepcopy: bool = True, with_mesh: bool = False):
def load_urdf_model_using_cache(file_path: Path, with_mesh: bool = False, deepcopy: bool = True):
file_path = file_path.expanduser()
assert file_path.exists()
key = str(file_path)
Expand Down Expand Up @@ -179,8 +179,10 @@ def extract_skrobot_model_q(

return np.array(angles)

def get_robot_model(self, with_mesh: bool = False) -> RobotModel:
model = load_urdf_model_using_cache(self.urdf_path, with_mesh=with_mesh)
def get_robot_model(self, with_mesh: bool = False, deepcopy: bool = True) -> RobotModel:
# deepcopy is recommended to avoid the side effect of the skrobot model's internal
# but it is not efficient. If performance is critical, you may want to set deepcopy=False
model = load_urdf_model_using_cache(self.urdf_path, with_mesh=with_mesh, deepcopy=deepcopy)
# Add custom links defined in conf to the robot model as CascadedCoords
if "custom_links" in self.conf_dict:
for name in self.conf_dict["custom_links"].keys():
Expand Down

0 comments on commit f1c19f4

Please sign in to comment.