question

Emily K avatar image
0 Likes"
Emily K asked Felix Möhlmann commented

Get moving direction of AGV

Hi @Felix Möhlmann,

I would like to identify the moving direction of AGVs when they enter the broad phase.

If they are moving in the same direction, turns green and do nothing.

If they are moving in different direction, turns to red, and compare their distancetotravel() to decide they priority

I reference to your post, I guess this could help to achieve what I want to do. As I don't have a strong coding fundamental, I am not sure if I am writing in a correct way, hopefully to get some advices from you.

Thanks!

1667377971221.png

AgentSystemTrial_221102.fsm

FlexSim 21.2.4
proximity agent systemagv travel directionagent system
· 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.

Kavika F avatar image Kavika F ♦ commented ·

Hi @Emily K, was Felix Möhlmann's answers helpful? If so, please click the "Accept" button at the bottom of the 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 ·
Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Felix Möhlmann commented

If both task executers are travelling on the same path when the proximity triggers (which seems to be the case with the way you intend to use this), then you should be able to use the "fromDist" and "toDist" values from the current travelPath node.

1667413494861.pngIf you calculate the difference of those values, the sign (+/-) of the result will correspond to the travel direction.

You should be able to reuse most of the code from the post you linked to. Note though that that code uses "current" to refer to the task executer. Looking at your model, you are using "obj" instead, so you have to adjust the code accordingly. You also don't get a reference to the navigator node ("avgNavNode") at all and instead use "agent.object" a lot. That is just a pointer to the task executer object and not the node you need.

1667413982643.png


1667413494861.png (44.8 KiB)
1667413982643.png (9.6 KiB)
· 8
5 |100000

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

Emily K avatar image Emily K commented ·

I have defined the otherAGV.

Object otherAGV = neighbor.object;

Is this the code I could get the node of agent itself and its neighbor?

treenode agvNavNode = obj.find("AGVNetwork>variables/agvs");
treenode agvNavNode = otherAGV.find("AGVNetwork>variables/agvs");

I determine the moving direction by "toDist.distAlong" minus "fromDist.distAlong", however nothing changed in my model..

Could you please give me some advices, thanks.AgentSystemTrial_221103.fsm

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Emily K commented ·

".find" searches for nodes within the node it is used on. The AGVNetwork is a subnode of the model itself, so

obj.find("AGVNetwork>variables/agvs");

won't find anything, since "obj" is not the model. Even then, this only points to the node that contains the individual agv nodes as subnodes, so you would have to extend the path to point to the correct one.

1667460589047.png

The faster method, that I use in the other post, is to follow the link node that connects to the agv node in the navigator from the task executer's own attribute tree.

So I use the find method to go to that node and then use the "+" in the path to follow the link it contains, which leads directly to the agv node in the navigator's tree.

1667460154879.png

obj.find(">variables/navigator/1+");

In the attached model I mostly copied the code from the other model up to determining the current paths of the agvs. I adjusted the task executer references to "current" and "otherAGV" so they fit the code.

Afterwards I check if they are on the same path, if the direction is different (and non-zero) and if the pending travel distance of the current agv is larger. If all of this is true, the current agv is paused by dispatching the utilize task to it, as you propose in your code.

agentsystemtrial-221103_fm.fsm

0 Likes 0 ·
Emily K avatar image Emily K Felix Möhlmann commented ·

Thanks for your advices.

Could I ask what is the relationship between them?

1667472732989.png1667472747451.png

1667472819000.png


In my previous model(agentsystemtrial-221102.fsm), If I define that

Object obj = agent.object;

Is it possible to navigate the node I want if I use the code below?

obj.find(">variables/navigator/1+")
0 Likes 0 ·
1667472732989.png (12.8 KiB)
1667472747451.png (2.8 KiB)
1667472819000.png (8.4 KiB)
Show more comments
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered
I would use a vantage point far outside my layout and compute distances of all AGVs from their current location and a location a few time units before from their kinematic node to get a heading to or from this vantage point. Then I can identify if two AGVs are going to collide or not.
5 |100000

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