Jump to content

Moving items via Lua from one place to another


Empfohlene Beiträge

Hi to all me fellow members

On one of my layouts I have two gantry cranes. Each one will lift 3 x 40' containers from the ground onto the train and then lift 2 x 20' containers on to each of 2 articulated truck/trailers.

Both gantry cranes have the Z rotation element set at 90 degrees

Each of the cargo pads on the train have their Z rotation set at 90 degrees as do the cargo pads on each of the trailers

The containers are similarly set at 90 degrees in the container port.

After each has loaded the Z element for each container remains at 90 degrees.

After completing their respective journeys both train and trucks stop whilst the containers are returned to the container port using Lua script. When this was first performed I made a note of the degree setting for each container once back at the container port and set about making the necessary adjustments for each container in it's respective Lua script. On the following operation all was well and each of the containers ended up back at the container port all showing 90 degrees. However on the next pass there was a variance of 0.01 with most. I reset all of the containers to 90 degrees and sent the vehicles and train on there merry way. The following results showed a variance between 89.99 or 90.01 or 90.02. My best results are that I can complete 3 cycles before things begin to loose accuracy.

I cannot explain why this might be happening, has anyone else come across this anomaly and if so how did you resolve it.

Puzzled Pete

 

Hallo an alle meine Kollegen

Auf einer meiner Anlagen habe ich zwei Portalkräne. Jede hebt 3 x 40-Fuß-Container vom Boden auf den Zug und hebt dann 2 x 20-Fuß-Container auf jeden von 2 Sattelschleppern/Anhängern.

Bei beiden Portalkränen ist das Z-Drehelement auf 90 Grad eingestellt.

Die Z-Drehung der Ladungspolster auf dem Zug ist auf 90 Grad eingestellt, ebenso wie die der Ladungspolster auf den einzelnen Anhängern.

Die Container sind im Containerhafen ebenfalls auf 90 Grad eingestellt.

Nach dem Beladen eines jeden Containers bleibt das Z-Element für jeden Container auf 90 Grad eingestellt.

Nach Beendigung ihrer jeweiligen Fahrten halten sowohl der Zug als auch die Lastwagen an, während die Container mit Hilfe eines Lua-Skripts zum Containerhafen zurückgebracht werden. Als dies zum ersten Mal durchgeführt wurde, notierte ich mir die Gradeinstellung für jeden Container, sobald er wieder im Containerhafen war, und machte mich daran, die notwendigen Anpassungen für jeden Container in seinem jeweiligen Lua-Skript vorzunehmen. Bei der folgenden Operation war alles in Ordnung und jeder der Container landete wieder am Containerhafen und zeigte 90 Grad an. Bei der nächsten Überfahrt gab es jedoch bei den meisten eine Abweichung von 0,01. Ich setzte alle Container auf 90 Grad zurück und schickte die Fahrzeuge und den Zug auf ihren fröhlichen Weg. Die folgenden Ergebnisse zeigten eine Abweichung zwischen 89,99 oder 90,01 oder 90,02. Meine besten Ergebnisse sind, dass ich 3 Zyklen abschließen kann, bevor die Genauigkeit abnimmt.

Ich kann mir nicht erklären, warum das passiert. Ist jemandem diese Anomalie aufgefallen und wenn ja, wie haben Sie sie behoben?

Verwirrter Pete

Link zu diesem Kommentar
Auf anderen Seiten teilen

vor 48 Minuten schrieb 220hotwheels:

I made a note of the degree setting

you could read the entire pack of rotation data (a table with four entries) and store it in a variable for later retrieval.

First, this'll be more accurate, because you store the very data that positioned the container in your rendered scene.
And second you only need to do it once. Thus avoiding the possibility that small errors accumulate.

Link zu diesem Kommentar
Auf anderen Seiten teilen

1 hour ago, Goetz said:

you could read the entire pack of rotation data (a table with four entries) and store it in a variable for later retrieval.

First, this'll be more accurate, because you store the very data that positioned the container in your rendered scene.
And second you only need to do it once. Thus avoiding the possibility that small errors accumulate.

Hi Goetz

Forgive me but I am unclear what you are referring to with regard to the entire pack of rotation data. Where do I find this.

Whenever I have needed to use Lua for this purpose I have always managed to convert the degrees to radians using a recognised calculator. It has usually been correct.

I can however appreciate your advice with regard to storing the data in a variable but am unclear as to how to achieve this too.

I bet you get tired at times dealing with members with so little actual knowledge of this wonderful hobby. I'll take a fresh look into all of this tomorrow.

Kind regards

Pete

Link zu diesem Kommentar
Auf anderen Seiten teilen

vor 8 Stunden schrieb 220hotwheels:

I am unclear what you are referring to

I'm talking about this set of data:

storeRotation = $("40' Container").transformation.rotation

You know it, because you've used the four values x, y, z and w from inside this table to do your conversions.
But when you only want to memorise the position and not manipulate it, you can store the entire table and restore it when required

$("40' Container").transformation.rotation = storeRotation

here is a small example for you

store rotation.mbp

 

Kind regards
Goetz

Bearbeitet von Goetz
Link zu diesem Kommentar
Auf anderen Seiten teilen

2 hours ago, Goetz said:

I'm talking about this set of data:

storeRotation = $("40' Container").transformation.rotation

You know it, because you've used the four values x, y, z and w from inside this table to do your conversions.
But when you only want to memorise the position and not manipulate it, you can store the entire table and restore it when required

$("40' Container").transformation.rotation = storeRotation

here is a small example for you

store rotation.mbp 3.74 kB · 2 downloads

 

Kind regards
Goetz

Good morning Goetz

Thank you for your patience and for your informative explanation. My knowledge of Lua is extremely limited, in fact just about none existent , but what little I do pick up over time is very useful. This is one such occasion so very many thanks for providing me with a little more knowledge to add to my little grey cells.

Kind regards 

Pete

Link zu diesem Kommentar
Auf anderen Seiten teilen

Hi Pete,

vor 14 Stunden schrieb 220hotwheels:

I cannot explain why this might be happening...

One possible cause is the following:

When the container is placed on the cargo pad by the crane, a link is automatically created from the container to the cargo pad...
Bild001.thumb.jpg.8e78d15021e697a1ca9068af8b1c79ec.jpg

The link causes the container to align itself with the rotation (and position) of the cargo pad. If you rotate the container back to its origin using lua, this can lead to the deviations you have described.
You should therefore delete the link first...

$("Container").link=nil

... and then bring the container into its home position/rotation.

Kind regards

EASY

Link zu diesem Kommentar
Auf anderen Seiten teilen

1 hour ago, EASY said:

Hi Pete,

One possible cause is the following:

When the container is placed on the cargo pad by the crane, a link is automatically created from the container to the cargo pad...
Bild001.thumb.jpg.8e78d15021e697a1ca9068af8b1c79ec.jpg

The link causes the container to align itself with the rotation (and position) of the cargo pad. If you rotate the container back to its origin using lua, this can lead to the deviations you have described.
You should therefore delete the link first...

$("Container").link=nil

... and then bring the container into its home position/rotation.

Kind regards

EASY

Hi Easy

Thanks for that although the cargo pad is already set at 90 degrees as is the container before the crane lifts it. Once the train stops in the holding area each of the 6 containers requires a slightly different Lua setting adjustment in order to return  it to the original position, the cargo pad at the end point is also set at 90 degrees. I plan to try to reset this operation using the guidance offered by Goetz in order to see if I can retain continuity but that might take me a little while to work through. Perhaps part of the issue is the fact that I am using 2 trains for this movement. One arrives at the depot with empty waggons. It disconnects from them ready to enter the depot for servicing. The second train comes out from the depot, through the turntable and moves to the opposite end of the waggons before hitching up and moving off once the containers have been loaded. The Lua rotation code is slightly different for this movement compared to that for the first train. The second train then returns to the depot with empty waggons and the process is repeated. The 2 trucks however are a constant which is the most puzzling element but hopefully once I set it up following Goetz advice all will be well.

Time and a little effort will tell.

Kind regards

Peter

Link zu diesem Kommentar
Auf anderen Seiten teilen

Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren

Du musst ein Benutzerkonto besitzen, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen.

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde dich hier an.

Jetzt anmelden
×
×
  • Neu erstellen...