Ramp Marshall: Difference between revisions

Jump to navigation Jump to search
(Cleanup; it's called a "marshaller" or "marshalling".)
Line 60: Line 60:


=== Teach the ramp marshaller new signals ===
=== Teach the ramp marshaller new signals ===
The marshaller's signal positions are stored in the '''ramp_marhsall.nas''' Nasal file in a hash. This is so that the signals can be accessed easily by other functions.
<syntaxhighlight lang="javascript">
var pos = {
rest: {lA_x:80, lA_z:0, lAO_x:0, rA_x:-80, rA_z:0, rAO_x:0},
stop: {lA_x:-55, lA_z:0, lAO_x:-70, rA_x:55, rA_z:0, rAO_x:70},
fwd_out: {lA_x:0, lA_z:-50, lAO_x:-30, rA_x:0, rA_z:50, rAO_x:30},
fwd_in: {lA_x:0, lA_z:-50, lAO_x:-120, rA_x:0, rA_z:50, rAO_x:120},
left_in: {lA_x:0, lA_z:0, lAO_x:-120, rA_x:0, rA_z:0, rAO_x:0},
left_out: {lA_x:0, lA_z:0, lAO_x:-30, rA_x:0, rA_z:0, rAO_x:0},
right_in: {lA_x:0, lA_z:0, lAO_x:0, rA_x:0, rA_z:0, rAO_x:120},
right_out: {lA_x:0, lA_z:0, lAO_x:0, rA_x:0, rA_z:0, rAO_x:30}
};
</syntaxhighlight>
* lA_x - Left Arm (shoulder joint) x axis rotation
* lA_z - Lett Arm (shoulder joint) z axis rotation
* lAO_x - Left Arm Outer (elbow joint) x axis rotation
* rA_x - Right Arm (shoulder joint) x axis rotation
* rA_z - Right Arm (shoulder joint) z axis rotation
* rAO_x - Right Arm Outer (elbow joint) x axis rotation
You can mess with the positions in a 3D modeling program or in FlightGear itself. Just set the ramp marshallers function to somethign random so it isn't recognised and change the values in the tree.
If you would like to add a new hand position (say both hands out stright), then you'd add this to the bottom of the '''pos''' hash.
<syntaxhighlight lang="javascript">
    hands_out_front: {lA_x:0, lA_z:-90, lAO_x:0, rA_x:0, rA_z:90, rAO_x:0}
</syntaxhighlight>
Remember to put a comma after the line right before the new one you add.
Now, you can call this position as '''pos.hands_out_front''' to be used in the sequence function. Or if you'd like to get or set one of the position values.
To add the signal sequence, add a new '''if''' state at the end of the last '''if(me.function == "<function_name>"''' statement with the sequence. You can use me.phase to control the sequence phase/step.
Then, add the signal sequence.
HINT - To animate the marshaller to a position you specified and then to go to the next step when it's complete and be achieved like this:
<syntaxhighlight lang="javascript">
if(me.phase == 0) {
    if(!check_pos(ramp_tree, pos.hands_out_front)) {
full_animate(ramp_tree, pos.hands_out_front, 100);
    } else {
        me.phase = 1;
    }
}
</syntaxhighlight>
The above code checks if the marshallers is not in the '''hands_out_front''' pos already and if he isn't, he'll move his hands to that position. In the full_animate function, you can specify the speed his hands should move at in ''degrees per second''. In this case, he'll move his hands forward to the specified position at 100 degrees per second.
==== Useful internal functions ====
* '''getDeviation(heading, target)''' returns the deviation to a target heading from your current heading. This is used by the marshaller to help guide you to the ramp.
* '''animate(property, target, rate)''' animates a property (slowly changes the property value) to a target value at the given rate. (Rate is in degrees per second)
* '''get_pos_values(ramp_tree)''' returns the current position of the marshaller's arms in a hash similar to that of the pos.<pos_name> hash.
* '''check_pos(ramp_tree, target) returns true if the marshaller is at a given position. '''target''' must be a hash similar to the '''pos.<pos_name>''' hash. It is best to simply send a position specified in the '''pos''' hash.
* '''full_animate(ramp_tree, pos_hash, rate) animates the ramp marshaller to the given position at the given rate.
* '''load_ramps(icao)''' loads all ramps (and marshallers) at the given airport.
'''NOTE -''' If any of the functions has '''ramp_tree''' as an argument and the function is being used within the ''main_loop'', the variable '''ramp_tree''' must be passed as an argument.


{{WIP}}
{{WIP}}
449

edits

Navigation menu