diff --git a/armarx_control/robots/common.py b/armarx_control/robots/common.py index f5af3dd97d0f7705da4e5011dab901bcfe18ea40..94fa73883a6eb56461c103d1ea8105d6f8d621a1 100644 --- a/armarx_control/robots/common.py +++ b/armarx_control/robots/common.py @@ -392,7 +392,7 @@ class Robot: ) return controller_name, ctrl, ctrl_cfg - def teach(self, robot_node_set: cfg.NodeSet, side: str, filename: str): + def teach(self, robot_node_set: cfg.NodeSet, side: str, filename: str, name_suffix: str = ""): """ Enable kinethestic teaching for the given robot node set, and filename as prefix Args: @@ -405,7 +405,7 @@ class Robot: e.g. 'kinesthetic_teaching-2023-06-18-16-21-15', you will have four files recorded, including file_path-ts-forward.csv, file_path-ts-backward.csv, file_path-js-forward.csv, file_path-js-backward.csv """ - return self.ctrl.kinestheticTeaching(robot_node_set.value, side, filename) + return self.ctrl.kinestheticTeaching(robot_node_set.value, side, filename, name_suffix) def update_controller_config( self, diff --git a/armarx_control/run/kinesthetic_teaching.py b/armarx_control/run/kinesthetic_teaching.py index 6ec8607cb1a45ebb73abf39e9c1811d28795cee8..a16c5434341e46a2dfc3407a5a3bbff656d01f9e 100644 --- a/armarx_control/run/kinesthetic_teaching.py +++ b/armarx_control/run/kinesthetic_teaching.py @@ -9,11 +9,11 @@ from armarx_control.config.type import ControllerType from armarx_control.config.utils import get_default_ctrl_cfg -def teach_motion(robot, name: str, node_set: NodeSet): +def teach_motion(robot, name: str, node_set: NodeSet, name_suffix: str = ""): console.log(f"[bold cyan]Kinesthetic teaching with name {name}") side = node_set.get_side(node_set) console.log(f"[bold yellow]you can press the FT sensor of {node_set.value} (on {side} side) to start") - traj_file_stem = robot.teach(node_set, side, name) + traj_file_stem = robot.teach(node_set, side, name, name_suffix) for motion_dir in ["backward", "forward"]: motion_file_ts = Path(f"{traj_file_stem}-ts-{motion_dir}.csv") motion_file_js = Path(f"{traj_file_stem}-js-{motion_dir}.csv") @@ -32,11 +32,13 @@ def teach_motion(robot, name: str, node_set: NodeSet): @click.option("--time_sec", "-t", type=float, default=5.0, help="time duration in seconds") @click.option("--left_arm", "-l", is_flag=True, help="set to use left arm, otherwise right arm") @click.option("--series", "-s", type=int, default=6, help="which robot to use") +@click.option("--name_suffix", "-ns", type=str, default="", help="any name suffix to avoid name collision") def main( name: str = "", time_sec: float = 5.0, left_arm: bool = False, - series: int = 6 + series: int = 6, + name_suffix: str = "", ): np.set_printoptions(suppress=True, precision=3) robot = get_control_robot(RobotName.from_series(series), with_ctrl_creator=True) @@ -50,7 +52,7 @@ def main( raise NotImplementedError(f"{robot.c.name} is not implemented yet") tcp = robot.arm_tcp.RightArm if right_arm else robot.arm_tcp.LeftArm - filename = teach_motion(robot, name, nodeset) + filename = teach_motion(robot, name, nodeset, name_suffix) control_type = ControllerType.TSMPImp appendix = ""