@@ -906,8 +906,7 @@ def get_attached_rigid_bodies(self, robot_cell_state, group):
906906 # Transformation functions
907907 # ----------------------------------------
908908
909- def t_pcf_tcf (self , robot_cell_state , tool_id ):
910- # type: (RobotCellState, str) -> Transformation
909+ def t_pcf_tcf (self , robot_cell_state : RobotCellState , tool_id : str ) -> Transformation :
911910 """Returns the transformation from the PCF (Planner Coordinate Frame) to the TCF (Tool Coordinate Frame).
912911
913912 Parameters
@@ -922,9 +921,33 @@ def t_pcf_tcf(self, robot_cell_state, tool_id):
922921 Transformation from the tool's TCF to TBCF.
923922 """
924923
924+ t_pcf_tbcf = self .t_pcf_tbcf (robot_cell_state , tool_id )
925+
926+ # t_tbcf_tcf is Tool Frame, a property of the tool model, describing Tool Coordinate Frame (TCF) relative to Tool Base Frame (TBCF)
927+ tool_model = self .tool_models [tool_id ]
928+ t_tbcf_tcf = Transformation .from_frame (tool_model .frame )
929+
930+ t_pcf_tcf = t_pcf_tbcf * t_tbcf_tcf
931+ return t_pcf_tcf
932+
933+ def t_pcf_tbcf (self , robot_cell_state : RobotCellState , tool_id : str ) -> Transformation :
934+ """Returns the transformation from the PCF (Planner Coordinate Frame) to the TBCF (Tool Base Coordinate Frame).
935+
936+ Parameters
937+ ----------
938+ tool_id : str
939+ The id of a tool found in `self.robot_cell.tool_models`.
940+ The tool must be attached to the robot.
941+
942+ Returns
943+ -------
944+ :class:`~compas.geometry.Transformation`
945+ Transformation from the tool's TCF to TBCF.
946+ """
947+
925948 if tool_id not in self .tool_models :
926949 raise ValueError ("Tool with id '{}' not found in robot cell." .format (tool_id ))
927- tool_model = self . tool_models [ tool_id ]
950+
928951 tool_state = robot_cell_state .tool_states [tool_id ]
929952 if not tool_state .attached_to_group :
930953 raise ValueError ("Tool with id '{}' is not attached to the robot." .format (tool_id ))
@@ -933,14 +956,10 @@ def t_pcf_tcf(self, robot_cell_state, tool_id):
933956 # t_pcf_tbcf is Tool Attachment Frame, describing Tool Base Coordinate Frame (TBCF) relative to PCF Frame on the Robot (PCF)
934957 attachment_frame = tool_state .attachment_frame or Frame .worldXY ()
935958 t_pcf_tbcf = Transformation .from_frame (attachment_frame )
936- # t_tbcf_tcf is Tool Frame, a property of the tool model, describing Tool Coordinate Frame (TCF) relative to Tool Base Frame (TBCF)
937- t_tbcf_tcf = Transformation .from_frame (tool_model .frame )
938959
939- t_pcf_tcf = t_pcf_tbcf * t_tbcf_tcf
940- return t_pcf_tcf
960+ return t_pcf_tbcf
941961
942- def t_pcf_ocf (self , robot_cell_state , workpiece_id ):
943- # type: (RobotCellState, str) -> Transformation
962+ def t_pcf_ocf (self , robot_cell_state : RobotCellState , workpiece_id : str ) -> Transformation :
944963 """Returns the transformation from the PCF (Planner Coordinate Frame) to the OCF (Object Coordinate Frame).
945964
946965 Parameters
0 commit comments