This project has moved and is read-only. For the latest updates, please go here.

Creating the illusion of a conveyor belt

Topics: Developer Forum, User Forum
Aug 17, 2008 at 9:46 PM
Hi guys!

First of all, thanks for a great physics engine! It's clear that there has been put alot of work and effort into this, and i'm really thankful for you putting it in everybodys hands!

Okay, I have a problem. I'm trying to create the illusion of a conveyor belt. I'm using a rectangular body and geometry, and want boxes landing on it, to be transported like if it were a real conveyor belt. How would you go about and do that? - Right now, I've made my own collision handler on the "belt" which check if the collision is between the belt and a box. If it is, it applies a force on the local point of the collision. However, this does not work to my complete satisfaction. Reason 1: The acceleration looks wrong. The box should accelerate imediately when it lands on the belt, maybe even roll over because of the acceleration. Reason 2: The box keeps accelerating. If the conveyor belt is fairly long, the box will keep accelerating. I suppose there is a way I could keep the box from accelerating by checking the velocity before applying the local force upon impact. But I was wondering if there would be a better way than using forces upon collision.

What do you guys say, is there a better way to accomplish this? - Thanks in advance!

Best regards
Aug 18, 2008 at 5:35 PM
I've seen a conveyor belt before in a demo of another physics engine for flash. Can't find it right now.

The way they did it was to make a real belt made up of revolutejoints. They had a space between each body so that a gear could rotate the belt.
There is a lot of tweaking going into stuff like this, but the result should be just what you want. (with the falling over of objects on the belt and so on)
Aug 19, 2008 at 9:00 AM
Thank you for your reply, genbox!

That's true, I could do that. However, my aim right now is to create an illusion of a conveyor belt, and thus not a 'real' conveyor belt. My decision to not make a real conveyor belt, was that it would possibly be too unstable in the simulation. But I know that might not be true. I guess I should try and see if I can make it work.

However, I'm still very interested in any suggestions on how to create a conveyor belt, without actually creating a belt of joints, but by just having a rectangle that makes objects on it behave as if it was a conveyor belt.

Best regards
Aug 19, 2008 at 1:04 PM
There are other approaches.  You could substitute the conveyor belt for a series of rollers that rotate at a constant rate.  If the belt is embedded in the ground, you could just make a long rectangle and slowly move it to the right, snapping back to the other side once it reaches the end.  Finally, you could have a bunch of squares just following a path where the belt would be.  I'm not sure how to do either of the last two without cheating the engine, so I'd say go with the first.
Aug 19, 2008 at 2:53 PM
Modeling the belt from a loop of animated rectangles is probably the best bet from the engine point of view, but what you are trying to do with the collision handler should also work. When you apply the force, it will take time for the object to get up to speed, as if you started to push a car in neutral. In this case, you want the acceleration to be immediate, so apply an impulse instead. Ignoring other factors like linear friction and such, this should work. To maintain a constant speed, you may have to manually modify the linear velocity vector, but I'm sure your approach will work.
Aug 21, 2008 at 3:26 AM
I am working on a tank simulation that uses the true conveyor belt style for my tracks. I have tested small belts around wheels and they seem to work quite well. Farseer can handle quite a few bodies and some fairly complex geometry without lagging so depending on how realistic you are going for... should decide how you implement your design.

Personally I would go with the rollers and just make some form of 'fake' rendered belt. Or use impulses on contact, but that would be more unstable then just making a real conveyer belt.
Aug 21, 2008 at 9:35 AM
Thank you all for replying! Your suggestions are all very good, and they gave me just what I needed.

I'm still trying to create a 'real' conveyor belt, as per genbox's suggestion. However, I haven't had time to really dig into this yet.

If that won't work, I think I'll use Yota's idea with a belt made up of invisible moving rectangles.

I'll let you know how it works out! - Really, thank you all for your help! I really appreciate it!

Best regards
Aug 21, 2008 at 9:46 AM
Oh, by the way Matt, which shape does your wheels have? Are they star shaped or completely circular? While thinking about how to make my conveyor belt, I'm not sure what shape would work best for the wheels to pull the belt around. I would like to avoid gaps between the individual sheets of the conveyor belt, to make sure the items i want to transport does not fall inbetween two sheets. But if I don't have any gaps, I guess the only wheel that could pull the belt would be a completely circular wheel. But would that be strong enough to pull the belt?

How did you make your belt for your tanks, Matt?
Aug 22, 2008 at 5:45 AM
I used circles for my wheels, but there are many different options. 

1. Round wheels with a track with no spaces. Be sure to set all your track pieces to not collide with each other. Be sure to set any friction coefficients to max between the wheels and track.

2. Round wheels with a sprocket at one end and a track with spaces. This works pretty well in a tank model. Might be to much for just a conveyer belt.

3. Round wheels with a sprocket and no spaces. Make the track like #1 but with every other piece not colliding with the sprocket. This would give you a smooth belt with great power. I have not tried this method but it sounds great and is on my to do list.

If you need better descriptions just let me know I'll draw up some diagrams.
Aug 27, 2008 at 11:42 PM
Matt, when you create your belt, do you place each individual sheet in it's correct position? - I suppose that would require some use of trigonometry, to calculate the rotation and position of the sheets at the ends where they 'turn around'? Have you figured out a formula or could you maybe show me some pseudo code on how you accomplished this?
Aug 28, 2008 at 1:09 AM
I had perfected a method for creating sheets around a capsule (2D of course) shape. However when my previous laptop died i lost all my code.

If all you need is a capsule shape you can create a 4 block section of code that will create the perfect track for you.

1. I always started at the left top of the capsule and using the length of the capsule minus the caps placed sheets linearly along.

2. Once you reach the first turn to have to switch to circumference style placement algorithm. I used a standard circle drawing algorithm but only used half the circle. You can figure out how many degrees each sheet needs by dividing 180 by the length of a sheet.

3. Do the same as 1. but from right to left.

4. Same as 2. but from bottom to top.

5. Make sure you place that last joint or your belt will be a rope ;)

I was working on making an belt that could follow any curve but that was lost with the computer as well. Something I learned while coding all this was if the size of your sheets is not to important then find the real perimeter of the shape your going to wrap your belt around and divide it by how many sheets you want in your belt. That will give you the perfect sheet length. I will say it was not easy to get the belt to fit a capsule. If you need a better description just let me know and I'll draw a diagram of how I did it. Maybe if your not in a rush I could help you out next week sometime.
Aug 28, 2008 at 9:09 AM
Edited Aug 30, 2008 at 4:58 PM

Thank you, for your explaination, Matt! – I’ll try the “Wrapping around a capsule” approach. :-)

I’m not in a rush, so let’s just see how far along I am next week. Thank you for your helpfulness!

Aug 30, 2008 at 12:33 PM
Edited Aug 30, 2008 at 4:58 PM

Alright, now I got the code to create sheets around a capsule shape and connect them all with revolute joints. However, when I start the simulation, the belt keeps bouncing up and down at the middle, both at the top and bottom. Did you experience this? Did you find a way to remove the bounciness?

I’ve tried setting the joint softness to a very low value, and it definately helps, but it still bounces and keeps doing it. It never comes to rest. Is there a tweak somewhere I can use to make the belt rest? In a desperate attempt, I also tried changing the bias factor. Although I could see something changed, I can’t exactly tell what the bias factor does. Can anyone enlighten me? :-)

I wanted to show a picture of the problem, to make it clear. I’ve uploaded a picture to my website, you can see it here:

Aug 30, 2008 at 10:57 PM
Create a static body and geometry "rectangle" in the center between the circles. Make sure you set the restitution values to be very low or 0. Also make sure you set the friction of your wheels high and the friction of everything else fairly low.