Thread Handling and Path Planner

  • I am trying to loop through a series of movements as long as an input is false. When that input goes true I want to immediately exit the loop and do something else.


    This is very simple with a loop command and using "check expression continuously option."


    My problem is that when the input goes true, the robot jolts to a stop as if performing a security stop. I tried using a stopl() command right after the loop, but this does work.


    I looked at the underlying script code, and it seems that with the "check expression continuously" option, a separate thread is spawned to handle it.


    I'm guessing that the when the input goes true and the thread is "killed," the path planner does not immediately "see" what to do and so hands out 0 velocity to all the joints which is this sudden violent stop.


    Is this what is going on? Is there any way around this behaviour?


    Thanks!

  • Hey gradyturner86,
    Try adding and event with the exact opposite condition on your loop. And within this event add a stopl(5) command.


    i.e if your looping condition is digital_input[0] = True, then your event condition should be digital_input[0] = False
    so something like :-

    Code
    Robot Program
        Loop digital_input[0] = True
               MovJ
                   Waypoint_1
                   Waypoint_2
                   Waypoint_3
    Event digital_input[0] = False
        stopl(5)


    This should work. good luck.

  • Thanks claycamel,


    This did achieve a smooth stop.


    It spawned a new problem though. My input that triggers the loop to exit will stay on (it is a presence sensor) for more of the program. So when I tested, as soon as the main robot program attempted to move the robot, I got an error saying there was a thread control conflict.


    I was under the impression that an "Event" ran through once, then stopped, and only started again on another trigger. This appears to be incorrect, looks like it loops through the event as long as the trigger is true (Or false depending on logic programmed)..

  • Belay that, I figured a way around it.


    If I create a flag and initialize as false, and then put the Event trigger condition to be: (input = true) and (flag = false); then in the event set the flag to true after the stopl() command, this takes care of things.

Advertising from our partners