RobotStudio event

Read/Write array of robtarget with PCSDK

tkelch
tkelch
edited September 2015 in Developer Tools

How can you read/write to a large array of robtargets in the PCSDK?

Whenever I try to access an array of > 6 robtargets, the following exception gets thrown:

ABB.Robotics.Controllers.ControllerBufferOverflowException: The amount of data is to large to fulfill the request. Here an example of my code (if I change the testRobs array to {7} and add two more positions, the exception will be thrown):

==Rapid Variable===

PERS robtarget testRobs{5}:=[ [[0,0,0],[0.218963,0.314159,2.75,-0.0510062],[-1,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],

                                                      [[1,0,0],[0.218963,0.314159,2.75,-0.0510062],[-1,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],

                                                      [[2,0,0],[0.218963,0.314159,2.75,-0.0510062],[-1,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],

                                                      [[3,0,0],[0.218963,0.314159,2.75,-0.0510062],[-1,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]],

                                                      [[4,0,0],[0.218963,0.314159,2.75,-0.0510062],[-1,0,-1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]];

==C# Code===

ABB.Robotics.Controllers.RapidDomain.RapidData arr = controller.Rapid.GetRapidData("T_ROB1", "sVars", "testRobs");

if (arr.IsArray)

{ ArrayData ad = (ArrayData)arr.Value;

int aRank = ad.Rank; int len1 = ad.Length;

ArrayModes am = ad.Mode;

Debug.WriteLine("Rank: " + aRank);

Debug.WriteLine("Len: " + len1);

Debug.WriteLine("Mode: " + am.ToString());

int i = 0; for (i = 0; i < len1; i++)

{

string a = "[[" + i + ",0,0],[0.218963,0.314159,2.75,-0.0510062],[-1,0,-1,0],[8.999999E+09,8.999999E+09,8.999999E+09,8.999999E+09,8.999999E+09,8.999999E+09]]";

ad[i].FillFromString(a); Debug.WriteLine(a); }

using (Mastership.Request(controller.Rapid))

{ arr.Value = ad; } }

Post edited by Niklas Skoglund on

Comments

  • The formatting stinks... sorry. It seems to be a packet size/timing issue. It seems like the max robtarget array size is indeed limited.
  • Dear Friend: There are a method can solve your problem,that is : read the data file form robot to local computer and then analys the data file ,get the array data of your need ,if any problem please contact with me with hesitate Martin-jie.zhang@cn.abb.com from china
  • Formatting support back on the forum but still not perfect for code. I formatted the initial post a bit.

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • I have the same problem, too.  Are there any solution???
  • Micky
    Micky ✭✭✭
    Hello,

    have you tried to use the method "ReadItem" or "WriteItem"?

    Example:

    The following example updates the data of a RECORD in an array by using ReadItem and WriteItem:
    ABB.Robotics.Controllers.RapidDomain.RapidData arr = controller.Rapid.GetRapidData("T_ROB1", "sVars", "testRobs");
    if
    (arr.IsArray)
    {
     
        //Update the 6. item in the array
          UserDefined ud = (UserDefined)arr.ReadItem(6))

       using (UserDefined ud = (UserDefined)arr.ReadItem(6))
         {
            //set new sync position
            ud.Components[1].FillFromString(Position.ToString());

           //Update the Rapid array
          arr.WriteItem(ud, 6);
       }
    }
    /BR
    Micky

  • Micky said:
    Hello,

    have you tried to use the method "ReadItem" or "WriteItem"?

    Example:

    The following example updates the data of a RECORD in an array by using ReadItem and WriteItem:
    ABB.Robotics.Controllers.RapidDomain.RapidData arr = controller.Rapid.GetRapidData("T_ROB1", "sVars", "testRobs");
    if
    (arr.IsArray)
    {
     
        //Update the 6. item in the array
          UserDefined ud = (UserDefined)arr.ReadItem(6))

       using (UserDefined ud = (UserDefined)arr.ReadItem(6))
         {
            //set new sync position
            ud.Components[1].FillFromString(Position.ToString());

           //Update the Rapid array
          arr.WriteItem(ud, 6);
       }
    }
    /BR
    Micky

    Hi,Micky
        Do you need Request Mastership to change the variable?
  • Micky
    Micky ✭✭✭
    Hello Baijun,

    as described in the "PC SDK Application manual" on the website:
    http://developercenter.robotstudio.com/Index.aspx?DevCenter=RobotCommunication&OpenDocument&Url=html%2ffa1e625e-74df-4847-9f55-72a51661e34f.htm
    you have to request mastership of the RAPID domain if you want to modify RAPID data.

    To read RAPID data you need to log on to the controller.

    /BR
    Micky