Cylinder won't rorate about x-axis if a cube (as driver) translates across Y-axis

I want cart wheels to roll (not slip) as a cart moves along y-axis

I first tried with a cube (acting as driver) and cylinder parented to it.
But the cylinder won’t rotate about the x-axis and the ‘Scripted Expression’ to use is not clear.

But the cylinder does rotate about the y-axis while the cube moves along the -X-axis.
I tried a scripted expression involving pi but it turns out , merely using ‘var’ works.

So my query:

  1. Why does the cylinder fail to rotate about the x-axis when the cube (driver) moves along the y-axis.
  2. what might be the best choice of Scripted Expression.
  3. Is there a better procedure?

I’d be most grateful for suggestions.

If you are using a bone to rotate your cylinder, the bone’s y axis is along its length. If you aren’t using a bone to rotate the cylinder, your cylinder may not be in it’s original orientation. Rotate things by hand, with the n-panel open, and see which values change. It would be easier to tell what’s going on if we could see a copy of the blend file. The ‘best choice’ for scripted expression depends on your actual set up, so without seeing it, it’s impossible to say what to do.

Blender’s default variable name is ‘var’, but you can change it to something more meaningful if you want. If you build complicated rigs, using meaningful names can be a lifesaver.

Is there a better way? If you are not using an armature, then yes, using an armature to animate your cart is a better way. There are some things that you can do easily with armatures that are difficult or impossible when animating ordinary objects. On the other hand, those might not be things you are planning on doing (yet).

If its just a Cylinder with a Cube as parent.

You want to set Scripted Expression to Sum value, or something else first.
Scripted Expression ignores the driver variables, unless you add them to the scripted expression.

The Cylinder is the one that will require a driver on the X Rotation.
Then you should be able to use Transform Channel, Y Location, World Space, for the Cube driver variable.

Only problem with this, if your car turns a corner, the wheels wont turn correctly.

Thanks, Dirty-Stick (what a name) and Orinoco>
The scripted expression seems to be the value of Euler rotation (in degrees) turned by wheel for ‘var’ units of distance translated by the cart. This is strictly 180*var/pi. This expression was accepted and the rotation was fine but got corrupted later, that is, the wheel was turning wildly. So I just used var.
This, as I said, works fine when the cube moves in x-direction and cylinder rolls (turns without slip) about the y-axis.
Here is the blendfile www.pasteall.org/blend/25561
Please comment.
But as I said, I want the cart to move in y-direction and wheel to turn about x-axis. This turns out to be tricky.
The cylinder won’t turn about x-axis when cube moves along y. I am baffled why. Please suggest how to do it.

By the way, the Cartoon girl has interested me too. But the original texturing can perhaps be simplified now that SS scattering is available.
Your animation is nice but a bit short. (I hope I can return to you on the Cartoon girl)

The scripted expression is the input to the driver, not a replacement for the output from the driver. The scaling is done by the driver curve. If you are going to use just ‘var’ for the expression, don’t bother with a scripted expression, but just use the ‘Sum values’ or ‘Maximum value’ option.

I want the cart to move in y-direction and wheel to turn about x-axis. This turns out to be tricky.
The cylinder won’t turn about x-axis when cube moves along y. I am baffled why.

  • You have an initial unapplied object-level 90-degree X rotation, which will cause confusion.
  • I doubt you really want your cylinder to turn about the X-axis, which would be a tumbling motion. More likely what you want is to turn about the Y-axis an angle that depends on the total distance in the X-Y plane that the cube has moved. One way to handle this is to have the cube’s X displacement become travel along a curve path. Here is something similar I did a while ago for a rolling ball: rollingball1.blend (430 KB) (hit Alt-A to play the animation).
  • You should at least have a look at Phillippe Roubal’s autodrive system.

Best wishes,
Matthew

I set the axis backwards here but i think this is what you want.

When the Cube moves the distance 2*pi X Location, the cylinder does a 360 Y Rotation.
The cube distance is added to the Frame of the keyframe, the cylinder rotation is added to the Value.
The driver reads the cube Transform Channel, X Location, and sets the cylinders Y Rotation.

http://www.pasteall.org/blend/25581
http://www.pasteall.org/pic/show.php?id=63613

Thanks, Matthew. You’ve really illuminated the underlying issues involved.
I’ll digest what you’ve said and check the links, and get back.

Thanks for your comment and especially the pic showing Graph Editor curve. I was mystified before.
But you have illustrated a cube move (along x) and cylinder turn about Y-axis.

The tricky part is how to move the cube along the y-axis and get the cylinder to turn about the X-axis.
Matthew Colett (previous comment) suggested this is not straightforward but I am baffled why.
I tried it and I get the cylinder tumbling along instead of rotating neatly.

Further to my comment above, you are right to suggest that an x-axis leads to a tumbling motion. But why?
What’s special about rotation about the y-axis with cylinder translation in x-direction?
I am sorry I could not open your file rollingball1.blend
I’d appreciate your help to open it. Would pastel.org make things easier?

As for Roubal’s Autodrive, the car drivng over a rough terrain is certainly most impressive but the PDF tutorials were written in 2006 or earlier using vers 2.49. I wish he had updated it.

I might be mistaken (need to doublecheck), but I’m reasonably sure that anything python-related (including scripted expressions) expresses angles in radians rather than degrees.

Furthermore, looking at your file, you might note that your cylinder’s local coordinate system is not in line with the global coordinate system. That is, your cylinder’s local y axis runs in the same direction as the global z (this is what MCollett was driving at)

And just to throw one more wrench in the mix… you can probably achieve similar results using the Transformation constraint instead of drivers. It’s not as flexible, but for a simple case like this, it may be faster to set up.

That’s the way your model cylinder naturally rolls from its initial position; anything else involves additional rotation around global Z.

I am sorry I could not open your file

Are you using the latest version of Blender? Anyway, on further thought, I suspect that the way I handled the rolling there probably won’t solve your current problem.

Orinoco’s original suggestion to use an armature instead of object-level constraints is probably the best one. If you ignore the fact that the interface looks different, I think you will find the Autodrive tutorials are still relevant.

Best wishes,
Matthew


Thanks so much for all the suggestions. The actual problem is a cart being pulled by a lady. She is shown above in a pose ready to pull (don’t mind the bikini).
Matthew I am using the latest version 2.69. I have done the animation about her bending, holding the handles and rising and then pulling. The handles and wheels have the same axis of rotation.
The problem remaining is get the wheels to roll as she pulls.