RobotStudio event

RapidData ValueChanged event not triggering

Hi there!

So, we are working on a project where we want to simulate real-time interaction with an ABB robot by loading a program that loops endlessly over 4 robtargets, and hotswapping their values as the loop progresses. The code we load to the controller looks like this:

MODULE StreamModule

  PERS bool aborted := FALSE;
  PERS num pnum := -1;

  PERS speeddata vel0:=[20,20,1000,1000];
  PERS speeddata vel1:=[20,20,1000,1000];
  PERS speeddata vel2:=[20,20,1000,1000];
  PERS speeddata vel3:=[20,20,1000,1000];

  PERS zonedata zone0:=[FALSE,5,8,8,0.8,8,0.8];
  PERS zonedata zone1:=[FALSE,5,8,8,0.8,8,0.8];
  PERS zonedata zone2:=[FALSE,5,8,8,0.8,8,0.8];
  PERS zonedata zone3:=[FALSE,5,8,8,0.8,8,0.8];

  PERS bool pset0 := FALSE;
  PERS bool pset1 := FALSE;
  PERS bool pset2 := FALSE;
  PERS bool pset3 := FALSE;

  PERS robtarget p0 := [[377.22,4.21,546.99],[0,-0.0056,1,0],[0,0,0,0],[0,9E9,9E9,9E9,9E9,9E9]];
  PERS robtarget p1 := [[260.33,4.21,671.48],[0,-0.0081,1,0],[0,0,0,0],[0,9E9,9E9,9E9,9E9,9E9]];
  PERS robtarget p2 := [[128.75,4.21,562.63],[0,-0.0163,0.9999,0],[0,0,0,0],[0,9E9,9E9,9E9,9E9,9E9]];
  PERS robtarget p3 := [[229.12,4.21,424.47],[0,-0.0092,1,0],[0,0,0,0],[0,9E9,9E9,9E9,9E9,9E9]];

  PROC main()
    AccSet 10, 10;
    ConfL\Off;
    ConfJ\Off;

    Path0;
  ENDPROC

  PROC Path0()
    WHILE NOT aborted DO
      WaitUntil pset0 = TRUE;
      pset0 := FALSE;
      pnum := 0;
      MoveL p0,vel0,zone0,Tool0\WObj:=WObj0;

      WaitUntil pset1 = TRUE;
      pset1 := FALSE;
      pnum := 1;
      MoveL p1,vel1,zone1,Tool0\WObj:=WObj0;

      WaitUntil pset2 = TRUE;
      pset2 := FALSE;
      pnum := 2;
      MoveL p2,vel2,zone2,Tool0\WObj:=WObj0;

      WaitUntil pset3 = TRUE;
      pset3 := FALSE;
      pnum := 3;
      MoveL p3,vel3,zone3,Tool0\WObj:=WObj0;
    ENDWHILE
  ENDPROC

ENDMODULE


The key to this working is subscribing to changes in the value of the variable 'pnum', so that the computer monitoring the program knows when to hotswap the next target, and which one to do. We have tried several methods to subscribe to these changes using the PC SDK 6.03:

// RD_pnum.ValueChanged += OnRD_pnum_ValueChanged;
// RD_pnum.ValueChanged += new EventHandler<DataValueChangedEventArgs>(OnRD_pnum_ValueChanged);
RD_pnum.Subscribe(OnRD_pnum_ValueChanged, EventPriority.High);  // (this is the one we are currently using)

However, we are stuck with a problem we cannot figure out: the subscription seems to randomly stop working for no reason...! So, if using RobotStudio for simulation, everything is fine when we create a new station with a new robot. Changes in 'pnum' raise events, the client can react to them, and variable hot-swapping works fine. However, after some time of use, 'pnum' stops raising these events, and the whole workflow stops working. It happens similarly when connected to a real controller. 

Some patterns observed:
- This problem usually doesn't happen if the same instance of a client is running for a long time, but rather if the client is started several times. 
- As an approximation, this usually fails after 30 minutes of creating a new station. 
- Once 'pnum' stops raising events, it doesn't go back to raising them for the same station. In RobotStudio, the only solution is to load/create a different station. In a real controller, the only option is to physically restart it (turn it off, and then on...), and we are not sure if this even works 100% of the times... 
- If sticking with the same station, we have observed if we refactor the variable 'pnum' to something else in the RAPID program we load to the controller, it will work again most of the times, although failing back again after some times. We have also noticed that the refactoring has to be to a variable name never used before, otherwise it will fail.

As a note, on client disconnection we are disposing the client-side variable:

        if (RD_pnum != null)
            {
                RD_pnum.Unsubscribe(OnRD_pnum_ValueChanged);
                RD_pnum.Dispose();
                RD_pnum = null;
            }

We would really appreciate some hints as to what might be happening here, we are going nuts trying to figure out what is going on... Does it have anything to do with 'pnum' being a PERS variable, and somehow the subscription also being persistent and conflicting over different client connections...? 

Thank you very much in advance,


Jose








Tagged: