'magnetic' landing pad...
|
|
Trent Hedges
TrentCycle & GRAPHICA
Join date: 4 Sep 2003
Posts: 198
|
06-12-2006 13:10
Hey all, I am in the process of building a hover-vehicle, and I want to add the feature of a 'landing base' to include with it... the basis of which is that when you come within x range of the base, it orients you with the base and 'pulls you in ' and lands you nicely on the landing pad. I have the vehicle dynamics down just the way i like them - the craft looks smooth and behaves well, but I am struggling with how to continue the smooth look of the flight with a landing... anyone have some thoughts, or of course - free code suggestions?  The winner gets a shiny new TrentCycle Griffin  I'll post pics in another forum... thanks in advance to you geniuii? (plural?) cheers, Trent
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
06-12-2006 14:10
Well, some rough thoughts... * Once you detect you're within range, you probably want to disable the controls, so your auto-pilot code doesn't have to also deal with someone trying to control the craft. * You could try a sequence of move to target / look at / rot look at calls. So move it to a certain height above the pad, turn it to face a certain way, then lower it to the pad's height. These calls should produce damped movement, but I don't know how well they'll work on a large vehicle because of energy reasons. * The other way would be to use the vehicle motor functions to achieve this, but that might be harder. I don't know. Haven't played with vehicles in a very long time 
|
|
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
|
06-12-2006 14:53
If anyone can figure this out, I'll really appreciate it too. I have plans for a moving aircraft carrier and am looking for auto-landing systems that can also keep objects in sync
|
|
Kokiri Saarinen
Quoted for truth
Join date: 7 Jan 2006
Posts: 44
|
06-13-2006 01:43
The best way to do this would by having your landing pad saying its coords over and over again using llWhisper on a very high command channel. Design your hovercraft to, when it hears a signal like this, move to that position and drop down. Whispers have a radius of 10m, which should work good enough for your range, and its always best to have the hovercraft itself to guide itself in rather than using llPushObject from the landing pad. A sample script may look something like Landing Pad: state_entry() { llSetTimerEvent(1);//Bad for sim load //I would use a 10m wide prim with a collision event instead }
timer() { llWhisper(12345,(string)(llGetPos()+<0,0,1>)); //The 1m is //the height for the craft to "fall into" }
Hovercraft code (implement into your vehicle code) on_rez(integer params) { llResetScript(); }
state_entry() { llListen(12345,"","",""); }
listen(integer channel, string name, key id, string message) { llMoveToTarget((vector)message,1); //a tau of 1 should be good enough if (llVecDist(llGetPos(),(vector)message) < .2) //Close enough to the target { llStopMoveToTarget(); //Stop moving, and just drop } }
Of course, this is only the basics. If you were fancy, you could adjust the tau (with some simple math) to match whatever your speed is, so when you come into range there arent any speed jumps, and your craft will slow down as it approaches the landing pad automatically. Also, you will want to adjust the rotation with a llLookAt to make sure its always looking at the landing pad. -Kokiri
|
|
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
|
06-13-2006 01:56
Looks like Kokiri beat me. =) Put this in the pad: default //this script is just here to make the prim show up on sensor sweeps. { state_entry() { llSay(0, "Hello, Avatar!"); } //IMPORTANT: Name this object "SmartPad" (that's the name the lander scans for) }
Then put this into a prim: //Movement Dynamics float tau = 5;//how many seconds the 'vehicle' has to get to the target integer goal; integer cutoffTime = 30; //how many seconds the lander has to get there before we give up float tolerance = 0.5;//how close we have to get before calling it good enough integer stage = 1;//stage 1 is moving to the pad, stage 2 is dropping to it
///Rotation Dynamics -- from http://secondlife.com/badgeo/wakka.php?wakka=llLookAt vector AXIS_FWD = <1,0,0>; rotation getRotToPointAxisAt(vector axis, vector target) { return llGetRot() * llRotBetween(axis * llGetRot(), target - llGetPos()); } float strength = 1.0; float damping = 1.0;
//Coordinates vector myPosition;//where we are vector finalPosition;//where we're going vector hoverPosition;//how we're going to get there
default { on_rez(integer start_parameter) { llResetScript(); } state_entry() { llSitTarget(<0, 0, 0.5>, ZERO_ROTATION); llSetBuoyancy(1.0);//for simplicity's sake, don't fight gravity llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);//for simplicity's sake, only handle z-axis rotation }
touch_start(integer total_number) { llSensor("SmartPad", NULL_KEY, ACTIVE | PASSIVE | SCRIPTED, 55, PI); } no_sensor() { llOwnerSay("Warning: unable to find landing pad within 55m. You must also be in the same region as the pad."); llResetScript(); } sensor(integer number_detected) { myPosition = llGetPos();//done with global coords in case the pad is in a different sim than me finalPosition = llDetectedPos(0);//reported by the sensor event if(llVecDist(myPosition, finalPosition) > 55) { llOwnerSay("Error: please move to within 55m before trying again."); llResetScript(); } hoverPosition = finalPosition; hoverPosition.z = myPosition.z + 5; llOwnerSay("Looks like we're headed to "+(string)hoverPosition); llSetStatus(STATUS_PHYSICS, TRUE); llRotLookAt(getRotToPointAxisAt(AXIS_FWD, hoverPosition), strength, damping); goal = llTarget(hoverPosition,tolerance); llMoveToTarget(hoverPosition, tau); llSetTimerEvent(cutoffTime);//if we ain't there in X seconds, something's gone wrong, trigger error handling (so to speak) } at_target( integer number, vector targetpos, vector ourpos ) { llOwnerSay("Landing procedure stage " + (string)stage + " complete."); stage++;//enter stage 2, which is dropping to the pad llTargetRemove(goal); llStopMoveToTarget(); llStopLookAt(); llSetTimerEvent(0); state stage2; } timer() { llSetTimerEvent(0); llOwnerSay("No joy, you honky righteous oppressor."); llTargetRemove(goal); llStopMoveToTarget(); llStopLookAt(); llSetStatus(STATUS_PHYSICS, FALSE);//pin ourselves in place for a clean dismount if (llAvatarOnSitTarget() != NULL_KEY) { llUnSit(llAvatarOnSitTarget()); } } }
state stage2 { on_rez(integer start_parameter) { llResetScript(); } state_entry() { llRotLookAt(llEuler2Rot(<1,0,0>),1.0,1.0); goal = llTarget(finalPosition,tolerance); llMoveToTarget(finalPosition, tau); llSetTimerEvent(cutoffTime); } at_target( integer number, vector targetpos, vector ourpos ) { llOwnerSay("Landing procedure stage " + (string)stage + " complete."); llTargetRemove(goal); llStopMoveToTarget(); llSetStatus(STATUS_PHYSICS, FALSE);//pin ourselves in place for a clean dismount llSetTimerEvent(0); llStopLookAt(); if (llAvatarOnSitTarget() != NULL_KEY) { llUnSit(llAvatarOnSitTarget()); } llResetScript(); } timer() { llSetTimerEvent(0); llOwnerSay("No joy, you cracker racist."); llTargetRemove(goal); llStopMoveToTarget(); llStopLookAt(); llSetStatus(STATUS_PHYSICS, FALSE);//pin ourselves in place for a clean dismount if (llAvatarOnSitTarget() != NULL_KEY) { llUnSit(llAvatarOnSitTarget()); } llResetScript(); } } //Ad majorem Dei gloriam... or something
Notes: Touch the autolander ("AL"  prim to begin. The AL queries the pad. The pad responds, shouting its coordinates. The AL receives the coords, and moves to a point 5m above the center of the pad, pauses, then drops to the pad while rotating to face east. Upon reaching the pad, the AL pins itself in place and the 'pilot' is unseated. The AL handles basic errors like not being able to reach the pad in a set time, and not being able to acquire the pad's coordinates. Feel free to use and abuse! Please don't just resell this and rip off my effort. Kindest regards, Kage
|
|
Trent Hedges
TrentCycle & GRAPHICA
Join date: 4 Sep 2003
Posts: 198
|
06-13-2006 07:52
KAGE and others - thanks SO much! You guys are awesome - I ended up snarling at my code for a few hours last night and came up with a very similar version to yours Kage, but without the elegant error-checking - which I will go implement now Your error-check states that you must be within 250 m of the landing base. This sounds great! i thought I had much less llMoveToTarget range? no? Thanks again!! Awesome posts!
|
|
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
|
06-13-2006 09:29
Trent, Thanks for the prompting to sit down and do this. I had been tossing around an idea for something like this for six months, but until I read Ziggy's promptings on how to do it, no forward motion on my part. My apology for the 250m range figure. It seems that the range is actually 100m, which makes using a sensor ping more attractive IMHO. EDIT: looks like I need to get around that MoveToTarget range limit. I'll try to hunt it down now. EDIT: temporary fix added-- if the lander is more than 55 m from the pad, it gives an error and asks you to be a real pilot and fly a little closer before trying again. This, however, is unsatisfactory to me. Note: currently the script uses region coordinates, not global, so this will break if you're in one sim and the pad is in another. EDIT: I've put together a simple autolander kit for anyone who wants to play with this. MAJOR bonus points for anyone who can make it work across region borders or beyond the basic 55m llMoveToTarget. Seems doable with a simple while loop structure, but meh brain is fried. I'll update the scripts above to the current version.
|
|
Trent Hedges
TrentCycle & GRAPHICA
Join date: 4 Sep 2003
Posts: 198
|
06-13-2006 11:25
From: Kage Seraph Trent, EDIT: temporary fix added-- if the lander is more than 55 m from the pad, it gives an error and asks you to be a real pilot and fly a little closer before trying again. This, however, is unsatisfactory to me. Note: currently the script uses region coordinates, not global, so this will break if you're in one sim and the pad is in another. Yeah discovered the same today - working with that limit for the moment, as it's a decent range given what my application is - i'll post some photos of the whole thing in action shortly... not sure f they should go in here - but I'll link or something...
|
|
Davan Camus
Registered User
Join date: 13 Sep 2005
Posts: 67
|
06-13-2006 12:24
That's all some great strategies. You might also want to do one last thing: // and snik! into placellSet... I forget, set status nonphysical();llSetPos(landingPadPosition + <0,0,.3> ; // tune to tastellSetRot(landingPadRot); // orient landing prim appropriatelyI do something like this on my crazy elevator in Alice, which hurtles upward as a tumbling physical object, and then snaps into its receiver location.
_____________________
Visit Cubes at Alice 100,18. -------------------------------------------------- Davan Camus, born: 2005 September 8 Out-world location: Santa Cruz, CA UI Proposal: http://davancamus.hexaflexagon.com/blog/?p=39
|