RobotStudio event

Jog by axis with PC SDK

MichelinFlicka
edited May 2016 in Developer Tools
Wounder if it possible to jog by axis with the controller API. Can get the current joint values by using :
JointTarget aJointTarget = controller.MotionSystem.ActiveMechanicalUnit.GetPosition();
Console.WriteLine(aJointTarget.RobAx.Rax_2);

etc..

but i dont know how to change the values. 
i have target_10 which i constantly is updating with translations in x,y,z to make the robot move when i want to jog it linear. 
i solve it like this 

 void selectTarget(string targetName)
        {

            rd = controller.Rapid.GetRapidData("T_ROB1", "Module1", targetName);
            target = (RobTarget)rd.Value;
        }

///athread/////

 selectTarget("Target_10");

                            target.Trans.X += (float)jogX;
                            target.Trans.Y += (float)jogY;
                            target.Trans.Z += (float)jogZ;
                          
                        
                            rd.Value = target
//////////////////////////////////////

Should i have a similar approach to change the joint values?
Thankful for every advice i can get!



Comments

  • Using the function "GetPosition" will return the current position as JointTarget, but this is not connect to any variable in the Rapid Code. You are also not reading any variable, thus there are no possibilities to change something....

    You can do similar approach with your "RobTarget" example. Use a JointTarget in your code, get it with the "
    GetRapidData" function and then change it....

  • MichelinFlicka
    edited May 2016
    Ok thanks for input!
    ive tried that approach but dosent seem to get it work  


           void selectTarget(string targetName)
            {

                Jrd = controller.Rapid.GetRapidData("T_ROB1", "Module1", targetName);
                aJointTarget = (JointTarget)Jrd.Value;
            }

    ///////////////////////aThread///////////////

     selectTarget("Target_10");




                         aJointTarget.RobAx.Rax_2+=10;
                         aJointTarget.RobAx.Rax_3+=.....some value...
                         aJointTarget.RobAx.Rax_4+=..
                         aJointTarget.RobAx.Rax_5+=...
                         aJointTarget.RobAx.Rax_6+=....
                              
                 
                                Jrd.Value = aJointTarget;


    /////////////////////////////

    Can you see what im doing wrong?
  • You need to request mastership to change a variable. Furthermore the Rapid data has to be defined with the keyword "PERS".

    PERS jointtarget MyPos := [[40,0,0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];

    // Log on
    controller.Logon(UserInfo.DefaultUser);
    
    // Get Position
    Jrd = controller.Rapid.GetRapidData("T_Rob1", "Module1", "MyPos");
    aJointTarget = (JointTarget)Jrd.Value;
    
    // Change Position
    aJointTarget.RobAx.Rax_1 += 10;
    
    try
    {
        // Request mastership
        master = Mastership.Request(controller.Rapid);
    
        // Save Position
        Jrd.Value = aJointTarget;
    
        // Release and dispose mastership
        master.Release();
        master.Dispose();
    }
    catch (Exception) { }
    
    // dispose variable
    Jrd.Dispose();
    
    // Log off and dispose
    controller.Logoff();
    controller.Dispose();

  • ok didnt create a jointtarget in robot studio ^^
    done now. 

    should i put the jointtarget in a path together with "target_10" which i use for jog linear, or should it be in a own path?
    Should the process template be MoveAbs or MoveExt?
  • Which move-instructions to use or how to define the path, is at the Rapid side and actually this is just your choice.... You can put them in the same path, but you can also use different paths. 

    I assume you have a "TCP-robot" and then the MoveExtJ function is not available. This example for defining a RobTarget and JointTarget in the same path...

    MODULE Module1
    
        PERS robtarget target_10 := [[1000,0,400],[0,1,0,0],[0,0,0,0],[9e9,9e9,9e9,9e9,9e9,9e9]];
        PERS jointtarget MyPos := [[0,0,0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
        
        
        PROC Path_10()
            MoveAbsJ MyPos, v500, fine, tool0;
            MoveJ target_10, v500, fine, tool0;
        ENDPROC
        
        PROC Main()
            Path_10;
        ENDPROC
    
    ENDMODULE