RobotStudio event

Change tool data

Hi, so I'm doing a project at school, and I want to change the tool data (only the X-value) by a value that is the difference between two robot targets.

One of the targets is fixed, the other one will change, depending on the length of my tool. I want to use SearchL to get the second/variable target. I want to calculate the difference in X fore the two targets, and adjust the tooldata by this walue.

Anybody who got some pointers or good tips for a noob? Smile


Comments

  • Hi SolidFloyd,

    the easy way to calculate the distance between two points is with the distance function. Distance is used to
    calculate the distance between two points in the space, in all three directions! 
    second option is to calculate only the X differentiation. 

    ! Example first option

    Var robtaget pfixpos := [....] ; 
    Var robtarget pfoundpos :=[......];

    Var toodata tTool := [....] ;
    Var num nDistance :=0;

    ! calculate distance
    nDistance := Distance(pfixpos.pos,pfoundpos.pos);

    ! Add distance to X value of toolframe;
    tTool.tframe.x := tTool.tframe.x + nDistance;


    ! Example second option

    Var robtaget pfixpos := [....] ; 
    Var robtarget pfoundpos :=[......];

    Var toodata tTool := [....] ;
    Var num nDistance :=0;

    ! calculate distance
    nDistance := pfixpos.pos.x - pfoundpos.pos.x;

    ! Add distance to X value of toolframe;
    tTool.tframe.x := tTool.tframe.x + nDistance;


  • Sweet, tnx...
    Just had to add .trans and I got it working


  • how would this work if I want to change the orientation of the tool ?