RobotStudio event

Stop task with PC SDK

Options
I need to stop a task using PC SDK (2023) (irc5 controller)

this is my code:

var m = Mastership.Request(_ctrl);
var task = _ctrl.Rapid.GetTasks().First();
task.Stop(ABB.Robotics.Controllers.RapidDomain.StopMode.Immediate);

the selected task will never stop.
Why?

Answers

  • revans
    Options
    I know there is probably a reason you are wanting to stop just one individual task, but if I remember correctly, PCSDK doesn't work like that in robotware 6.xx. It only worked like that in robotware 5.xx. So your approach mostly likely won't work with your robot. What you are supposed to do is use the option below.

     _ctlr.Rapid.Stop(ABB.Robotics.Controllers.RapidDomain.StopMode.Immediate);

    Unfortunately, that will stop all motion tasks by default if I remember correctly. From here, I have not tested it, so take the rest of my words with a grain of salt. You can set the enabled state of the tasks you wish to stop to true and the ones you want to leave running to false. Then send the rapid.Stop command to the whole controller, and only the tasks you want to stop should be stopped. This is similar to how the menu works in robotstudio. Good luck.

    My 2 cents, don't use the .first() command to get the task you want do _ctrl.Rapid.GetTask("T_ROB1") OR _ctrl.Rapid.GetTask("T_ROBR") instead. I have had the safety controller task in a safe move system register as the first task in the list before which cannot be stopped. This is simply my preference. Nothing more.

    Fun thing to note, you don't need write access to send a stop command with the default UAS system. 
  • betaGuy
    betaGuy
    edited March 18
    Options
    Thank you for the feedback.
    Maybe I have been provide a small amount of information to understand the problem.

    I have 4 task:
    - 1 motiont task: T_ROB1
    - 1 normal task
    - 2 semistatic tasks.

    I want to stop and restart one of the semistatic task.

    (I wrote .First() to "simplify" the problem)

    this is part of my code

       m = Mastership.Request(_ctrl);
      var task = _ctrl.Rapid.GetTasks("T_SOCK_COMM");
      task.Stop(ABB.Robotics.Controllers.RapidDomain.StopMode.Immediate);
      _ctrl!.Rapid.Stop(ABB.Robotics.Controllers.RapidDomain.StopMode.Immediate);
      task.ResetProgramPointer();
      task.Start();

    (Before reach this code, t_rob1 is already stopped)
    Neither  task.Stop or _ctrl!.Rapid.Stop actually stop my semiStatic task.
    So I have an exception on .ResetProgramPointer(); because the task is "running".


  • revans
    Options
    Look into the command below. Now that I know what your after, this might work a bit better. You still may have to use a some combination of enabling and disabling to make sure you do not stop a task you may want to leave running. there is a taskpanelexecutionmode that should do what you want.

    _ctrl.Rapid.Stop(ABB.Robotics.Controllers.RapidDomain.StopMode.Immediate, ABB.Robotics.Controllers.RapidDomain.TaskPanelExecutionMode.AllTasks);


    Best of luck