question

Roeland S avatar image
0 Likes"
Roeland S asked Ben Wilson commented

AGV redirect function throws an exception

Hello,

Below a snippet of some code. Everything works fine until the redirect function is excecuted. Any ideas?

Thanks in advance!

FlexSim 21.0.2
flexsim 21.0.2agv redirect
1614810790211.png (2.7 KiB)
1614810861430.png (16.6 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ben Wilson avatar image Ben Wilson ♦♦ commented ·

Hi @Roeland S, was steven.hamoen's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Steven Hamoen avatar image
0 Likes"
Steven Hamoen answered anthony.johnson commented

@Roeland S If I look at the error message it point to an index out of range. So looking at your code I would suspect the token.DuwKonvooi[i+1]. With the snippet I can't say what i is and if it is out of bounds. You could place a breakpoint and look at it's value.

The other thing is that you use a "2" in the redirect statement. This most likely should work, but I would suggest you use the official constants/macros that are defined for it. Firstly you know absolutely sure that it does work and secondly your code is better understandable if if you revisit after a while. Options are:

REDIRECT_AND_WAIT - if not redirected before arrival, the agv will wait at the destination until redirected
REDIRECT_AS_FINAL - the destination becomes the new final destination for the agv
REDIRECT_AND_CONTINUE_ON_ARRIVAL - the agv will continue to the final destination after arriving at the intermediate destination
REDIRECT_AND_CONTINUE_ON_PRE_ARRIVAL - the agv will continue to the final destination after pre-arriving at the intermediate destination (it will not decelerate to a stop)

· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Roeland S avatar image Roeland S commented ·

@steven.hamoen

Steven,

I had better posted the entire function in the code snippet. As you can see below, i is always smaller than the length of the array such that the i+1 returns a valid object (control point). If i debug this code, it runs fine until the redirect function. I originally wrote the enumerate "REDIRECT_AS_FINAL" but changed it as a test because the manual indicates the second argument should be an integer.

I really don't understand why this redirect statement throws an exception. Hence, i really hope you could give me any advice...

0 Likes 0 ·
1614848647574.png (27.5 KiB)
Steven Hamoen avatar image Steven Hamoen commented ·

@Roeland S It is very difficult to debug without the model (as you can understand) but from your earlier posts I understood that you can't post it. So we have to keep guessing. First thing ofcourse you checked that newDest is valid and an existing object and that it is connected to the AGV network?

Also that agv is a valid agv.

By the way is the code after the redirect ever executed. So have you placed a print statement directly after the redirect statement?

Because the token.DuwKonvooi[i++] can run out of bounds
0 Likes 0 ·
Roeland S avatar image Roeland S Steven Hamoen commented ·

@steven.hamoen

During debugging (F10), i've noticed that the code after the redirect statement is never executed. I've added the print function, which confirms it.

Indeed, I cannot share the model, but is it possible to have a short call about it? I then can give the the controls to access the model.

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen commented ·

@anthony.johnson We have looked at it with an online session. It looks like the redirect throws this error. (the redirect in the code we looked at is REDIRECT_AS_FINAL and not 2 as above) It is redirecting the AGV to the next CP it encounters and that is also already claimed by this AGV. We have tried to create a simple model to reproduce, but that worked fine. Would this remark together with the exception, give you an idea what could be wrong? Or should Roeland post the model in a privat question?

0 Likes 0 ·
anthony.johnson avatar image anthony.johnson ♦♦ Steven Hamoen commented ·

The "invalid index" exception is thrown when using treenode.subnodes. The question is, whose code is using treenode.subnodes? From the exception screenshot, I can only see MODEL:/Tools/ProcessFlow/to. If that path is the correct path to the code that's executing, then it's our code throwing the exception. Otherwise, you can try stepping into the redirect function to see if there is any user code being called as part of the redirect. Other than that I'd have to see the model. You can post a private question, tag me on it, and I will take a look at it.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.