ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 07-08-2012
Vadim Fooks's Avatar
Vadim Fooks Vadim Fooks is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 67
Downloads: 26
Uploads: 0
Thanks: 50
Thanked 24 Times in 13 Posts
Rep Power: 118
Vadim Fooks will become famous soon enough
Default 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  
Old 07-09-2012
syseo's Avatar
syseo syseo is offline
Flexsim User
 
Join Date: Aug 2007
Location: Korea
Posts: 290
Downloads: 439
Uploads: 0
Thanks: 249
Thanked 63 Times in 41 Posts
Rep Power: 211
syseo has a spectacular aura aboutsyseo has a spectacular aura about
Default

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  
Old 07-09-2012
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

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  
Old 07-09-2012
Vadim Fooks's Avatar
Vadim Fooks Vadim Fooks is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 67
Downloads: 26
Uploads: 0
Thanks: 50
Thanked 24 Times in 13 Posts
Rep Power: 118
Vadim Fooks will become famous soon enough
Default

Quote:
Originally Posted by Steven Hamoen View Post
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?
Hi Steven,
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  
Old 07-09-2012
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

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  
Old 07-10-2012
Vadim Fooks's Avatar
Vadim Fooks Vadim Fooks is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 67
Downloads: 26
Uploads: 0
Thanks: 50
Thanked 24 Times in 13 Posts
Rep Power: 118
Vadim Fooks will become famous soon enough
Default

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  
Old 07-11-2012
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

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  
Old 07-17-2012
Vadim Fooks's Avatar
Vadim Fooks Vadim Fooks is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 67
Downloads: 26
Uploads: 0
Thanks: 50
Thanked 24 Times in 13 Posts
Rep Power: 118
Vadim Fooks will become famous soon enough
Thumbs up

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
Attached Files
File Type: zip external_path_planner.zip (192.6 KB, 80 views)
  #9  
Old 07-17-2012
Kris Geisberger Kris Geisberger is offline
Flexsim Canada, Forum Moderator
 
Join Date: Aug 2007
Location: Canada
Posts: 209
Downloads: 54
Uploads: 1
Thanks: 99
Thanked 389 Times in 133 Posts
Rep Power: 451
Kris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud of
Default 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.
Attached Files
File Type: fsm looping TS using TASKTYPE_MILESTONE.fsm (31.8 KB, 87 views)
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


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.