The TORCS Racing Board
Username: Password: Remember Me?
Lost Password Register
Author: wdbee | Created: 2017-05-31 07:29:07
Subject: TORCS - Design bugs in pit code API
Hi all,

trying to get a race run without a TORCS crash I slidely modified the setup of the wdbees (initial fuel), because there is no robot using uninitialised variables (with WINDOWS), that would do the job just starting the race again and again.

In most of the races I see Tim's teams be trapped by the TORCS pit code. I reported this bug to Bernhard before start of the season...

After the modifications in the simulation and race engine code the "late" allocation of the pit does not work for cars reaching the pit with no fuel remaining. TORCS is taking the car out of race before the robot can aquire the pit after stopping successfully in the correct position.
You have to aquire the pit before you know, that your car can stop in the pit as expected. Even if your robot works well, it can be hampered by another robot starting out of the pit just if you try to steer into your one. Because you have to aquire the box before stopping successfully, it is already allocated if the car is taken out of race. As consequence the teammate cannot pit. TORCS does not call the end of race function that would allow to easily handle such a situation (release pit it taken out of race).

For me this is a clear TORCS design bug, not a robot using the pit code API in a wrong way (as Bernhard answered).

Knowing about this bug it is possible to work around it, but it causes the robot code to be much more complex.

The correct way to fix the issue would be to give the robot a chance to use "late" allocation of pit and to call the end of race function to allow the driver itself to release the pit (or doing it in TORCS code).

Hope this helps to avoid such issues for your robots.

Wolf-Dieter

Last Edited: 2017-05-31 07:29:07 by wdbee
    Author: berniw | Created: 2017-05-31 21:22:05
    Subject: Re: TORCS - Design bugs in pit code API
    Hi Wolf-Dieter

    "
    trying to get a race run without a TORCS crash I slidely modified the setup of the wdbees (initial fuel), because there is no robot using uninitialised variables (with WINDOWS), that would do the job just starting the race again and again.
    "

    I cannot understand that, what are you talking about, please explain?

    Regarding Tims former question the answer of him was:
    "
    Just tried it in the callback as you suggested, and you're correct... it now works as it should.
    "

    Then:
    "
    After the modifications in the simulation and race engine code...
    "

    What modifications?

    Seriously confusing...

    Kind regards

    Bernhard
    Last Edited: 2017-05-31 21:49:44 by berniw
      Author: wdbee | Created: 2017-06-01 07:08:26
      Subject: Re: TORCS - Design bugs in pit code API
      > Just tried it in the callback as you suggested, and you're correct... it now works as it should.
      This means, if there is still fuel in tank, it works.
      Last Edited: 2017-06-01 07:08:26 by wdbee
        Author: firechief | Created: 2017-06-01 07:19:32
        Subject: Re: TORCS - Design bugs in pit code API
        In my running of the current race, one car ran out of fuel and managed to coast on empty all the way to the pits, where it successfully refuelled and was able to finish the race.

        I'm not saying you're wrong as mine was just a single isolated example, but nevertheless I did see a car with an empty tank pit without being eliminated.
        Last Edited: 2017-06-01 07:19:32 by firechief
          Author: wdbee | Created: 2017-06-01 08:12:31
          Subject: Re: TORCS - Design bugs in pit code API
          Well, does this car use "late" allocation of the pit?

          If it allocates the pit at startline of the lap as some cars do, it works to refuel, but the risk is to not reach the pit. And as we know from past seasons, the pit code of the robots does not handle this situation. The pit is allocated to the teammember, means it is blocked for me. That's it.

          As I wrote, knowing about the issue you can code a work around, but this has to be done in each robot.

          Remember in SD we added the teammanager to the robottools and this way it is available for all robots. It works even if different robots have to drive in one team.
          Last Edited: 2017-06-01 08:12:31 by wdbee
          Author: timfoden | Created: 2017-06-01 08:56:17
          Subject: Re: TORCS - Design bugs in pit code API
          >I did see a car with an empty tank pit without being eliminated.

          This'll be a Mouse or Tiger then :) I've seen all sorts of badness with pitting for these two now in my testing. I've made some changes and its hopefully fixed now.

          Mouse asks for the pit during the call to the robot's main drive() function, at the same time as it starts the final bit of braking to come to a halt in the pit.

          Seems to work OK.

          Cheers, Tim.
          Last Edited: 2017-06-01 08:58:55 by timfoden
            Author: firechief | Created: 2017-06-01 09:29:02
            Subject: Re: TORCS - Design bugs in pit code API
            Yep, it was a Tigger. Pity, as that car was looking very competitive before the pit troubles struck (not that I want to give any spoilers away of course). I'm sure you'll have it sorted for wheel-2 :)
            Last Edited: 2017-06-01 09:29:02 by firechief
      Author: wdbee | Created: 2017-06-01 08:55:14
      Subject: Re: TORCS - Design bugs in pit code API
      Hi Bernhard

      To get serviced in the pit you have to stop (V = 0 m/s).
      But Fuel = 0 L and V = 0 m/s means, the car is taken out of race, isn't it?

      Here the order of checking the "taking out of race" condition and "late allocation of the pit" does not allow to use code like the Mice and LosLobos did use it in the past. You have to allocate the pit before V = 0, isn't it?

      Cheers

      Wolf-Dieter
      Last Edited: 2017-06-01 08:55:14 by wdbee
        Author: berniw | Created: 2017-06-01 19:04:43
        Subject: Re: TORCS - Design bugs in pit code API
        Without looking at the code: I would gueuss yes. But it is totally natural to allocate the pit before you turn in, so please no silly and esoteric use cases...

        Bernhard
        Last Edited: 2017-06-01 19:04:43 by berniw
    Author: berniw | Created: 2017-06-01 00:49:46
    Subject: Re: TORCS - Design bugs in pit code API
    "As consequence the teammate cannot pit"

    Are you sure about that, I have my doubts, namely because

    car->_state |= RM_CAR_STATE_PIT;

    and

    ReUpdtPitTime(car);

    are in the same code block, so either the bot is captured and repaired, or the pit is not occupied. Am I wrong?

    Bernhard
    Last Edited: 2017-06-01 00:49:46 by berniw
      Author: wdbee | Created: 2017-06-01 08:13:33
      Subject: Re: TORCS - Design bugs in pit code API
      And as we know from past seasons, the pit code of most of the robots does not handle this situation. The pit is allocated to the teammember, means it is blocked for me. That's it.
      Last Edited: 2017-06-01 08:13:33 by wdbee
        Author: berniw | Created: 2017-06-01 19:02:16
        Subject: Re: TORCS - Design bugs in pit code API
        "The pit is allocated to the teammember": As I showed you, this is not the case as far as I can see it, or on which line do you think this happens (in TORCS). If the robot is confused about its own internal state it is not TORCS's business to take care of.

        Bernhard.
        Last Edited: 2017-06-01 19:07:18 by berniw
    Author: berniw | Created: 2017-06-01 21:41:12
    Subject: Re: TORCS - Design bugs in pit code API
    As this thread contains no information I consider it for deletion later, currently it is just a waste of space and misleading.

    Regards, Bernhard
    Last Edited: 2017-06-01 21:41:12 by berniw