                  Morimoto Traffic Simulator ver.0.21
        for RoboCupRescue Prototype Simulation System ver.0.39

                            May. 11, 2002


ܥץϡRoboCup2002 in Fukuoka/Busan  RoboCupRescue
Simulation League ǤλѤŪ˳ȯ줿 RoboCupRescue
Prototype Simulation System Ѹ̥ߥ졼Ǥ

ܥץ Ver.0 ǺƤ¸ΥȤؤͤ
ήߥ졼ȤθߴŻ뤷ƤޤˡȺ
ʤ̱ƶΤΤޤήߥ졼ǳ̤˰
ƤʤΤܥץǤ⳵Ͱޤ


I. Installation

To make this simulator, you simply type the following command:

    % make

    NOTE: JDK 1.3.0 is required


II. Usage

Synopsis is as follows:

    java traffic.Main [ hostname [ port ] ]

    hostname : kernel host name (default: localhost)
    port     : kernel port (default: 6000)


III. ¹ԴĶ

1/10 ǥΥߥ졼Ǥϡ׻٤礭ᡤץ
ʤȤ3ΥޥˡʲΤ褦˿ʬɬפޤ

  ߵ//ƻϩ⥨
  ̱ȡкҥߥ졼
  ͥ롤¾Υߥ졼 (ܥץޤ)

кҤȸ̤Ϸ׻ӤŤʤäƤꡤʬɬפޤ
ȷȥ֥ߥ졼Ϸ׻Ӥۤʤ뤿ᡤ̱
ȤȲкҥߥ졼 1 Ƿ׻Ƥꤢޤ

ʤܥץϰʲ PC 3 Ȥưǧޤ

    CPU : Pentium III 930MHz
    MEM : 256MB
    OS  : Linux (Vine 2.1.5)
    JDK : 1.3.0


IV. ȳȯɬפʺ¤ξ

(1) ܥץ AK_MOVE/LOAD/UNLOAD ޤ AK ޥɤλ
ϴ¸Υߥ졼ƱͤǤ

(1-1) ư (MovingObject Τ)
    Header: AK_MOVE
    Body:   routePlan : an array of IDs  (32 bit * number of route objects)
            0         : a sentinel of the array (32 bit)

ưϩ routePlan ˱äơȤưޤưϩϡ
ϤȤ 1İʾ MotionlessObject  ID 鹽롤ޤ
褦ʥȥޥȥ󤬼θǤ

             n          n
          ------>    <------ OrgBldg
      Road       Node
          <------    ------> DestBldg
             r          b

        | Road | Node | OrgBldg
      ----------+------+------+----------
       ߰ | Road | Node | Building

       ϵ | n                | r                | b
      ----------+------------------+------------------+----------------------
           ̣ | ܤNodeID | ܤRoadID | ܤBuildingID

      λ : Ƥξ

(1-2) Ԥߵ޼֤˾褻 (AmbulanceTeam Τ)
    Header: AK_LOAD
    Body:   target : an ID (32 bit)

 target ߵ޼֤˾褻ޤԤϵߵƱˤʤФ
ޤ󡥤ƻϩȤüƱ֤Ȥߤʤޤ

(1-3) Ԥߵ޼֤ߤ (AmbulanceTeam Τ)
    Header: AK_UNLOAD
    Body:   Nothing

ߵ޼֤˾褻ƤԤߤޤߤ줿Ԥΰ֤ϡߵ
Ʊˤʤޤ

(2) ̲β

ưϩĺɤڤ硤ȤϤƻϩ̲Ǥĺ
ڤμߤޤ

(2-1) ĺ

ƻϩĺɤⰯήߥ졼ƱͤǤꡤʲΤ褦ޤ

    lineWidth             := width / (linesToHead + linesToTail)
    road.blockedlines     := floor(road.block / road.lineWidth / 2 + 0.5)
    road.aliveLinesTo...  := max(0, road.linesTo... - road.blockedLines)
    road.isPassableToHead :- road.aliveLinesToHead >= 1
                          or movingObject.positionExtra < road.length / 2
    road.isPassableToTail :- road.aliveLinesToTail >= 1
                          or movingObject.positionExtra > road.length / 2

ĺɤƻϩο 1 ¸ߤ뤳Ȥˤޤޤʣ
ϡ¦μĺɤ뤳Ȥˤޤ isPassableTo...  true 
Ȥϡƻϩ¦ĺɤƤʤ뤫뤤ϴĺɤ
֤ۤˤ̣ޤ

ĺɤƻϩ̲βݤϡ֤ͤƱͤȽꤷޤ

(2-2) 

ܥץϡȤμ֤ȤμִֵΥݤĤİư
ޤΤᡤ֤̩ͤȽڤȯޤ

μ֤ޤǤκûμִֵΥ MIN_SAFE_DISTANCE_BETWEEN_CARS
οͤޤǤκûδֳ֤ MIN_SAFE_DISTANCE_BETWEEN_CIVILIAN Ǥ
(cf. Constants.java)

 (۵޼) ͥ褷ơ̱ϼ֤ˤҤʤ褦տư
ȹ֤ͤϻ̵̱뤷ưưǤޤޤߤƤ֤
Ǥ⡤̤μƤмѹǤ뤿ᡤ̲᤹뤳
Ǥޤ

(3) ¾

(3-1) ֤κǹ®٤ MAX_VELOCITY_PER_SEC [mm/sec]
(cf. Constants.java) Ǥꡤ 1 cycle ǰưǤĹΥϹ⡹ 
MAX_VELOCITY_PER_SEC * 60 [mm] Ǥ

(3-2) Ver.0Ǥϰư֤϶۵޼ξΤߤʤΤǡ, ޤ¤Ϲͤ
ޤ
    
(3-3) ήߥ졼ǻȤƤʤäʬΥӡԼƻϩ
Ƥʤä carsPassTo... humansPassTo...ϡܥץ
Ǥⰷޤ


V. 꿼ȳȯΤ

(1) ߥ졼γ

ܥץνǥȤʤΤϡƻϩ˼γǰΤˤ뤳ȤǤ
ȤϡʪˤΤơ˼ˤޤܥץ
बʤϡ

  ư
  ʪ
  Ԥ褻/ߤ
  ̲᤹
  ĺɤ򤹤
  ߼ξɤۤ
  ž󤹤
  Ū˼֤¦μ˴󤻤
  ʪϩ˽Ф

ǤꡤΤ 6 Ĥνϡѹ˵夵ޤ
Prototype Simulation System λ;塤Ȥˤϼʬɤμ
뤫ΤѤϤޤ󤬡ڤβäΤˤϡռ
ȥץߥ󥰤פˤʤȹͤޤξϤǤϼ
ˡܥץबԤߥ졼γפޤ

(2) ΰư

Ȥΰưϡΰưȼѹη֤ˤäƷ׻
Ĥޤꡤ㳲ʪ (ŪϤưˤμξޤ) ޤǼ
ľʤ㳲ʪۤ뤿˼ѹ롤ȤŪϤ
ɤ夯ޤǷ֤ޤ

ȤϾ㳲ʪμǳμ¤ߤǤ褦ˡ®٤ޤưư
®٤ϡߤ®٤˲®٤ä뤳ȤǷꤷ® a ϰʲ
 (1)  a ˤĤƲ򤯤Ȥˤޤ

    dx  : distance from the forward object
    ma  : maximum acceleration
    msd : minimum safe distance to forward object
    v   : velocity
    a   : acceleration
    safeDistance = (v + a)^2 / (2 * ma) + msd
    dx - safeDistance = v + a                  ... (1)

    NOTE: t = (v + a) / ma : ߤޤǤˤ
          (v + a) / 2 * t  : ߤޤǤ˰ưΥ

֤β®٤ˤ¤ꡤ֤߾֤ǹ®٤ˤʤޤ (εդƱ
) ˡʤȤ ACCELERATING_SEC [sec] (cf. Constants.java) פ
̱⤤ưư뤿ᡤ®٤¤Ϥޤ

 cycle ν®ˤϡ cycle κǽ®٤Ѥޤ
cycle Ϳ줿ȤιưƤưǤʤäꡤؤ
ưǤˤϡߤȹͤ® 0 [mm/sec] ˤޤ
ߥ졼λγ 1 ʬƲ᤮뤿ޤ

(3) ѹ

˽Ҥ٤褦ˡʲι԰

  ̲᤹
  ĺɤ򤹤
  ߼ξɤۤ
  ž󤹤
  Ū˼֤¦μ˴󤻤
  ʪϩ˽Ф

ϼѹȤƽޤ

ѹνǤϡѹθμγƼˡߤβݤȽ
ꤷ߲ǽʤѹޤߤǽʾȤϡ
Ǥȸˤ֤ȤμִֵΥݤǤѹ
ΤɤμˤʤϡޤԵޤ

礭ʤ뤤Ʊƻϩ (ʹμ¿ޤƻϩ 
--- Ĥޤꡤͥƻϩ) ȸ Node (ʬ, ήޤ) ȸƤӤ


(4) ưϩȤν

ߥ졼νƤ뤿ˡưϩ˱
Υ᡼ޤѤƽҤ٤ޤưϩϰʲɽεˤäɽ


   B        | N    | R
  ----------+------+------
   Building | Node | Road

ƤΥ᡼ϰʲɽεˤäɽޤ

   [ ]      | :    | ---> | +        | s          | m
  ----------+------+------+----------+------------+--------------------
   Building | Node | Lane | Blockade | self agent | other MovingObject

  case 1:
    route plan: {B}
      # ⤷ʤ
      [s]        [s]
      before     after

  case 2:
    route plan: {... R}
     AK_MOVE ƤʤRoad ˤ
      # ¾μ֤˸ˤʤʤ褦ˡֳ¦μ˴
      ------->       ---s--->
      ---s--->       ------->
      <-------       <-------
      <-------       <-------
       before         after

  case 3:
    route plan: {... N}
     AK_MOVE ƤʤNode ˤ
      # ¾μ֤˸ˤʤʤ褦ˡֳ¦μ˴
      ------->:       ------->s
      ------->s       ------->:
      <-------:       <-------:
      <-------:       <-------:
       before           after

  case 4:
    route plan: {B N}
      # N ФƤ˼ѹ
             [s]                   [ ]
              |                     |
      ------->:------->      ------->s------->
      <-------:<-------      <-------:<-------
           before                  after

  case 5:
    route plan: {B N B}
      # NФƤ˼ѹ塤Ūηʪ
             [s]                    [ ]                    [ ]
              |                      |                      |
      ------->:------->      ------->s------->      ------->:-------->
      <-------:<-------      <-------:<-------      <-------:<--------
              |                      |                      |
             [ ]                    [ ]                    [s]
           before                  after                more after

  case 6:
    route plan: {B N R} ({B R} is similar)
      # N ФƤ Rμλ˼ѹ
      [s]             [ ]
       |               |
       :------->       :s------>
       :<-------       :<-------
         before           after

  case 7:
    route plan: {... N B}
      # B 
             [ ]            [s]
              |              |
      ------->s      ------->:
      <-------:      <-------:
        before         after

  case 8:
    route plan: {... N R ...}
      case 8-1: ... -> N -> R -> ...
        case 8-1-1: N  R ľʲǽ
          # ʤ
          s------->       :---s--->
          before           after

        case 8-1-2: N  R ؤθ
          # N ФƤ R μλ˼ѹ塤ʤ
           :------->       :s------>       :---s--->
          s:               :               :
            before           after         more after

        case 8-2:      ->    -> N  -> ...
                  ... <-  R <-    <-
        # N ФƤ R μλ˼ѹ塤ʤ
        ------->s------->       ------->:------->       ------->:------->
        <-------:               <------s:               <---s---:
             before                    after                more after

  case 9:
    route plan: {... R N ...}
      case 9-1: ... -> R -> N -> ...
        case 9-1-1: R  N ľʲǽ
        # ʤ
        ---s--->:       ------->s
         before           after

        case 9-1-2: R  ĺɤƤ
          case 9-1-2-1: ĺ (ƻϩ濴) ᤮֤ˤ
          # ʤ
          ---+s-->:       ---+--->s:
           before           after

          case 9-1-2-2: ĺɤμˤ
          # ʤǤ˼ѹ塤ʤ (ʤФ)
          --s+--->:       ---+--->:       ---+---> :
          ------->:       --s---->:       ------->s:
           before           after         more after

        case 9-1-3: ưʪΤμˤ
        # ʤǤ˼ѹ塤ʤ (ʤФ)
        -s---m->:       -----m->:       -----m-> :
        ------->:       -s----->:       ------->s:
         before           after         more after

      case 9-2:      ->    -> R  -> ...
                ... <-  N <-    <-
      # N ˸ RȿмƱ֤˼ѹ塤ʤ (== ž)
      :-------s->       :--------->       : --------->
      :<---------       :<------s--       :s<---------
         before            after           more after

(5) AK_MOVE/LOAD/UNLOAD ͥ

AK_MOVE ͥǽޤAK_LOAD/UNLOAD ϡåȤԤ 
AK_MOVE ʤäΤ߹Ԥޤ

Prototype Simulation System Ver.0.31 ϡAK_LOAD/UNLOAD Misc
Simulator ƤޤSimulation System Ver.0.36 Ǥϡ
position, positionExtra, positionHistory ץѥƥζɤᡤ
̥ߥ졼ޤ


VI. ܥץγȯ/ݼɬפʾ

(1) Ȥΰ֤˴ؤʲΥץѥƥ

  MovingObject.position
  MovingObject.positionExtra
  MovingObject.positionHistory

ϡ̥ߥ졼Τߤꤷ¾Υߥ졼ѹʤȤ
Ȥޤ줬ݾڤʤȡߥ졼ξ֤ȡܥץब
ݤäƤ륨Ȥξ (®٤ʤ) Ȥδ֤˰ʤ
ʤꡤߥ졼Υץߥ󥰤ˤʤޤ

positionHistory ϰήߥ졼ƱͤǤꡤϩ Node Υ
ȤȤɽޤ

(2) Constants.java Ƥͤѹˤꡤ꤬ѹǤ


  ߥ졼η׻ñ̻	UNIT_SEC
  /ͤ®				MAX_VELOCITY_PER_SEC
					MAX_CIV_VELOCITY_PER_SEC
  ֤κǹ®٤ޤǤˤ		ACCELERATING_SEC
  /ͤ߻ΰʼִֵΥ		MIN_SAFE_DISTANCE_BETWEEN_CARS
					MIN_SAFE_DISTANCE_BETWEEN_CIVILIAN
  ʹ				DRIVING_DIRECTION_IS_LEFT
  ׻Ǥڤ (cf. VI (3-3))	CALCULATING_LIMIT_MILLI_SEC

(3) ߥ졼ή

ߥ졼ϡޤ
  traffic.Simulator.Simulator(InetAddress kernelAddress, int kernelPort)
ˤԤʸ塤
  traffic.Simulator.simulate()
򷫤֤ȤǿʹԤޤ

(3-1) traffic.Simulator.simulate() γ

  ȤιưƤ	traffic.io.receiveCommands()
  AK_MOVE 		traffic.Simulator.move()
  AK_LOAD/UNLOAD 		traffic.loadUnload()
  ߥ졼̤	traffic.io.sendUpdate()
  ߥ졼̤	traffic.io.receiveUpdate()

(3-2) ȤιưƤΥå

ȤιưƼˡ
  traffic.WorldModel.parseCommands(int[] data)
ˤꡤưƤβΥåԤޤưƤͤ
ƤʤϡʳǤϤޤ

(3-3) AK_MOVE νγ

ƥκǽˡ
  traffic.object.MovingObject.initializeEveryCycle()
ˤꡤưϩUNIT_SEC (cf. VI (3-2)) ñ̤ǥ
ΰư򥷥ߥ졼Ȥޤ1 ñ̻Υߥ졼γפϰʲ
ȤǤ

  1) ߥ졼ǤڤȽ
    CALCULATING_LIMIT_MILLI_SEC

  2) ưȾ㳲ʪĴ٤
    traffic.object.MovingObject.setMotionlessObstructionAndMovingLaneList()

  3) ưˤξĴ٤
    traffic.object.MovingObject.setMovingObstruction()

  4) 㳲ʪμ˱ƥȤʬ
    traffic.Simulator.sortByObstruction()

  5) ξ˹ԤˤޤƤ륨Ȥư
    traffic.Simulator.m_waitingNoChangeList
    traffic.Simulator.moveBeforeForwardMvObj(MovingObject MovingObject mv)

  6) ĺɡѹžμˤ륨Ȥư
    traffic.Simulator.m_waitingMap
    traffic.Simulator.dispatch(ArrayList follows)

  7) ʪŪϤμˤ륨Ȥư
    traffic.Simulator.m_noWaitingList
    traffic.object.MovingObject.move()

  8) 㳲ʪʤȤư
    traffic.Simulator.m_noWaitingNoChageList
    traffic.object.MovingObject.move()

1) ϡߥ졼̤襵롤μ¤˥ͥ뤿Ρ
֤̽Ǥǽοȡ¿ΥȤĹΥư
褦ʾˡ׻Ǥڤ뤳Ȥޤ

6)  traffic.Simulator.dispatch(ArrayList follows) Ǽѹ륨
Ȥοϡ1 Ĥξ㳲ʪˤĤ1 ñ̻ 1 Ȥ˸¤ä
ޤ


VII. License Of Morimoto Traffic Simulator

(1) Neither the RoboCupRescue committee nor development staffs of this
program provide warranty.  Use the software at your own risk.

(2) Copyright of all program code and documentation included in source
or binary package of this program belongs to Takeshi Morimoto.

(3) You can use this program for research and/or education purpose
only, commercial use is not allowed.


VIII. Author

Takeshi MORIMOTO
Ikuo Takeuchi Laboratory
Department of Computer Science
The University of Electro-Communications

Additional information can be found in:
    http://ne.cs.uec.ac.jp/~morimoto/rescue/traffic/

Mail bug reports and suggestions to:
    morimoto@takopen.cs.uec.ac.jp
