Tank track rotation

Little Video showing the tank spinning and tracks staying as they should be: :spin:

It’s me playing the guitar by the way, perhaps I should stick to the day job, not that I have one…

It seems that I must use the Execute Trigger settings in AN to prevent objects moved by “delta” distances from getting out of sequence. I will look at the main system with the curves, tomorrow, once I sober up. :yes:

Here’s the node tree for this video:


And the script code, this does not do everything, just straight lines and spinning:

if frm < 2:
    obj.location.x = 0
    obj.rotation_euler.z = 0
    trk_l.location.x = 0
    trk_r.location.x = 0
else:
    obj.location.x = obj.location.x + delta
    obj.rotation_euler.z = obj.rotation_euler.z + (-rad * 1.25)
    
    trk_l.location.x = trk_l.location.x + delta
    trk_r.location.x = trk_r.location.x + delta
    
    if rad > 0:
        trk_l.location.x = trk_l.location.x - (rad * wid)
        trk_r.location.x = trk_r.location.x + (rad * wid)

Note that the tracks & turret are zeroed at the start of the animation, you cannot run these “delta” animations backwards and expect objects to return to their start positions, “obj” is the tank turret BTW. :no:

Simple stuff for these options, needs a bit more code to follow a curve, that you will get later, once testing is complete. :eyebrowlift:

Cheers, Clock. :RocknRoll:

Now, I am going to sleep-off the booze… :stuck_out_tongue:

Wow clockmender, I am amazed at how much effort you put into it. My week was unfortunately busy enough that only now I found time to catch up.

Actually I kind of moved on, meaning I sort of gave up on this topic, being resolved to animate the tracks independently from the hull by hand.

I have to admit that right now I cannot find the patience to think through your endeavours here; however, judging from your videos you seem to be making steady progress, so I would like to test it myself once it is done… :wink:

That music on the videos… was that really you or your famous robot? (Yes, I have already followed some of your threads here… :p)

Booze during the day? Or you are not in Britain right now? Anyway, all the best, young man!

Actually, having the track pads distortion free is really easy. You just have a simple plane (or a long strip of planes) as the object connected to the curve, but have these planes not rendered. As each of those pad placeholder consists of only one face, they do not get distorted. Then you parent the real pad to this plane as duplifaces.

@Estajxo - yes day time drinking I am afraid to admit… Thanks for the kind words and the heads-up on the track pads, I now have a method that works with AN, the trick that finally clicked everything into place was to use “Execution Triggers” rather than “Execute on Frame Changed” The proof:

Script and blend file to follow if anyone wants it, just let me know here and make payments in beer! :stuck_out_tongue:

Node tree:


Note the Execution Triggers for “fixer” object location and rotation.

Cheers, Clock. :eyebrowlift:

Hej, judging from the video this looks really solid!
Yes, I would like to have a look at the blend file and play around with the tank. Not sure when I will find the time to have a good look at your nodes, and if I will even be able to understand all of it.
As for the payment… the shipment is the issue here, maybe I can model you some and send you the blend file? :stuck_out_tongue:

@Estajxo: Give me a couple of days and I’ll clean up the file a little, just get rid of all the unwanted debug stuff.

Cheers, Clock.

Set up a fund me page and I am there. :slight_smile: Real nice work.

Thank you very much Richard, but the tax man would then chase me… :evilgrin: Believe it, or not, I do this for fun and to keep my ageing mind active.

Here is the last “My Little Tank” video:

There are some “Camera Shutter” issues, where tracks appear to be not moving or going backwards, these do not show if I use bigger pads, I guess motion blur is the answer, or vary the speed of the tank. :eyebrowlift2:

And some pictures of the node tree:


This bit above moves the rollers and the next bit:


Does all the rest.

This is the most complicated bit:


I have used an armature as Blender became “Blundered” when rotating the tank on the curve between pointing at 9 O’clock and 12 O’clock, for some entirely unknown reason it suddenly decided that a negative value of -2.4 Rads would suddenly became 0.9 Rads - most odd, but using two bones sorted that so I guess there is a bug in Matrix_World.Decompose() routine.

I should have the file cleaned and ready for anyone who wants it by the end of the week, Mrs. C has to go into hospital for a heart problem (not serious), so I will be away for a couple of days. The file was done with Blender 2.79 and Animation Nodes 2.0 - these will be required to make it work. I have used all standard AN nodes, but could have saved some complicated Expression Nodes if I had used some of my own nodes. :yes:

Cheers, Clock. :wink:

Hi Mr. Mender,

I also have the feeling that Blender still is a little bug-ridden, when I try to do something a little more specific, out of the usual routine; like using a transformation node where something is dependent on a rotating bone in pose mode. But that is another topic.

The nodes look clean already, but take your time to make it perfect! :eyebrowlift:

May I ask about your odd choice to make your tank golden? Is it a reference to something? It reminds me a little bit of a James Bond tank, similar to the golden gun or so.

All the best this week!
Eric

Hi Eric,

Thanks for that, I have been playing a little with the setup and have simplified it a little to make it more understandable - well a bit more anyway. I have taken some of the stuff out of the script and added it to Expression nodes, like the bit that works out the curve radius so the script can adjust the track speeds so they don’t slide on turns. The only bit that I am still looking at is when you turn the tank 180 degrees, then run it back down the curve again, whatever I do the tracks run backwards! Annoying, but in the end I might just say “Don’t do that for now”, otherwise everything seems to be fine and I will get the file to you shortly. I am cooking another video “The Director’s Cut” using the new system and will post that when it finished.

Let me know what this AN problem you have is, I am quite good with AN for mechanical/music stuff and have made my own “bone” nodes that really help here. Post me a blend file and I will take a look for you. Rotating bones in pose mode often screws other things up, one way round this is to get the bones matrix values, rather than transform values as the former are in World units, but you must add any offset for the Armature Object (I also found that out by trial and error) so, an expression like"

Amature.pose.bones[‘crank’].matrix.decompose()[1]

Returns a Quaternion (irrespective of what the bones rotation mode is) of what the bone “crank” is doing in World units, rather than its transforms, which might not have moved. If an object is parented to that bone, its transform will not change for location, or rotation, whereas using:

Object.matrix_world.decompose()[0]

Will return a Vector of where the object is in World space. That is not in the AN docs by the way, I found it by experimenting. You can simply type these expressions into an Expression node, adjust the output to what you are outputting and away you go.

On the matter of the tank being gold coloured, that can be easily explained by the comment from @Gumboots in my signature: “You are completely bonkers.” just about sums it up. It also explains the exploits of my robot, my other characters and a lot more.

Mrs. C is home again and in much better shape than we thought, so that is brilliant news.

Cheers ,Clock.

OK folks, the final word on my development, for now - how is that even possible???:stuck_out_tongue:

I have simplified the node tree:


This bit does everything apart from the gears and rollers, which have not changed from my previous, but one post. By now you should all understand that bit. :eyebrowlift:

I have moved the radius calculation out of the script on onto an Expression node, the formula is this:

(abs(x) > 0.001) * (y / cos((pi / 2) -x)) / 2

Tha should all be self-explanatory Ha Ha, so the first bit is a conditional statement, if absolute (always positive) X is greater than 0.001 it’s either True of False, then you rearrange the Cosine Equation, what do you mean you’ve bloody-well forgot it tut, tut - Cosine = Adjacent divided by Hypotenuse, so this works out the radius of the curve the tank is travelling around. This is used to slow the inside track and speed up the outside track. :eyebrowlift2:

The Angle of steer is calculated by two bones, one of which has a Track To constraint the other doesn’t, so I measure the angle in World Space between them to get the input (x) in the Expression node - simples!

Here is the ball-achingly-bad video of the tank in motion:

Here is the code in the script, much simplified from the first version:

if frm <= 2:
    # Zero tracks at the start.
    trk_l.location.x = 0
    trk_r.location.x = 0
if abs(radius) == 0:
    # Going straight.
    trk_l.location.x = trk_l.location.x - delta
    trk_r.location.x = trk_r.location.x - delta
elif radius < 0:
    # Left turn.
    fac = (abs(radius) - spc) / abs(radius)
    trk_l.location.x = trk_l.location.x - (delta * fac)
    trk_r.location.x = trk_r.location.x - (delta * (1/fac))
else:
    # Right Turn.
    fac = (abs(radius) - spc) / abs(radius)
    trk_l.location.x = trk_l.location.x - (delta * (1/fac))
    trk_r.location.x = trk_r.location.x - (delta * fac)
if hull_d != 0:
    # Spinning on its centre.
    trk_r.location.x = trk_r.location.x - (hull_d * spc)
    trk_l.location.x = trk_l.location.x + (hull_d * spc)

PM me if you want the blend file and I haven’t sent you a copy yet, you never know I might just do that, you can always re-create it from the info in this post, don’t forget “Execution Triggers”. :eek:

Cheers, Clock. :eyebrowlift:

Haha, that music, that celebration of the little tankie! :smiley:
I will take a look at it at the weekend, when I will have time.
Cheers!

An after-thought:


This is a more efficient way to drive the rollers and gears, by using two iterators rather than two loops. I still need a separate loop feed for each side of the tank as the tracks don’t move in unison.

Cheers, Clock. :wink:

Or you could use my own Nodes, including the new one: :smiley:


It will be on my Old-GitHub later on this weekend once I have finished testing and drinking and drinking and testing… :stuck_out_tongue:

This gets easier every time I look at it. :eyebrowlift:

Cheers, Clock.

PS I need to try this on a proper tank I think.

I tried my own version - as I was thinking that the AN solution works for the case of a tank driving on a flat plane - but would likely not work properly on a hill or varied terrain.

It’s not really “my” version - I followed this:

Here’s the blend file:
https://1drv.ms/u/s!AhF2VHOcCd18iCuIONHQlhZDXaYE

Press play.
The R and L character are animated with a driver that adjusts the motor speed for the left/right track.

the next step would be to hide the low poly parts with the physics and replace with nicer ones (like they did in the video)

(figured out how to attach the .blend here)
tank_v3.blend (3.01 MB)

Hej Clockie!
I took a look at your blend file and tried to understand it. Well, understanding the nodes would take much more time, but I understood that just freely grabbing and rotating the “fixer” (after deactivating the curve modifier) causes a big lag on my laptop. Apparently, you undertake some seriously demanding calculations here.
Also, I had the feeling that just skipping to the start and changing the fixer’s X location causes the treads to rotate like crazy, but I am not sure because of the lag.
Not sure what to make of and with it… :slight_smile:

@cadaei: Yes, that is the physics based approach that I tried to avoid as long as possible. :wink:
I had a short look at your file… it seems that your two controllers are not controlling anything? At least nothing else is moving when I move or rotate them. Or are they meant to be used in another way?

The controls have a driver that is multiplied against the motor target speed. So they only do something when the physics simulation is running. I have then currently keyframed to a few different positions. So planning a precise animation might be difficult with this approach - depending on how much variability there is between multiple simulation runs I suppose.

If you cleared the keyframes from the L and R objects, then positioned them to be both +1 in Y, the pressed play - the tank would go forward, you can then move them while the simulation is running (which is a little awkward). Could probably make more clever control setup, but this was quick to get the idea across.

I had also avoided the physics solution as it seemed like overkill - but I think this actually works quite well. It also seems pretty stable in that the tracks seem to work as expected.

So far I found the most difficult part is getting the tracks even spaced, and then modeling a nice fitting drive gear. But that’s likely my modeling skills being the issue.

@Cadaei: Not looked at your solution yet, I have been relaxing in the sun at last!

@Estajxo:

So, if you break it, it doesn’t work! Hmmmmm, interesting. :eyebrowlift:

Some pointers as to how in works:

  1. It uses Execution Triggers in AN, so if you set AN to execute “Always” - you break it, if you set AN to execute on “Frame Change” - you break it when you come to render animations. Hmmm don’t do that. :no:

  2. It use current and previous frame values for the position and rotation of Fix, if you just rotate the fix object in the 3D view - you break it, or it does nothing, if you destroy the spacial relationship between Fix and Target, like take off the curve mods - you break it. Hmmm don’t do that. :no:

  3. If you just grab the Fix object in any other axis than X, you break it. Hmmm don’t do that. :no:

To make it work you simply keyframe offsets of Fix object along X axis and run the animation (CTRL+A) - you don’t break it, if you then rotate Fix and keyframe some changes over some frames whilst it is stationary, the tank turns on the spot - you don’t break it. :yes:

Don’t expect it to run other than through keyframed offsets of the Fix object along it curve path, or keyframed rotations of the Fix object whilst it is stationary and then only when you run the animation. And DON’T change the execute functions for AN.

As for process times - the whole node tree runs at under 3 milliseconds on my MacBook, even with a complex model:


So the compute time for me is a tiny fraction of the frame elapse time of 42 milliseconds for a 24 fps animation. But then I don’t use Windoze…

Gentlemen both: Incidentally the rig is based on the same principles as the rigs I use for cars, bikes, buses, trucks, aeroplanes, trains, pedal cycles, etc. and they all work on hills… Maybe I should do a quick video of the tank doing a loop like an aeroplane, that might be fun. I will just alter the path curve and the tank will go anywhere I want it to…

Cheers, Clock. :wink:

EDIT:

I have fixed the issue with the tracks going the wrong way if you turn the tank through 180 degrees then move it back down the path again - the new node has a boolean input, which you can keyframe to change when you need the tracks to go the opposite way, the execute code got a little more complex. Yay!!!

Yeeehaaaaa!!! :eek:


The tracks worked all the way round, I rest my case… :stuck_out_tongue:

Cheers, Clock.

i think I have never been so entertained in being shown I was wrong before!

I am always pleased to provide some entertainment for my friends. :eyebrowlift:

I thought I heard someone say “Oi Clock you old git, what about some wheel suspension?” maybe it’s my age - I am over 80 you know, oh, wait a minute thats my weight in Kg, not my age… :eyebrowlift:

So, here is my prototype suspension and track tensioning system, all done with AN and some Clockwork Magic:

I need to work on the model detail and the camouflage a bit… :stuck_out_tongue:

And a peek at the project:


Still lots to do and I have to integrate the two systems together, but it’s a start. Note you can provide output from a loop in the form of a list, just in case anyone didn’t know that.

PS. should I start a new thread for this, rather than keep posting in my old mate’s thread?

Cheers, Clock. :eyebrowlift:

PS. Is it bad grammar to start a sentence with “So,”? I cannot decide. :no:

EDIT:

Now I have it tilted over as it should be for one track in a dip and the other on a rise:


I am using the relative positions of the wheels to do this.