ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
||||
|
||||
Conditional looping of CALLSUBTASK
Ladies and Gentlemen,
I am trying to model an AGV for which a decision on how to proceed from waypoint (m-1) to waypoint (m) is made immediately before it reaches the point m-1. The complete path cannot be planned in advance. My intent is to add each leg of a path as a separate subtask, so that it gets activated when the vehicle reaches the intermediate waypoint and proceeds on with the rest of the task when it reaches the final point. At each waypoint the current task sequence can be preempted if the AGV is suddenly needed elsewhere. Is it possible to create a custom task sequence as follows: 1) execute the first part of the task sequence 2) CALL_SUBTASK 3a) execute the subtask portion of the task sequence. 3b) test a condition. If false, CALL_SUBTASK(itself) else goto 4) 4) execute the rest of the task sequence. The subtask may have to be be called 10-100 times for each task. Is this doable? Can call subtask be nested or recursive? If this approach is suboptimal, what is the best approach for this situation? Thanks! Vadim Last edited by Vadim Fooks; 07-08-2012 at 11:08 PM. |
#2
|
||||
|
||||
Hi. Vadim.
I think the model of all your idea will be possible. So after you make your idea to a simple model though it is not complete (not finished), you need it uploaded to this forum. I expect it. |
#3
|
||||
|
||||
I think you should add a delay task before recursive calling the call subtask otherwise you end up in a loop. And if the condition is not satisfied why not do a UTILIZE tasks and use a message if the condition is satisfied to release the operator again?
|
#4
|
||||
|
||||
Quote:
could you possibly explain how UTILIZE can be used in this situation? I am trying to use a 3rd party API that takes TaskExecuter's current x and y as an input and returns one of four things: a return code acknowledging that the vehicle should keep going to its current waypoint, a new waypoint to go to, a return code meaning that the TaskExecuter has arrived to the destination and should proceed with the rest of its task, or that it has to reach the next waypoint, stop, and wait for a specified duration and then try again. I thought a simple non-coordinated task sequence could be a good fit if I can recursively call a subtask from itself. Thanks! Vadim |
#5
|
||||
|
||||
you are right in this situation with a third party API it's probably not a solution unless you have access to the code. If it was done in Flexsim you could send a message when the AGV arrived and then select what it should do and in that case do freeoperators() if it should continue.
But in this case that doesn't work, but I wouldn't use callsubtaks but again do the utilize task and call a loop that checks when to continue, because to use the callsubtasks you have to create a tasksequence and dispatch it, so it keeps generating tasksequences and filling up the tree (so memory). A simple loop will not do that. Be aware that Flexsim is single threaded so it will lock up completely when you do things like this. |
#6
|
||||
|
||||
Hi Steven,
thanks for your replies. I do have access to the source code (if you are referring to the API in question). How can I use it to my advantage? More general question: is it possible to: 1)create a task sequence 2)call subtask 3)in subtask delay until a message arrives 4) return from the subtask and carry on with the main task If I can do that, once I am in the subtask, I can send messages back and forth between the entity creating the task sequence and the AGV until it reaches the final waypoint, and then return from a subtask and continue with the main task picking up or dropping off a flowitem or whatever else has to happen there. It would also be interesting to know if it is possible to pause the execution of the task until an event occurs (e.g. a message arrives). In this case I can delegate moving the vehicle to a different object and let it "unfreeze" the sequence after it is done its job by sending a message back. Regards, Vadim |
#7
|
||||
|
||||
Yes what you want is possible. In the callsubtask create a tasksequence with a utilize task (and if you want,another callsubtask)
Then when you receive the message use freeoperators() to let the TE continue, it will then automatically continue with new tasksequence and after that continue with the original one. Please read the user manual about the callsubtask again. |
#8
|
||||
|
||||
After some tinkering I got the model working. Please have a look.
The interesting part is in the OnMessage callback for the task executer. If there are any ways to improve the performance, please let me know how. The dll has to be one directory above the model. If not perhaps this model will save some effort to somebody who has to solve a similar problem. Regards, Vadim |
#9
|
|||
|
|||
looping TS using MILESTONE
It might be worth trying to make the attached concept work in your situation. You can use a MILESTONE task type to repeat a series of tasks if the task sequence is preempted. The dirty trick is to use changetask() to modify the coordinates of the TRAVELTOLOC before it is repeated. Lots of nodes are still created and destroyed, but at least they don't accumulate during travel as with the sub task approach.
|
The Following User Says Thank You to Kris Geisberger For This Useful Post: | ||
Vadim Fooks (07-18-2012) |
Thread | Thread Starter | Forum | Replies | Last Post |
Looping command in Flexsim | Manoj Kumar | Q&A | 10 | 02-20-2012 07:31 AM |