compute distances
Laro88
✭
Hello.
Can someone share some code to compute distances in RAPID?
I need to compute the distance from the present robot position to a target - say "jointtargetHome".
Case:
Depending on where the robot is and what tool it is carrying, I need to perform different motions depending on the distance to a target. Something like pseudo:
num DistToTarget(CurrentTool, Target T);
Best regards
Can someone share some code to compute distances in RAPID?
I need to compute the distance from the present robot position to a target - say "jointtargetHome".
Case:
Depending on where the robot is and what tool it is carrying, I need to perform different motions depending on the distance to a target. Something like pseudo:
num DistToTarget(CurrentTool, Target T);
Best regards
0
Comments
-
Hello,Why don't you apply following function?Usage: Distance is used to calculate the distance between two points in the space.Example:VAR num dist;
CONST pos p1 := [4,0,4];
CONST pos p2 := [-4,4,4];
...
dist := Distance(p1, p2);Best Regards,0 -
Hello,as below:???IF CurrentPos(pXX,tGripper,100)=TRUE THEN
...ENDIFFUNC bool CurrentPos(
robtarget ComparePos,
INOUT tooldata Tool,
num Accuracy
INOUT wobjdata Wobj)VAR num Counter:=0;
VAR robtarget ActualPos;IF Present(Wobj) THEN
ActualPos:=CRobT(Tool:=ToolWObj:=Wobj);
ELSE
ActualPos:=CRobT(Tool:=ToolWObj:=wobj0);
ENDIF
IF ActualPos.trans.x>ComparePos.trans.x-Accuracy AND ActualPos.trans.x<ComparePos.trans.x+Accuracy Counter:=Counter+1;
IF ActualPos.trans.y>ComparePos.trans.y-Accuracy AND ActualPos.trans.y<ComparePos.trans.y+Accuracy Counter:=Counter+1;
IF ActualPos.trans.z>ComparePos.trans.z-Accuracy AND ActualPos.trans.z<ComparePos.trans.z+Accuracy Counter:=Counter+1;
IF ActualPos.rot.q1>ComparePos.rot.q1-0.1 AND ActualPos.rot.q1<ComparePos.rot.q1+0.1 Counter:=Counter+1;
IF ActualPos.rot.q2>ComparePos.rot.q2-0.1 AND ActualPos.rot.q2<ComparePos.rot.q2+0.1 Counter:=Counter+1;
IF ActualPos.rot.q3>ComparePos.rot.q3-0.1 AND ActualPos.rot.q3<ComparePos.rot.q3+0.1 Counter:=Counter+1;
IF ActualPos.rot.q4>ComparePos.rot.q4-0.1 AND ActualPos.rot.q4<ComparePos.rot.q4+0.1 Counter:=Counter+1;
RETURN Counter=7;
ENDFUNCBR TonyABB Robotics Senior Application Engineer0 -
Distance() seems to be the perfect solution, thank you
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 801 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings