Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Sumo Multi-Clients
  • From: Philippe Käufer <philippe@xxxxxxxxxxxx>
  • Date: Thu, 8 Jul 2021 08:38:51 +0200
  • Autocrypt: addr=philippe@xxxxxxxxxxxx; prefer-encrypt=mutual; keydata= mQENBFIR/PwBCADE1IQAiC3/gZvKlKfq1oR3Nw//8MRBqzh4CvCeGZOvHUgvUx2TO3DMzGax qdfS49h0WB+0nBx23Rvem/Vof9N0MveY2qrySlGBPS2HFvC/AIefGYf7DmvXPKWcJDeHi99M 8DcztmohkwPHtjESUxbVV8oeHL/mYO0x6APWbu0bM97dJB4773LngkX4y9uOdeZN6gw50owG Y6a1yIrEriZwvnMD1htIJinWfFA8c6rdyVKP0xUDh3MD+AsWAVDSZHlH0Q5YjMpnC9OMUNS/ 91l/eS59aymL7TB6z/XKzbvh11W1fyDS2DPsdFQeQIkVQ2jM5mcSaG417Lq04OqrkManABEB AAG0KFBoaWxpcHBlIEvDpHVmZXIgPHBoaWxpcHBlQHBpbGFya3RvLm5ldD6JATAEEwEKABoE CwkIBwIVCgIWAQIZAQWCWhK8VQKeAQKbIwAKCRCAYTk5OEL8gG+WB/9VsUanzywpXhQqPJP0 mNMyiPe3bmx2J+glHr8wIAoOO+XCKKbdHANFkRnpXNigFMDSVES5xL7ypxDgAKnGw55//LWG xmmFoBCNME6/SjC+HgXR8YSxVAMeJ0Oq438goH79kAgwMgvWvGTHK3ihgeOIU64HJbOWUhLR q+HzUOUAQxsBA6SgbMxrS12wCaLp5cyOdsVqw+EdEJq08JZhYOdx32fWa63TWAMCqj+ituDg hKTMXvyu1RfoQ4z/tENXLq2BSPxhruXKhVSFB82ivT6pH1IVMW11tZj9vZhdqf0Gh5be4/mX E2YlYzE/VB4/KToE0su7HarVVBzRYzfOn2HcuQENBFIR/PwBCACtJucBFjIIL0fcXZhqkW/t PPln+cqSh+L7mxVclDFLL32xD//AqkPuXrihWFgja24ueEMFmh0iPGWSpI/PfO9BpHTwNvck 4yO28QrMWwq9dKUxjWG1+khfBiGtw7rPppPB8j2nfGNkkgSjiQcUHqc44ZlucUVVCDTIUQwL GKR4jQfWgFC1vDTKCdrPxtIOpABlsHVzWXQPs744Z5yq79CraZxFztJJ3+eU9KJqntZvGmff DOoQWlvpgOhMU6nObySFZDRe7lc91pbqETqioDh2fwG9WgrtduG+l0X12XO9xcp8CQFbzWce DEmvD64SeL+B2keGNl0jNIU4gxJ4CFTzABEBAAGJAR8EGAEKAAkFgloSvFUCmwwACgkQgGE5 OThC/IASAAgAtHKAqjQsIuCgEAW4C2R6AJ2puVkVqcEFQuBVwj8Y4E6uKO0Tc6tI5853GugK QxmgX9s7KNP0N5D9CAKcRwQhdlGoms7GJLQ92BeRiYoVsixFVX3b5WdqXTZ1CKqck0sULUEE DWBlBykukk/TIMo+lE3s8B8+vwnionheyf1MlbJb6pnfdlBv0DetNMMOa3mvXcpVYYYgvzWA lHSUb+ekWf+ZqAiSd3JABAexSiGloYT/Kz9juLtPruv+6QXkPluRKJ00EGh8WqCmEt138APT nsZtJBuflGyMxFxVFxDuhXFNdaV0Rlel1alf1e00DKnePvjkWkSBG2Bpe+rHoCL9Eg==
  • Delivered-to: sumo-user@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/sumo-user/>
  • List-help: <mailto:sumo-user-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/sumo-user>, <mailto:sumo-user-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/sumo-user>, <mailto:sumo-user-request@eclipse.org?subject=unsubscribe>
  • Openpgp: preference=signencrypt
  • User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

Hi Lewis,

i have an setup with one Java and one Python client. I had the same problem some moth ago. I can not remember what i done exactly. I hope that my code helps you out in some way where i got via traci.getConnection("2") the connection instance:

1. Client (Java):

    conn = new SumoTraciConnection(sumoExec, sumoConfig);
    conn.addOption("num-clients", "2");
    conn.runServer(sumoPort);
    conn.setOrder(1);

2. Client (Python):
        traci.init(9100, 5, "127.0.0.1", label="2")
        conn = traci.getConnection("2")
        conn.setOrder(2)


regards,

    Philippe

Am 08.07.2021 um 01:46 schrieb Yue Zhu:
Hello,

I am currently using sumo to do research with A3C. However, when I was trying to use multi-clients with the method from sumo documentation, it always shows 'waiting for clients'. Could you please help me with this?

Below is my code.

try:
        sys.path.append(os.path.join(os.path.dirname(
                __file__), '..', '..', '..', '..', "tools"))  # tutorial in tests
        sys.path.append(os.path.join(os.environ.get("SUMO_HOME", os.path.join(
                os.path.dirname(__file__), "..", "..", "..")), "tools"))  # tutorial in docs
        from sumolib import checkBinary  # noqa
        from sumolib.miscutils import getFreeSocketPort
except ImportError:
        sys.exit(
                "please declare environment variable 'SUMO_HOME' as the root directory of your sumo installation (it should contain folders 'bin', 'tools' and 'docs')")
       

PORT = 8813
sumoBinary = checkBinary('sumo-gui')
       
#client1
# PORT = int(sys.argv[1]) # example
traci.start([sumoBinary, "-c", "fixed_avg.sumocfg", "--num-clients", "2"], port=PORT)
traci.setOrder(1) # number can be anything
while traci.simulation.getMinExpectedNumber() > 0:
   traci.simulationStep()
   # more traci commands
traci.close()

# client2
# PORT = int(sys.argv[1]) # example
traci.init(PORT)
traci.setOrder(2) # number can be anything as long as each client gets its own number
while traci.simulation.getMinExpectedNumber() > 0:
   traci.simulationStep()
   # more traci commands
traci.close()

Thank you very much!

Best,
Lewis

_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user

Back to the top