RadarTurnAngle with setAdjustXXX(true)

  • Wompi

    Wompi - 2012-04-05

    Hi mates.

    Can somebody try this piece of code and tell me whats wrong with it? Just make
    a Robot and put this at your run() method.

        public void run()
            while (true)

    With this i always get a 25deg (45 (radar) - 20 (gun)) scan arc. But it should
    45 radar because i put the radar apart from the gun turn, i guess. I tryed
    this with ( and clients and got the same results. I'm sure i
    did something wrong, but i simply don't get it.

    take care


  • Nat Pavasant

    Nat Pavasant - 2012-04-05

    There are nothing wrong with it. The setAdjustXX() did not detach the radar
    from gun; it just simply compensate radar turn automatically e.g. if you have
    setAdjustRadarForGunTurn(true) and setTurnGunRight(20), the system will
    automatically call setTurnRadarLeft(20) for you.

    So you only get 25 degrees of radar coverage.

  • Flemming N. Larsen

    I agree with Nat. :-)

    1) The radar is mounted on the gun. When turning the radar, this is always
    done relative to the gun. It can move up to 45 degrees in one direction
    compared to the gun heading.

    2) The gun is mounted on the body. When turning the gun, this is always
    relative to the body. It can move up to 20 degrees in one direction compared
    to the body heading.

    3) The body can turn up to 10 degrees in one direction.

    If you set all setAdjustXXX() to false, and turn the body, gun, and radar at
    max. speed, the radar with effectively turn 10+20+45 = 75 degrees, i.e. the
    radar heading will change with 75 degrees. If you turn the body and gun at max
    speed to the right, but the radar in the opposite direction with max speed,
    the radar heading will change with -10-20+45 = 15 degrees.

    When you call setAdjustXXX() to true, you are not getting the "compensated
    angles" for free. So Nat is right.

    When you turn your gun to the left with 20 degrees, Robocode will
    automatically turn the radar the same amount of degrees in the opposite
    direction. That is, the gun turn is compensated by also turning the radar, so
    that radar "stands still" compared to the gun. But the radar will have spend
    20 degrees, and is only able to turn 45-20 = 25 of additional degrees

    I hope this makes sense to you? :-)

    Actually, turning the radar with 75 degrees using "piggybacking" with the gun
    + body is an effective way to move the radar really fast, if you need to turn
    it fast. This can be handy in some situations where another robot just passed
    beside your robot, and your robot lost it on the scanner.

  • Wompi

    Wompi - 2012-04-06

    Uhhh ... thanks to both of you.

    This gives me a big headache. I'm not sure if i get it now, but i see how it
    is supposed to be working. It's the first time i thought about a better radar
    and i have to find a way around this additive angles. So thanks again.

    take care



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks