question

Jared T avatar image
0 Likes"
Jared T asked Joshua S answered

Question on Robot Palletizing

Hi, I'm new to Flexsim hence if possible kindly teach with example. Thank you.

1) Currently I am building a palletizing layout where robot is picking and placing a sheet onto a pallet before placing cartons onto a pallet (each layer consist of 5 cartons). I had used the coding from the forum where the coder had coded using 5 tokens method. But however as you could see from the model, on the first layer there is only 4 cartons instead of 5 due to the the first pick is sheet instead of carton. Is there any way to edit the coding in a way where it will ignore the first sheet with the token method?

2) As the carton is being stacked up, the robot arm get collide with the stacked carton. How can i avoid that?

layout.fsm

FlexSim 18.0.3
palletizingrobot picking
layout.fsm (750.6 KiB)
5 |100000

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

1 Answer

Joshua S avatar image
1 Like"
Joshua S answered

Replace your code with the one below, I didn't change a whole lot so you can compare, but this should fix your first problem. The Problem was since you were adding a slipsheet as well, it was reading that as the last object placed. so in essence it was reading it as the first bag.

Object item = i;
Object current = c;
Object lastitem = item.prev;
/**Custom Packing Method*/
int	Layer = current.subnodes.length / 5;
double LayerPos = current.size.z;
int test = current.subnodes.length;




if(current.subnodes.length > 1)
{
	test = current.subnodes.length-1;
	Layer = (current.subnodes.length-1) / 5;
	LayerPos = (lastitem.location.z) + lastitem.size.z;
}


int EvenLayer = Layer %2;


if (current.subnodes.length==2)
{
	item.setLocation(0, 0, lastitem.location.z + lastitem.size.z);
	return 0;
}




if(test%5 == 1)
{
	if(!EvenLayer)
	{
		item.setLocation(0, 0, LayerPos);
		return 0;
	}
	else
	{
		setrot(item, 0, 0, 90);
		item.setLocation(-100, -100, LayerPos);
		return 0;
	}
}




if(test%5 == 2)
{
	if (current.size.x - (lastitem.location.x + lastitem.size.x) >= item.size.x) 
	{
		if(!EvenLayer)
		{
			item.setLocation(lastitem.size.x+lastitem.location.x, lastitem.location.y, lastitem.location.z);
			return 0;
		}
		else
		{
			setrot(item, 0, 0, 90);
			item.setLocation(lastitem.size.y+lastitem.location.x, lastitem.location.y, lastitem.location.z);
			return 0;
		}
	}
	else
	{
		test = 1;
		item.setLocation(0, 0, lastitem.location.z + lastitem.size.z);	
	}
}	




if(test%5 == 3)
{
	if(!EvenLayer)
	{
		setrot(item,0,0,90);
		item.setLocation(-100, -600, lastitem.location.z);
		return 0;
	}
	else
	{
		setrot(item, 0, 0, 90);
		item.setLocation(lastitem.size.y+lastitem.location.x, lastitem.location.y, lastitem.location.z);
		return 0;
	}
}




if(test%5 == 4)
{
	if(!EvenLayer)
	{
		setrot(item,0,0,90);
		item.setLocation(300, -600, lastitem.location.z);
		return 0;
	}
	else
	{
		item.setLocation(0, -600, lastitem.location.z);
		return 0;
	}
}




if(test%5 == 0)
{
	if(EvenLayer)
	{
		setrot(item,0,0,90);
		item.setLocation(700, lastitem.location.y, lastitem.location.z);
		return 0;
	}
	else
	{
		item.setLocation(lastitem.size.x+lastitem.location.x, lastitem.location.y, lastitem.location.z);
		return 0;
	}
}
item.setLocation(0, 0, lastitem.location.z + lastitem.size.z);
5 |100000

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