<HTML dir=ltr><HEAD>
<META content="text/html; charset=unicode" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16444"></HEAD>
<BODY>
<DIV dir=ltr id=idOWAReplyText35647>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>Hi Marcel,</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>Mm, the Sleep is only called when the avatar takes place in the vehicle not otherwise.</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>So before any movement over the vehicle the code that contains the Sleep commands has already been executed.</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>And of course you would expect the script to continue after a small delay and that does not happen.</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>Thx,</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>Marco</FONT></DIV>
<DIV dir=ltr><BR> </DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> opensim-users-bounces@lists.berlios.de on behalf of marcel verhagen<BR><B>Sent:</B> Wed 9-12-2009 12:25<BR><B>To:</B> opensim-users@lists.berlios.de<BR><B>Subject:</B> Re: [Opensim-users] Vehicle script stops after about 5 secs<BR></FONT><BR></DIV>
<DIV>could it be the sleep function ?<BR><BR>
<DIV class=gmail_quote>2009/12/8 Marco Otte <SPAN dir=ltr><<A href="mailto:m.otte@camera.vu.nl">m.otte@camera.vu.nl</A>></SPAN><BR>
<BLOCKQUOTE style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0pt 0pt 0pt 0.8ex; PADDING-LEFT: 1ex" class=gmail_quote>
<DIV>
<DIV dir=ltr>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>Hi everyone,</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial><FONT size=3 face="Times New Roman">I've got a simple car (works fine in SL).<BR>I've created a small LSL script (see below) that listens to channel 9 for information about speed and direction. The script inputs this into the standard physics commands to move and turn the car.<BR>Because I want outside (of OpenSIM) control of the car, I've created a small C# program that simply types the speed and direction into the chat box (/9 speed_direction). This because a HTTPrequest from LSL is limited to about 1 call per second and that is too slow.<BR>The whole setup seems to work. The car moves and turns smoothly, BUT after about 5 secs (give or take) moving the script stops responding and the vehicle stops. After StandUp-Sit it resumes for another 5 secs.<BR>If the vehicle does not move, the script keeps running.</FONT><BR></FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>----- script -----</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial><FONT size=3 face="Times New Roman">//This car uses a C# program that send keypresses containing the speed and direction.<BR>//A Listen() event picks up these numbers and pushes these into the VEHICLE<BR>string sit_message = "Ride"; //Sit message<BR>string not_owner_message = "You are not the owner of this vehicle ..."; //Not owner message<BR>key requestid; //Used for the HTTPREQUEST<BR>float SpeedSet = 0; //Translated speed from bike speed<BR>float TurnRatioSet = 0; //Calculated turn adjustment<BR>integer TurnLeftThreshold = 1070; //Upper bound for straight ahead from bike<BR>integer TurnRightThreshold = 1050; //Lower bound for straight ahead from bike<BR>integer TurnLeftMax = 1243; //Maximum value from bike at full left steering<BR>integer TurnRightMin = 809; //Minimum value from bike at full right steering<BR>integer Handle = 0;<BR><BR>default<BR>{<BR>    state_entry()<BR>    {<BR>        llSetSitText(sit_message);<BR>        llSitTarget(<0.2,0.2,0.5>, ZERO_ROTATION ); // forward-back,left-right,updown, ZERO_ROTATION<BR>        <BR>        llSetCameraEyeOffset(<-0.2, 0.0, 1.0>);<BR>        llSetCameraAtOffset(<5.0, 0.0, 0.0>);<BR>        <BR>        //car<BR>        llSetVehicleType(VEHICLE_TYPE_CAR);<BR><BR>        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.8);//0.8<BR>        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.10);//0.1<BR>        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.1);//1.0 Lower is more responsive<BR>        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1);//0.2<BR>        llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <20.0, 20.0, 10.0>);//1000,2,1000<BR><BR>        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);//0.2 - not much difference on its own<BR>        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.10);//0.1<BR>        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.1);//0.1 Low is better, less after turning<BR>        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.1);//0.5<BR>        llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <20.0, 20.0, 20.0>);//20,20,1000<BR><BR>        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.10);//0.5<BR>        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.50);//0.5<BR>    }<BR>    <BR>    changed(integer change)<BR>    {<BR>        if (change & CHANGED_LINK)<BR>        {<BR>            key agent = llAvatarOnSitTarget();<BR>            if (llKey2Name(agent) == "Blithe Crosswater")<BR>            { <BR>                if (agent != llGetOwner())<BR>                {<BR>                    llSay(0, not_owner_message);<BR>                    llUnSit(agent);<BR>                    llPushObject(agent, <0,0,50>, ZERO_VECTOR, FALSE);<BR>                }<BR>                else<BR>                {<BR>                    llListenRemove(Handle);<BR>                    llSetStatus(STATUS_PHYSICS, TRUE);<BR>                    llSleep(.1);<BR>                    llListen(9,"","","");<BR>                    requestid = llHTTPRequest("</FONT><A href="http://127.0.0.1:8002/?1%22,%5BHTTP_METHOD,%22GET%22%5D,%22%22%29;" target=_blank><FONT size=3 face="Times New Roman">http://127.0.0.1:8002/?1",[HTTP_METHOD,"GET"],"");</FONT></A><FONT size=3 face="Times New Roman"> [</FONT><A href="http://127.0.0.1:8002/?1%22,%5BHTTP_METHOD,%22GET%22%5D,%22%22%29;" target=_blank><FONT size=3 face="Times New Roman">^</FONT></A><FONT size=3 face="Times New Roman">] //This is to start the C# program inputting Speed and Direction<BR>                    llSleep(.4);<BR>                }<BR>            }<BR>            else<BR>            {<BR>                llListenRemove(Handle);<BR>                llSetStatus(STATUS_PHYSICS, FALSE);<BR>                llSleep(.4);<BR>                llTargetOmega(<0,0,0>,PI,0);<BR>                requestid = llHTTPRequest("</FONT><A href="http://127.0.0.1:8002/?0%22,%5BHTTP_METHOD,%22GET%22%5D,%22%22%29;" target=_blank><FONT size=3 face="Times New Roman">http://127.0.0.1:8002/?0",[HTTP_METHOD,"GET"],"");</FONT></A><FONT size=3 face="Times New Roman"> [</FONT><A href="http://127.0.0.1:8002/?0%22,%5BHTTP_METHOD,%22GET%22%5D,%22%22%29;" target=_blank><FONT size=3 face="Times New Roman">^</FONT></A><FONT size=3 face="Times New Roman">] //Stops the C# program<BR>                llResetScript();<BR>            }<BR>        }<BR>        <BR>    }<BR><BR>    http_response(key request_id, integer status, list metadata, string body)<BR>    {<BR>        //Catch the response of the C# program, a dummy method<BR>    }<BR><BR>    listen(integer chan, string name, key id, string message)<BR>    {<BR>        //llSay(0,message);<BR>        integer Separator = llSubStringIndex(message,"-");<BR>        float speed = llGetSubString(message, 0, Separator - 1); //Extract speed<BR>        float direction = llGetSubString(message, Separator + 1, llStringLength(message)); //Extract DIRECTION<BR>        <BR>            SpeedSet = (30 * speed) / 7000; //Transform to [0-30] range<BR>        <BR>            if (direction > TurnRightThreshold && direction < TurnLeftThreshold) //Is steering in the middle?<BR>            {<BR>                //Straight ahead<BR>                TurnRatioSet = 0;<BR>            }<BR>            if (direction > TurnLeftThreshold) //Steering left?<BR>            {<BR>                //Set steering in VR to [0-1.65]<BR>                TurnRatioSet = (direction - TurnLeftThreshold) / ((TurnLeftMax - TurnLeftThreshold)/1.65);<BR>            }<BR>            if (direction < TurnRightThreshold) //Steering right?<BR>            {<BR>                TurnRatioSet = (TurnRightThreshold - direction) / ((TurnRightThreshold - TurnRightMin)/1.65);<BR>            }<BR>            <BR>            if(SpeedSet < 0.5) {TurnRatioSet = 0;} //Low speed then no steering<BR>            <BR>            vector angular_motor; //use vector<BR><BR>            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <SpeedSet,0,0>); //Set speed<BR>            <BR>            if (direction > TurnLeftThreshold) //If left<BR>            {<BR>                angular_motor.z += TurnRatioSet; //then increase rotation angle<BR>            }<BR>            if (direction < TurnRightThreshold) //If right<BR>            {<BR>                angular_motor.z -= TurnRatioSet; //decrease rotation angle<BR>            }<BR><BR>            //llSay(0,(string)SpeedSet + " --- " + (string)angular_motor.z); //Diagnostic<BR><BR>            llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor); //Set rotation<BR>    }</FONT><BR>---- end script ---</FONT></DIV>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial></FONT> </DIV></DIV>
<DIV dir=ltr><PRE>With kind regards, 

Marco Otte
CAMeRA @ VU University Amsterdam
De Boelelaan 1081
1081 HV  AMSTERDAM
Netherlands

Visiting address: 
Metropolitan Building
Buitenveldertselaan 3
1082 VA Amsterdam (room Z539)
T +31 (0)20 598 6807
M +31 (0)6 46025037
E <A href="mailto:m.otte@camera.vu.nl" target=_blank>m.otte@camera.vu.nl</A> 

</PRE></DIV></DIV><BR>_______________________________________________<BR>Opensim-users mailing list<BR><A href="mailto:Opensim-users@lists.berlios.de">Opensim-users@lists.berlios.de</A><BR><A href="https://lists.berlios.de/mailman/listinfo/opensim-users" target=_blank>https://lists.berlios.de/mailman/listinfo/opensim-users</A><BR><BR></BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>