I am at a customer place and thinking about a logic about the box passing. I am afraid that I have not reached out to an clean solution yet.
Problem statement:
There are two points from where boxes can come on a path. pointA & pointB. All I want is to figure out how to make sure that the boxes do not collide if they come from different paths. Pictorial representation is attached for the problem. I am free to put sensors on the path to know whether box has come or not.
In the image I have attached, there are 3 sensors, s1, s2, s3 which tell me that if there are any boxes in front of them or not. 
This is what I have thought of till now. If there is any box in front of s3, stop box at s1 and let box at s3 go. As soon as box at s3 reaches to s2, I start moving box at s1. Please write me if I am not clear on this.
Problem I see is if multiple boxes, say 2 boxes box1 & box2, come together at s3 separated by minor space. In my logic, box1 at s3 would stop the box at s1, which is fine. Along with box1, box2 would also go from s3. Whenever sensor at s2 sees that box1 has reached s2, my logic starts moving box at s1 as well and thus box from s1 and box2 would collide.
How do I make clean logic for this problem so that boxes do not collide.
I know it is difficult to explain. I am very happy to write any clarifications, if needed.
P.S. Tagging C++ since I am coding in C++ for this. Admin, please feel free to add the right tags.