MantisBT - opensim
View Issue Details
0004434opensim[REGION] Physics Enginespublic2009-12-08 01:152021-10-08 00:44
Dutchottie 
tampa 
normalmajoralways
resolvedunable to reproduce 
master (dev code) 
 
11680
Standalone (Multiple Regions)
ODE
Mono / Windows
0004434: Vehicle motion stops after about 15 meters
I've got a simple car (works fine in SL).
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.
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.
The whole setup seems to work. The car moves and turns smoothly, BUT after about 15 meters (give or take) moving the script stops responding and the vehicle stops. After StandUp-Sit it resumes for another 15m.
If the vehicle does not move, the script keeps running.
I've tried without setting any angular motion, still stops.
I've tried with different speeds (1, 2, 4 m/s) all result in a distance of 15m after which the script stops. So at 1m/s the car moves longer (15s) than at 4m/s (3.75s).
//This car uses a C# program that send keypresses containing the speed and direction.
//A Listen() event picks up these numbers and pushes these into the VEHICLE
string sit_message = "Ride"; //Sit message
string not_owner_message = "You are not the owner of this vehicle ..."; //Not owner message
key requestid; //Used for the HTTPREQUEST
float SpeedSet = 0; //Translated speed from bike speed
float TurnRatioSet = 0; //Calculated turn adjustment
integer TurnLeftThreshold = 1070; //Upper bound for straight ahead from bike
integer TurnRightThreshold = 1050; //Lower bound for straight ahead from bike
integer TurnLeftMax = 1243; //Maximum value from bike at full left steering
integer TurnRightMin = 809; //Minimum value from bike at full right steering
integer Handle = 0;

default
{
    state_entry()
    {
        llSetSitText(sit_message);
        llSitTarget(<0.2,0.2,0.5>, ZERO_ROTATION ); // forward-back,left-right,updown, ZERO_ROTATION
        
        llSetCameraEyeOffset(<-0.2, 0.0, 1.0>);
        llSetCameraAtOffset(<5.0, 0.0, 0.0>);
        
        //car
        llSetVehicleType(VEHICLE_TYPE_CAR);

        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.8);//0.8
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.10);//0.1
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.1);//1.0 Lower is more responsive
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1);//0.2
        llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <20.0, 20.0, 10.0>);//1000,2,1000

        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);//0.2 - not much difference on its own
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.10);//0.1
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.1);//0.1 Low is better, less after turning
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.1);//0.5
        llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <20.0, 20.0, 20.0>);//20,20,1000

        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.10);//0.5
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.50);//0.5
    }
    
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key agent = llAvatarOnSitTarget();
            if (llKey2Name(agent) == "Blithe Crosswater")
            {
                if (agent != llGetOwner())
                {
                    llSay(0, not_owner_message);
                    llUnSit(agent);
                    llPushObject(agent, <0,0,50>, ZERO_VECTOR, FALSE);
                }
                else
                {
                    llListenRemove(Handle);
                    llSetStatus(STATUS_PHYSICS, TRUE);
                    llSleep(.1);
                    llListen(9,"","","");
                    requestid = llHTTPRequest("http://127.0.0.1:8002/?1",[HTTP_METHOD,"GET"],"" [^]); //This is to start the C# program inputting Speed and Direction
                    llSleep(.4);
                }
            }
            else
            {
                llListenRemove(Handle);
                llSetStatus(STATUS_PHYSICS, FALSE);
                llSleep(.4);
                llTargetOmega(<0,0,0>,PI,0);
                requestid = llHTTPRequest("http://127.0.0.1:8002/?0",[HTTP_METHOD,"GET"],"" [^]); //Stops the C# program
                llResetScript();
            }
        }
        
    }

    http_response(key request_id, integer status, list metadata, string body)
    {
        //Catch the response of the C# program, a dummy method
    }

    listen(integer chan, string name, key id, string message)
    {
        //llSay(0,message);
        integer Separator = llSubStringIndex(message,"-");
        float speed = llGetSubString(message, 0, Separator - 1); //Extract speed
        float direction = llGetSubString(message, Separator + 1, llStringLength(message)); //Extract DIRECTION
        
            SpeedSet = (30 * speed) / 7000; //Transform to [0-30] range
        
            if (direction > TurnRightThreshold && direction < TurnLeftThreshold) //Is steering in the middle?
            {
                //Straight ahead
                TurnRatioSet = 0;
            }
            if (direction > TurnLeftThreshold) //Steering left?
            {
                //Set steering in VR to [0-1.65]
                TurnRatioSet = (direction - TurnLeftThreshold) / ((TurnLeftMax - TurnLeftThreshold)/1.65);
            }
            if (direction < TurnRightThreshold) //Steering right?
            {
                TurnRatioSet = (TurnRightThreshold - direction) / ((TurnRightThreshold - TurnRightMin)/1.65);
            }
            
            if(SpeedSet < 0.5) {TurnRatioSet = 0;} //Low speed then no steering
            
            vector angular_motor; //use vector

            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <SpeedSet,0,0>); //Set speed
            
            if (direction > TurnLeftThreshold) //If left
            {
                angular_motor.z += TurnRatioSet; //then increase rotation angle
            }
            if (direction < TurnRightThreshold) //If right
            {
                angular_motor.z -= TurnRatioSet; //decrease rotation angle
            }

            //llSay(0,(string)SpeedSet + " --- " + (string)angular_motor.z); //Diagnostic

            llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor); //Set rotation
    }
} //end default
No tags attached.
Issue History
2009-12-08 01:15DutchottieNew Issue
2009-12-08 01:15DutchottieGit Revision => 11680
2009-12-08 01:15DutchottieSVN Revision => 0
2009-12-08 01:15DutchottieRun Mode => Standalone (Multiple Regions)
2009-12-08 01:15DutchottiePhysics Engine => ODE
2009-12-08 01:15DutchottieEnvironment => Mono / Windows
2009-12-08 01:15DutchottieMono Version => 2.4.2
2009-12-08 04:48DutchottieCategory[REGION] Scripting Engine => [REGION] Physics Engines
2009-12-09 01:19DutchottieSummaryVehicle motion stops after about 5 secs => Vehicle motion stops after about 15 meters
2009-12-09 01:19DutchottieDescription Updated
2021-10-08 00:44tampaMono Version2.4.2 =>
2021-10-08 00:44tampaStatusnew => resolved
2021-10-08 00:44tampaResolutionopen => unable to reproduce
2021-10-08 00:44tampaAssigned To => tampa

There are no notes attached to this issue.