Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

AirRobot's max. speeds exceeded

Help
2012-04-15
2012-12-14
  • Hi there,
    first of all I'd like to say that I am new to USARsim and UT programming, so please be patient with me and forgive me my ignorance.
    Now to my problem. I am working with the AirRobot model at the moment and I am wondering why the maximum speeds defined in the AirRobot's source file can be exceeded. The uc-file says:

        maxLateralSpeed = 2;
        maxLinearSpeed = 2;
            maxPitchAngle=25;
            maxRollAngle=25;    
        maxAltitudeSpeed=2;
            maxRotationSpeed=100;
    

    So I would assume that it should not be possible to set the AirRobot's speed to a value higher than the maximum value defined in its uc-file but in Iridium or my control programm I can set the velocities to whichever value I like and the AirRobot flies with the provided velocity. Do I have to take care myself that the maximum velocity value I provide for the robot stays within proper bounds? Or is the robot not functioning properly?

     
  • AHA
    AHA
    2012-04-16

    I've heard about this problem, and It's the robots fault, no you!
    Seems like there are still some fixes needed to be made.

     
  • Seems like it should be a simple fix to clamp the maximum velocity. Any volunteers to have a look?

     
  • AHA
    AHA
    2012-04-16

    I'm working on it.

     
  • Cool :-) Thank you!

     
  • Maximum velicity values are taken into account when the DRIVE commands are sent with {Normalized true}. In this case, the value to be sent should be in . If the command doesn't have that flag activated, the velocity willl be applied to the robot as it is.

    A quick fix to have the maximum velocities never exceeded in non-normalized mode is to simply add something llike this:

    if (speed > maxLinearSpeed) cmdLinearVelocity = class'UnitsConverter'.static.LengthToUU(maxLinearSpeed);
    

    in setLinearVelocity() and, using the corresponding variables, in setLateralVelocity() and setAltitudeVelocity(). (These functions are defined in in AerialVehicle.uc. Alternatively they can be overrided in  Airrobot.uc).

     
  • AHA
    AHA
    2012-04-16

    As nbasilico noted, make the change:

        if (norm) {
            if (speed > 100) speed = maxLinearSpeed;
            else if (speed < -100) speed = -maxLinearSpeed;
            else speed = (speed*0.01)*maxLinearSpeed;
        }
        else {  
            if (speed > maxLinearSpeed) speed = maxLinearSpeed;     
        }
    

    in function setLinearVelocity(float, bool), in ..\Development\Src\USARBot\classes\AerialVehicle.uc.
    Then make_clean Usarsim and see if the maxSpeedLimit issue is solved.

     
  • Thanks for going through the efford! I'll try out your fixes tomorrow. For me maximum velocities are being exceeded even in normalized mode though. No matter which mode I select to send the DRIVE command I can get the AirRobots unrealistically fast. A speed of 100 in normalized mode is really really fast for me. If I remember correctly a velocity of about 2 in normalized mode looked realistic. Another thing I remember from my tests was that I think I could not get the AirRobot to move at all when providing values lower than 2 (or maybe it was 1) for velocity. So values below 2 had no effect on the AirRobot, values around 2+ looked ok and from 2 I could go as high as I wanted which at some point looked just crazy.

     
  • Once you get the changes working, can you please check in the fixed code to the repository? This will allow everyone to take advantage of it! Thanks.

     
  • AHA
    AHA
    2012-04-17

    If you're experiencing the same problem even with Normalized mode, I'm afraid problem is elsewhere.
    For now test the code above, and tell the result.

     
  • Just checked it again. The maximum velocity is not being exceeded when using normalized mode. I guess my former tests were with an older version of USAR.

    @dr_steveb
    Did you ask me to check the fixed code to the repository or did you meen someone else?

     
  • Whoever made (or verified) the change should be free to check it in. I just want to make sure that we don't end up with several versions of the same patch. Thanks for your help.

     
  • I just edited AirVehicle.uc so that maximum velocities are not exceeded even when not using normalized DRIVE commands. The changes I made look as follows for all of the four setVelocity() methods:

    // if the value is normalize in [0,100]
        if (norm) {
            if (speed > 100) speed = maxRotationSpeed;
            else if (speed < -100) speed = -maxRotationSpeed;
            else speed = (speed*0.01)*maxRotationSpeed;
        }
        else {
            if (speed > maxRotationSpeed) speed = maxRotationSpeed;
            else if (speed < -maxRotationSpeed) speed = -maxRotationSpeed;
        }
    

    All I did was to add the else-branches. If this is ok with you I can check it in.

     
  • AHA
    AHA
    2012-04-17

    If it solved the problem, yes, that's the code. Check it in. Thanks

     
  • Done. Thanks for your help guys :-)