RobotStudio event

[RobotStudio SDK] Waiting while robot is moving

HM
HM
edited May 2013 in Developer Tools
Hi,

I have a code where my robot executes a MoveTo instruction and immediately after another instruction involving it. The problem is that this second instruction is executed while robot is doing the first movement with unexpected results. My question is if there is some "wait move" instruction or some event is fired when it occurs, because I couldn´t find it in the reference.

Thanks!
Post edited by Niklas Skoglund on

Comments

  • I'm assuming this is a RAPID question?

    If so then you might be running into the old calculating zones issue. If I do this:

     MoveL Target_10,v1000,z100,tool0\WObj:=wobj0;
     Set do1 := 1;
     MoveL Target_20,v1000,z100,tool0\WObj:=wobj0;

    Then the set do will execute as soon as the motion hits the zone100 before Target_10. This because the zone needs to be calculated based on the next motion which is in Target_20.

    You solve this by using fine points, that tells the motion planner to finish the current move before executing the next. Like this

     MoveL Target_10,v1000,fine,tool0\WObj:=wobj0;
     Set do1 := 1;
     MoveL Target_20,v1000,z100,tool0\WObj:=wobj0;

    In this case the motion will first go to Target_10, then STOP and then Set do1.

     

     

  • Sorry, no. I forgot to specify that I´m working on the PC SDK.
  • John Wiberg
    John Wiberg ✭✭✭

    OK, I added that to your title.

    If so then you can listen to the ExecutionStatus to see if the controller is running or stopped. You do this by the RAPID.ExecutionStatus property and the ExecutionStatusChanged event.
    http://developercenter.robotstudio.com:80/Index.aspx?DevCenter=BlobProxy/devcenter/RobotCommunication&OpenDocument&Url=html/0f27e1b1-7953-838e-a587-2bc1b7042519.htm&OptTitle=Rapid Class

    Depending on you could also listen to MotionPointer or ProgramPointer to see where it is.

    Or you could make it a combosolution with RAPID setting an IO/variable flag which your app listen to.

  • HM
    HM
    Hi,

    as you said in other topic, I´m wrong with the terms. I´m developing for the RobotStudio SDK. Sorry for the confusion.

    To be more specific with the problem, my code is similar to this (some instructions are omited):

    Station station = Project.ActiveProject as Station;
    [...] // Create RobTarget
    [...] // Create Target and add it to ActiveTask
    RsMoveInstruction trgInst = new RsMoveInstruction(station.ActiveTask, "Move", "Default", MotionType.Joint, "wobj0", target.Name, "tool0");
    station.ActiveTask.ActivePathProcedure.Instructions.Add(trgInst);

    trgInst.MoveTo();
    MakeSomeComputations();

    The problem is that MakeSomeComputations() starts execution before MoveTo is finished, so the results aren´t consistent. Some "wait movement" is needed.
  • HM
    HM
    I´ve added the code to listen the execution status of the controller between moveTo and the next instruction and now MakeSomeComputations() starts correctly. But now I can´t see the movement in the graphic window. My code:

    trgInst.MoveTo()

    RsIrc5Controller rsIrc5Controller = (RsIrc5Controller)myTask.Parent;
    ABB.Robotics.Controllers.Controller controller = new ABB.Robotics.Controllers.Controller(new Guid(rsIrc5Controller.SystemId.ToString()));

    if(controller!=null)
    {
    using (ABB.Robotics.Controllers.Mastership master = ABB.Robotics.Controllers.Mastership.Request(controller.Rapid))
    {
    while(controller.Rapid.ExecutionStatus == ABB.Robotics.Controllers.RapidDomain.ExecutionStatus.Running)
    Logger.AddMessage(new LogMessage("Robot is moving", LogMessageSeverity.Information);
    }
    }

    MakeSomeComputations();

    While MoveTo is running the message is displayed in the logger window, but the robot doesn´t move in the graphical environment. 
  • John Wiberg
    John Wiberg ✭✭✭

    Hi HM,

    That While loop is too tight. The GUI will have no CPU to handle the graphics etc. How many thousands of "Robot is moving" do you get when you did that? You might want to have some timer or somesuch in the loop to make it looser.

    If you really want something like that you should look into async programming. ie create a new thread apart from the one RS uses.

    http://msdn.microsoft.com/en-us/library/ms228963(v=vs.100).aspx

    A quick and dirty solution is the Application.DoEvents but that is prone to misfires and crashes if used too much and in the wrong places.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.application.doevents(v=vs.100).aspx

     

    But if you are using the RobotStudio SDK shouldn't it (don't have time to test right now) wait naturally for the result if you simply do a resultbased codesnippet like thus:

        if (trgInst.MoveTo())
        {
            Logger.AddMessage(new LogMessage("Yay!"));
        }
        else
        {
            Logger.AddMessage(new LogMessage("Nay!"));
        }
       MakeSomeComputations();

    Please try and let me know.