Is it possible to somehow convert a string (in my case received through a socket) to the equivalent data but in a number type in RAPID? I have tried with StrToByte but the problem is that I’m significantly limited by the range of the byte type (0 - 255 without negative values). What I need is to by the socket the position of the robotic arm and, as you know, the position of the effector can quite a bit exceed the limit (255). I thought about multiplying the values but in this case I would lose a possibility of reaching intermediate points. And still, what about negative values?
How can I check a reachability of a specified point by a RAPID code? Generally, my program crashes now when the coordinates of the demanded point are exceeding the robot’s workspace limit.
StrToVal allows you to convert a string to positive or negative number.
Find out your max x, y, and z you can reach and use an IF statement to check that your positions are valid before sending the robot too far/crashing the program.
! Check if specified robtarget can be reach with given tool and wobj.
!
! Output:
! Return TRUE if given robtarget is reachable with given tool and wobj
! otherwise return FALSE
!
! Parameters:
! pReach - robtarget to be checked, if robot can reach this robtarget
! ToolReach - tooldata to be used for possible movement
! WobjReach - wobjdata to be used for possible movement
Thank you msalminen. I think the ERR_ROBLIMIT parameter could be very useful.
I have a modified version but cant get it working. Will you have a look please? It is the first time I’m doing error handling so Im not sure if im clear of the functions like “ERROR” and “TRYNEXT” . I think the use of CalcJointT is essentially just to exploit its ability to generate an error code, which we try to make use of?
MODULE MODNAME
PERS num bReachable:=0;
PROC mMain
CheckReachable TheTarget,ActiveTool;
!Only try to move if it is reachable. IF bReachable=1 THEN movej TheTarget,TheSpeed,TheZone,ActiveToolj; ENDIF
ENDPROC
PROC CheckReachable(robtarget pReach,pers tooldata ToolReach,\pers wobjdata WobjReach) VAR jointtarget jntReach;
bReachable:=0;
IF present(WobjReach) then jntReach:=CalcJointT(pReach,ToolReach\Wobj:=WobjReach); else jntReach:=CalcJointT(pReach,ToolReach); endif
ERROR IF ERRNO=ERR_ROBLIMIT THEN bReachable:=2; TPWrite “NOGO”\Pos:=pReach.trans; TRYNEXT; else bReachable:=1; TPWrite “GO”\Pos:=pReach.trans; TRYNEXT; ENDIF ENDPROC ENDMODULE
You routine seems to set bReachable to 0, if the robtarget is reachable. You check in main if it’s 1. So change the line bRechable:=0; to bRechable:=1;
The error handler never fires if CalcJointT can calculate the position, so your If/else in error handler don’t work.
Hi msalminen, thank you. I have made the changes according to your suggestions but the flow controls seems to be acting weird. The designed list of robtargets goes from easy to reach to unreachable incrementally, so I sort of know when the error will occur.
But the weird behavior is that the program goes into the ERROR section and prints the “NOGO” lines even when the robot is moving well in the simulation. When it finally goes to the robtargets which is in fact impossible, then only it will stop execution and gives error messages in the output/debug tab.
The motivation behind my question is in ABB Robotics Community - Maintenance How did you get the code formatting to work in your first post in this thread?
This is old thread and old post was done with previous site/format where it woked just fine. This new look/site/format not working well at least for me with windows 7 PC.
I am using Samatsimt’s modified code. I am trying test if a given robtarget is within reach or not. If it is, it moves to the target. If the target is not in reach, then the robot is supposed to go “Home”. For some reason I cannot get bReachable to equal 2 if the robtarget is not in reach. Attached is some snippets of my code, can anyone help me and tell me where my mistake is? If I declare bReachable:=0, then the program never moves the robot, and bReachable will stay at 0 unless I send a target that is out of reach, then it only changes to 1 (which it should change to 2). If I declare it to equal 1 in the beginning, all it does is keep bReachable at 1, no matter if the target is within reach or not.. So essentially the error handler isn’t working correctly I think. Any ideas?
My Code:
Module Module1
PERS num bReachable:=0; Proc Main()
CheckReachable myRobtarget,tool0; IF bReachable=2 THEN MoveJ Home,v100,fine,tool0,\WObj:=wobj0; ELSEIF bReachable=1 THEN MoveJ myRobtarget,v100,tool0,\WObj:=wobj0; ENDIF ENDPROC
PROC CheckReachable(robtarget myRobtarget,PERS tooldata ToolReach1,\PERS wobjdata WobjReach1) VAR jointtarget jntReach1; IF Present(WobjReach1) THEN jntReach1:=CalcJointT(pReach1,ToolReach1\WObj:=WobjReach1); ELSE jntReach1:=CalcJointT(pReach1,ToolReach1); ENDIF RETURN; ERROR IF ERRNO=ERR_ROBLIMIT THEN bReachable:=2; TRYNEXT; ELSE bReachable:=1; TRYNEXT; ENDIF ENDPROC ENDMODULE
If anyone can help me, I would greatly appreciate it!!
Thanks,
SM
The manual states the ERR_ROBLIMIT is when the target is reachable but at least one axis is outside the joint limits…
So you should add (or change) the ERRNO to ERR_OUTSIDE_REACH which is where the target is outside the reach of the robot.
Also the code will not enter the error handler if the target is reachable which is why it is not changing the variable value if you set it to 1 in the declaration (it is executing the ELSE part of the error handler), and also means the variable will not be set to 1 when reachable (if set to 0 in the declaration).