How to identify the front traveller during a collision on network node path?

How to identify the front traveller during a collision on network node path?

962076751
Enthusiast Enthusiast
99 Views
4 Replies
Message 1 of 5

How to identify the front traveller during a collision on network node path?

962076751
Enthusiast
Enthusiast

[ FlexSim 19.1.0 ]

Hi ! As you can see in model 001001.fsm, when i set up collision logic for every TE, error happens.The problem is that when the Task Executors come into contact with each other, both of their "Handle Collision" triggers are fired, causing them both to stop. This is not reasonable.

Logically, when a collision happens, the front traveller should do nothing, while the travellers behind it should execute collision logic. So, we should firgue out the front traveller in a collision.

Under most circumstance, routes are more complicated. It is unknown that which traveller may come into a collision with current traveller. This means the front traveller is always dynamical to one traveller.

So , How to identify the front traveller during a collision happens between two or more travellers on network node path?

0 Likes
Accepted solutions (1)
100 Views
4 Replies
Replies (4)
Message 2 of 5

joseph_g3
Not applicable
Accepted solution
@meng L

You can determine which Task Executor is in front by checking the positions and rotations of each TE involved in the collision. Here is some custom code I added to the "Handle Collision" function of each TE in your model:

/**Custom Code*/
Object current = ownerobject(c);
Object otherobject = param(1);
treenode thissphere = param(2);
treenode othersphere = param(3);
Object thisobject = current;


int thisrotation = thisobject.attrs.spatialrz.value;
int thisxloc = thisobject.attrs.spatialx.value;
int otherxloc = otherobject.attrs.spatialx.value;
int thisyloc = thisobject.attrs.spatialy.value;
int otheryloc = otherobject.attrs.spatialy.value;


if(thisrotation > -90 && thisrotation < 90){ //Travelling right
	//Stop if left of other AGV
	if(thisxloc < otherxloc){
		thisobject.stop(48);
		senddelayedmessage(thisobject,0.5,thisobject);
	}
} else if (thisrotation > 90 || thisrotation < -90){ //Travelling left
	//Stop if right of other AGV
	if(thisxloc > otherxloc){
		thisobject.stop(48);
		senddelayedmessage(thisobject,0.5,thisobject);
	}
} else if (thisrotation > 0 && thisrotation < 180){ //Travelling up
	//Stop if below other AGV
	if(thisyloc < otheryloc){
		thisobject.stop(48);
		senddelayedmessage(thisobject,0.5,thisobject);
	}
} else { //Travelling down
	//Stop if above other AGV
	if(thisyloc > otheryloc){
		thisobject.stop(48);
		senddelayedmessage(thisobject,0.5,thisobject);
	}
}

This uses the rotation of the current TE to determine in which direction it is moving. Then, by checking its position and the position of the other TE in the collision, it can determine whether it is behind the other TE. If it is behind the other TE, it will stop.

Here is your model with this code added in: 001answer.fsm

Try changing the speeds of the two TEs so that TaskExecuter1 is faster than TaskExecuter2, and you will see that it works no matter which TE is behind.

When applying this to your model, there may still be problems when the TEs go around corners or sharp turns, but I would just adjust the shape of the collision sphere so that they detect other TEs in front of them and not to the sides.

0 Likes
Message 3 of 5

962076751
Enthusiast
Enthusiast

Thanks a lot Joseph ! I've tried as you suggested here. It is a bit complicated to avoiding collisions , and i will try some other methods to accomplish this.

0 Likes
Message 4 of 5

joseph_g3
Not applicable

@meng L

As a suggestion if other methods aren't working for you, you could always switch to using Control Points instead of collision spheres to ensure that AGVs don't collide with each other. That is what AGVs are built around and it would be pretty easy to do.

0 Likes
Message 5 of 5

962076751
Enthusiast
Enthusiast

@Joseph Gillespie ♦

I have tried using Control Points and Accumulation Path to avoid collision, but it turned out undesirably.Thank you for having a look at the question in the link below.

https://answers.flexsim.com/questions/74510/agv-system-get-stucked-without-any-error-shows-up.html

0 Likes