Hi…
A few months ago, I encountered the same situation and resolved it by creating my own function.
My goal is to ensure that the tip of the object being carried moves at a speed comparable to linear motion. Since we work with parameterized programs where the user defines the robot’s execution speed, this adjustment becomes necessary.
Here’s the code; feel free to modify and use it as needed. If you find any improvements for the routine, please share them with us.
! Adjust Orientation Speed to Resemble Linear Speed
! Version: 1.1.1
!
! Purpose: This procedure converts linear speed into angular speed based on the reference object’s radius. This is useful when only linear speed is known, but an object’s rotation speed is needed, with the radius derived from the object’s dimensions.
! Angular Speed Adjustment (v_ori): Adjusts the angular speed (v_ori) of an object relative to its linear speed (v_tcp), taking into account the reference object's dimensions.
! Radius Calculation: Computes the reference object’s radius using its width (objRefP.width) and length (objRefP.length). The radius is half the hypotenuse of a right triangle formed by these dimensions.
! Linear to Angular Speed Conversion: Converts linear speed (v_tcp) to angular speed (v_ori) using the calculated radius. This formula translates the linear speed unit (mm/s) to angular speed (degrees/s).
! Assigning Angular Speed: The computed angular speed is assigned to the v_ori property of the setVelR object, which is of type speeddata.
!
! Version History
! 1.1.1 - Modification
! The optional overflowP parameter is now capped at 300%.
! Added the optional \switch FULL option, which, when enabled, equates TCP speed with joint orientation speed, so v_tcp = v_ori.
! 1.1 - Modification
! Added an optional parameter to set the percentage to override the calculated speed, constrained by the maximum allowable speed.
! 1.0 - Original
!
! Parameters
! \switch FULL: Sets reorientation speed to match TCP speed, bypassing any mm to degree conversion.
! INOUT speeddata setVelR: Return speed to be set.
! \object objRefP: Reference object for calculation.
! \num rayP: Option to specify a radius parameter instead of the object.
! \num overflow: Overrides speed by a specified percentage.
! Return
! Returns speeddata for axis orientation to achieve a result similar to the linear movement specified in setVelR.
! Usage Example
! MODULE ModPRG()
! RECORD object
! num width ;
! num length ;
! num height ;
! ENDRECORD
!
! PERS speeddata myVel := [7000, 7000, 5000, 1000];
! VAR object obj;
! VAR num radius;
!
! PROC main()
! obj := [100, 200, 0];
! radius := 100;
!
! AdjustVOriWithVTCP(myVel\objRefP := obj); ! >>~ myVel := [7000, 3587.28, 5000, 1000]
! AdjustVOriWithVTCP(myVel\rayP := radius); ! >>~ myVel := [7000, 4010.7, 5000, 1000]
! AdjustVOriWithVTCP(myVel); ! >>~ myVel := [7000, 700, 5000, 1000] -> v_tcp*0.1
! AdjustVOriWithVTCP(myVel\overflowP := 80); ! >>~ myVel := [7000, 560, 5000, 1000] -> v_tcp*0.1*0.8
! ENDPROC
! ENDMODULE
!
PROC AdjustVOriWithVTCP(\switch FULL,INOUT speeddata setVelR\object objRefP\num rayP\num overflowP)
! ## ATTRIBUTES ##############################################################################
VAR num overflowL:=1;
! ## ATTRIBUTES ##############################################################################
! Checks whether to set the maximum speed for reorientation...
IF Present(FULL) THEN
setVelR.v_ori:=setVelR.v_tcp;
ELSE
! Checking speedup and limiting it to 300%...
IF Present(overflowP) THEN
IF overflowP>300 THEN
Add overflowL,overflowP/100;
ELSE
Add overflowL,300/100;
ENDIF
ENDIF
! Calculate the speed...
IF Present(objRefP) THEN
! Radius = Hypotenuse / 2
! Angular Velocity (degrees/s) = (Linear Velocity (mm/s) / (2 * pi * Radius)) * 360
setVelR.v_ori:=(setVelR.v_tcp/(pi*Sqrt(Pow(objRefP.largura,2)+Pow(objRefP.comprimento,2)))*360)*overflowL;
ELSE
IF Present(rayP) THEN
! Using the radius value...
setVelR.v_ori:=(setVelR.v_tcp/(2*pi*rayP)*360)*overflowL;
ELSE
setVelR.v_ori:=(setVelR.v_tcp*0.1)*overflowL;
ENDIF
ENDIF
ENDIF
RETURN ;
ERROR
! #############################################################################################
! HANDLING POSSIBLE ERRORS
! #############################################################################################
! If you encountered an error while dividing by ZERO...
IF ERRNO=ERR_DIVZERO THEN
IF Present(FULL) THEN
setVelR.v_ori:=setVelR.v_tcp;
ELSE
setVelR.v_ori:=(setVelR.v_tcp/(pi*Sqrt(Pow(1,2)+Pow(1,2)))*360)*overflowL;
ENDIF
RETURN ;
ENDIF
ENDPROC
Good Job.