You give the AGV a task to travel to CP2. Then you give the AGV a task to travel to CP3. Then, shortly after the AGV starts that travel task, you redirect it to CP4 with a CONTINUE_ON_PRE_ARRIVAL.
Then, in the middle of that PreArrival event that is being processed (before it has even finished), you fire code without a breathe that redirects him again to CP5, which will start him traveling towards CP5 once he traverses past the next point.
At this point, he now tries to finish his code that was trying to travel to CP4 as part of the first redirection, and his internal state is all kinds of messed up because you (1) never let him arrive and (2) redirected him before he even finished his first redirection.
Thus, he thinks he's done redirecting because he is trying to finish his first redirection, as the call stack unwinds. And thus, he never gets back to traveling to CP3 because his internal state is in total disarray from getting his functions called all out of order.
Suggestion for a workaround? Before the second redirect, breathe for the duration of time that the AGV requires between his current PreArrival event and his next traversal event so that the AGV can finish processing the first redirection and get back to traveling to CP3 before you redirect him again.
redirect_2.fsm (In this particular model, the amount of time needed to breathe is 1.0 seconds, but if you change the AGV's speed/acceleration/deceleration settings, then that value is going to be different because that will change when the PreArrival event fires relative to the next traversal event.)
Suggestion for a solution? Stop all this crazy preempting and redirection and give him tasks to go where you want him to go when you want him to go, using the end speed of the travel task to determine whether he continues traveling at full speed or whether he slows to a stop between travel tasks.
Phil BoBo
Sr. Manager, Software Development