Further Investigations into LSynth and Treads

After posting my “tutorial” articles on the LEGO MINDSTORMS EV3 Facebook group I started to look in to how LSynth does its magic, and now have a greater understanding of what the issue with treads is. I’ve worked through how the lsynth.mpd file works, including reading the source code. I’ll attempt to describe what I’m seeing.

Constraint  Radii

The lsynth.mpd file is used to describe the parameters around the various elements, in this case Bands, and Band Constraints. Each constraint is defined by its type, radius, orientation etc. The two sprocket types I’m interested are listed as:

0 // Technic Sprocket Wheel 25.4
1 25 0 0 0 1 0 0 0 1 0 0 0 1 57520.dat
0 // Technic Sprocket Wheel 40.4
1 50 0 0 0 1 0 0 0 1 0 0 0 1 57519.dat

This states that the small sprocket has a radius of 25 LDU, and the large 50. This is incorrect, since the large sprocket is 1.6x that of the small, not 2x. It is in fact the small sprocket that is wrong, it ought to be 32 LDU. The sizes as per the LSynth file can be seen in the image below:

Sprocket Radii as defined by lsynth.mpd.
Sprocket Radii as defined by lsynth.mpd.
Band Scaling

The loop of treads is defined in the lsynth.mpd file as a band of fixed size elements. Two parts are defined: one for going between, and the other for wrapping around, the constraints – i.e. the sprockets. The band definition includes a scaling value which is used for working out how many elements will be needed between constraints, i.e. the straight line segments. For the large treads this is defined as:

0 FILE TECHNIC_CHAIN_TREAD_38.ldr
0 TECHNIC_CHAIN_TREAD_38 SYNTHESIS DEFINITION
0 Name: TECHNIC_CHAIN_TREAD_38.ldr
0 Author: Willy Tschager
0 Unofficial Model
0 SYNTH BEGIN DEFINE TECHNIC_CHAIN_TREAD_38 BAND FIXED 0.03571 8
0 // Technic Chain Tread 38
1 0 0 0 0 0 1 0 0 0 -1 -1 0 0 57518.dat
0 // Technic Chain Tread 38
1 0 0 0 -32 0 -1 0 0 0 1 -1 0 0 57518.dat
0 SYNTH END

The scale value here is 0.03571. This should be 1/N where N is the LDU length of the segment unit, i.e. tread, in LDU. The value of 0.03571 gives N=28 LDU. This is also wrong. The distance between the centre of the hooks and pin on the treads is 30 LDU, so the scale value ought to be 0.03333. This incorrect scaling value is what leads to the “compressed links” I referred to in the previous blog. The original value, and one of 0.03333 can be seen in the image below:

Top = 0.03571 (original), Bottom = 0.03333 (corrected).

An additional benefit is that the parts around the sprocket are also now the correct number.

Numerical Accuracy

Unfortunately it appears that numerical accuracy has a noticeable influence on the appearance. With the corrected scaling value for the treads, wrapped around a single sprocket the result looks like below:

Numerical accuracy.
Numerical accuracy.

As can be seen, the tread pins don’t sit quite in to the sprocket’s notches. I would put this down to rounding errors.

There is another issue in the code which doesn’t actually affect things, but I will comment on it. The code works out how many treads are needed on an arc, i.e. to go around the sprocket, as the length of the arc divided by the length of the tread (as deduced from 1/scale value):

n = type->scale * 2 * pi * k->radius + 0.5;

This is making the assumption that the tread would be “bent” around the circumference of the sprocket, when in fact it is a chord between two notches. In reality this difference between arc length and chord length doesn’t have an effect.

Final Thoughts

Again, I’m not knocking LSynth – I’d be lost without it for making up cables. I just thought I’d investigate why I never seemed to get bands of treads right with it. My “fixed” lsynth.mpd file has made a difference as things are now better, but the perfectionist in me would prefer that the treads sit in the notches, so I’ll continue doing them manually.

1 thought on “Further Investigations into LSynth and Treads”

Leave a Reply

Your email address will not be published. Required fields are marked *