SUMO Traffic Simulation in Unity3D (3d Simulation)

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 มิ.ย. 2017
  • I ported the Traci4J Library to C# for Unity3D to communicate with SUMO via TCP. Everything which is generated only bases on the SUMO map.net.xml file.
    I almost used only free assets (mostly 3D models) with exception of one (SuperSplines).
    1. Part:
    It is possible to insert an ego vehicle which can be controlled via keyboard or via UDP (We are using a complex realtime vehicle model as source for the ego vehicle)
    2. Part:
    It is also possible to just observe the traffic within the 3D Environment wihtout ego vehicle.
    The rotational speeds of the wheels and their steering angles are approximated by the yaw angle and the speed of the vehicle bodies.
    Note that I had to disable the shadows since my working PC is not powerful enough.
    Work in progress:
    - The traffic lights only can handle one command (one lane).
    - For more realistic terrains, the inclination (z coordinate) will be included
    UPDATE (03.12.2019):
    YOU CAN FIND THE UNMAINTAINED FILES HERE:
    github.com/SvenMertin/SUMO3d

ความคิดเห็น • 80

  • @trananswers
    @trananswers 6 ปีที่แล้ว

    Awesome work

  • @hpaul1790
    @hpaul1790 ปีที่แล้ว

    excellent work!

  • @mayssadardour3604
    @mayssadardour3604 2 ปีที่แล้ว +1

    hello ! please what is the RtM next to component in the window above ? how did you add it to unity ? i actually don't have it on my installed unity version ? and i see that you did all the work with it ! can you please tell me ?

  • @sophiemartin1535
    @sophiemartin1535 3 ปีที่แล้ว +7

    Hey! Would it be possible to have a tutorial on how to run your github file to obtain your result ?

  • @musicmuse09
    @musicmuse09 2 ปีที่แล้ว

    i cant seem to find the same interface as you have in the current unity3d editor. do you know what RtM is replaced with now?

  • @valeriodomenici6583
    @valeriodomenici6583 6 ปีที่แล้ว +6

    Hey! I was trying to do a model of Sumo for my thesis! Could you help me for doing it 3D?? It would be awesome

  • @pcs_PradeepJha
    @pcs_PradeepJha 2 ปีที่แล้ว +1

    How have u synced both... pls provide some link for reference

  • @bimwerx
    @bimwerx 4 ปีที่แล้ว +1

    Hi, this is excellent work. Are you able to disclose some more information on the add-ins that imports the SUMO network? Do you have a sample model that we may look at?
    Thanks in advance.

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว +1

      Hi! Please check my video discription, I recently uploaded the code. Maybe it will help you!

    • @bimwerx
      @bimwerx 4 ปีที่แล้ว

      @@Svenman11 Thank you!

  • @ziad_jkhan
    @ziad_jkhan 7 ปีที่แล้ว

    Nice approach but does the reliance on SUMO make it a Windows-only solution?

    • @Svenman11
      @Svenman11  7 ปีที่แล้ว +2

      SUMO runs on Linux as well. So I don't see any problems running this software in Linux

  • @MikaelVaivre
    @MikaelVaivre 7 ปีที่แล้ว +4

    Amazing. Do you plan to opensource your port?

    • @Svenman11
      @Svenman11  7 ปีที่แล้ว +2

      I will see if I can do this, but at the moment I dont know

    • @brylie
      @brylie 6 ปีที่แล้ว +1

      multirotor I am also very interested in checking out the source.
      I would like to try a similar experiment with the Godot engine ☺

    • @coenheems
      @coenheems 5 ปีที่แล้ว +1

      Dear Multirotor it would be great to have your source is it avaiable?

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว +1

      Hi! Please check my video discription, I recently uploaded the code. Maybe it will help you!

  • @yessinekammoun1997
    @yessinekammoun1997 3 ปีที่แล้ว

    Hi could you handle parking using your code?

  • @naveensachdeva2221
    @naveensachdeva2221 6 ปีที่แล้ว

    Did you use polygons data for drawing buildings into the environment?

    • @Svenman11
      @Svenman11  6 ปีที่แล้ว

      Hey there,
      in the version of the video the buildings are positioned randomly (with collision check with other objects) without any cosideration of polygons defined in SUMO. I already implemeted the parsing of polygons for buildings which is working for a simple extrusion, but it's not that easy to generate 3D-buildings that look plausible and correct from 2D-polygons only.

    • @naveensachdeva2221
      @naveensachdeva2221 6 ปีที่แล้ว

      Okay thanks

    • @saurabhbagh
      @saurabhbagh 4 ปีที่แล้ว

      @@naveensachdeva2221 Dear Naveen ,
      I just wanted to know if you were able to set it up ?

  • @jucescab
    @jucescab 6 ปีที่แล้ว +3

    Graeat Job! How to conect SUMO to Unity? Could you share the library? Please help me!!

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว

      Hi! Please check my video discription, I recently uploaded the code. Maybe it will help you!

  • @henriquegoncalves8783
    @henriquegoncalves8783 3 ปีที่แล้ว

    Hello my friend, all right? I download your project, but i find some erros when I imported it: The type or namespace name 'Spline' could not be found (are you missing a using directive or an assembly reference?)
    What is "Spline"? This is a specific asset?

    • @ayushs3195
      @ayushs3195 3 ปีที่แล้ว

      SPLINE is a CAD term. It means a special line i.e. a polyline with bends and curves. So, not a straight line.

    • @siyathokozankosi5469
      @siyathokozankosi5469 ปีที่แล้ว

      Plus you have to buy the asset from the unity store, it costs $30 at the time of this writing

  • @techknowledge127
    @techknowledge127 3 ปีที่แล้ว

    @Multirotor can u plz send me description link

  • @naveensachdeva2221
    @naveensachdeva2221 6 ปีที่แล้ว

    hey there,
    I am working on same kind of requirement. Will you please let me know how do we generate Trafiic Lights into Unity. As TraCI is not helping much fior Traffic Light System.

    • @Svenman11
      @Svenman11  6 ปีที่แล้ว +1

      Hi there!
      So Tracie also allows to determine all traffic light states as well as setting them. In my approach, I am just polling all traffic light states and change the light within the Unity3D scene accordingly (I just activate or deactivate light sources).
      Here you can find the Tracie-commands for traffic light control:
      Getting values: sumo.dlr.de/wiki/TraCI/Traffic_Lights_Value_Retrieval
      Setting values: sumo.dlr.de/wiki/TraCI/Change_Traffic_Lights_State
      Regards!

    • @naveensachdeva2221
      @naveensachdeva2221 6 ปีที่แล้ว

      Thanks for reply!
      I still not getting position vector of Traffic Light in that.
      What I have found here is that Traffic Light Position Vector is inside Junctions Repository Which is not Available for JAVA Traci Library. Right?
      If not please provide me any direction.
      Thanks

    • @Svenman11
      @Svenman11  6 ปีที่แล้ว

      Hey!
      That is true, I checked my code and saw that I calculated the positions of the Traffic Lights manually. I will post the code part below since I wrote this completely on my own. The idea was to find the end of a lane facing to the intersection, then shifting this coordinate along the line of the lane about a specific distance. The shifted coordinate ist then rotated about 90 degrees about the coodinates of the end of the lane facing to the intersection. Using thins approach it is possible to place the traffic lights allways on the right side of a lane at an intersection.
      The code for traffic light placement (C#):
      [...]
      float trafficLightDistance = 2f;
      foreach (NetFileJunction j in junctions.Values)
      {
      if (j.type == junctionTypeType.traffic_light)
      {
      int index = 0;
      foreach (NetFileLane l in j.incLanes)
      {
      // Calc the position (in line with the lane)
      float x1 = (float)l.shape[0][0];
      float y1 = (float)l.shape[0][1];
      float x2 = (float)l.shape[1][0];
      float y2 = (float)l.shape[1][1];
      float length = (float)Math.Sqrt(Math.Pow(y2 - y1, 2) + Math.Pow(x2 - x1, 2));
      float angle = Mathf.Atan2(y2 - y1, x2 - x1) * 180 / Mathf.PI;
      double ratio = (length - trafficLightDistance) / length;
      float xDest = (float)((1 - ratio) * x1 + ratio * x2);
      float yDest = (float)((1 - ratio) * y1 + ratio * y2);
      // Insert the 3d object, rotate from lane 90° to the right side and then orientate the traffic light towards the vehicles
      GameObject trafficLightPrefab = Resources.Load(PathConstants.pathTrafficLight) as GameObject;
      GameObject trafficLight = GameObject.Instantiate(trafficLightPrefab, new Vector3(xDest, 0, yDest), Quaternion.Euler(new Vector3(0, 0, 0)));
      trafficLight.name = "TrafficLight_" + j.id;
      trafficLight.transform.SetParent(network.transform);
      trafficLight.transform.RotateAround(new Vector3(x2, 0, y2), Vector3.up, -90.0f);
      trafficLight.transform.Rotate(Vector3.up, -angle);
      // Insert traffic light index as empty GameObject into traffic light
      GameObject TLindex = new GameObject("index");
      GameObject TLindexVal = new GameObject(Convert.ToString(index++));
      TLindexVal.transform.SetParent(TLindex.transform);
      TLindex.transform.SetParent(trafficLight.transform);
      }
      }
      }
      Hope this helps ;-)

    • @naveensachdeva2221
      @naveensachdeva2221 6 ปีที่แล้ว

      Thanks for this help, will check your code to get this done.

    • @naveensachdeva2221
      @naveensachdeva2221 6 ปีที่แล้ว

      Hey Multirotor,
      I have got right position of traffic lights.Can you please tell me how do I control their state means signal(Red Yellow Green).
      Thanks

  • @AmyrBorgesFortesNeto
    @AmyrBorgesFortesNeto 6 ปีที่แล้ว +3

    Hello! I am working at the University of Cyprus, and I have interest in collaboration with you.
    I found this model very interesting and I really need to connect it in Unity3D.
    How can I reach you for discussing the possibilities?
    Best,
    Amyr

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว

      Hi! Please check my video discription, I recently uploaded the code. Maybe it will help you!

    • @MsDazdouz
      @MsDazdouz 3 ปีที่แล้ว

      @@Svenman11 hhhh

    • @gabrielmoise6979
      @gabrielmoise6979 2 ปีที่แล้ว

      Hello! Did you find any solution and maybe can you help me? Please

  • @naveensachdeva2221
    @naveensachdeva2221 6 ปีที่แล้ว +1

    Hi there,
    Have ever tried Omnet++ for Network Simualtion Events in Unity3d.

    • @Svenman11
      @Svenman11  6 ปีที่แล้ว

      Hi Naveen,
      it's funny you are asking because that is exactly what is currently in work ;-)
      Regards!

    • @naveensachdeva2221
      @naveensachdeva2221 6 ปีที่แล้ว

      Sorry, But I am understand here is that you only get all data from SUMO server.
      Omnet++ is also included here for network simulation.
      Confirm me If I m wrong!

    • @Svenman11
      @Svenman11  6 ปีที่แล้ว

      Yes you are right, at the moment (the video you see here), there only a communication between the SUMO server and the unity3D environment. But currently, there is work in progress to include Omnet++ with VEINS into this simulation framework for being able to take V2V and V2I communication into account. But there are no results so far which can be presented.

    • @naveensachdeva2221
      @naveensachdeva2221 6 ปีที่แล้ว

      Yes, That what I am asking to you!
      Actually I also working on same thing , What I achieve till now is 1)Getting data from SUMO server and visualizing into Unity3d what you done done above.2)I also able to connect Omnet ++ Vein connection to SUMO means Omnet is controlling SUMO and Updating its information. Unity also work as client to SUMO and getting updated data from SUMO.
      I have one more task that I have to do in my project. You know inside Omnet++ there are Nodes that transmit data to each other. I just need to get that information which node sending data to which node So I can visualize same communication event inside Unity. I don't have much knowledge about Omnet Internal working . Can you please suggest something for same,

    • @Svenman11
      @Svenman11  6 ปีที่แล้ว

      Unfortunately, I can't give you any detailed information about the Omnet++ inclusion into this framework at the moment as I am not the developer but only an adviser for this topic. But I can say that the main topology structure actually consists of a man-in-the-middle network application that capsules relevant traffic between omnet and SUMO and is therefore able to provide this data to other applications such as a 3D-environment.

  • @sala70mn8
    @sala70mn8 3 ปีที่แล้ว

    Hello, is there possibility to send me a project?

  • @bs-lj4jf
    @bs-lj4jf 4 ปีที่แล้ว

    why when the output file has created I just find additional.xml
    map.net.xml
    map.sumo.cfg and start simulation.bat
    why the other files which in the video not created?

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว

      Take a look into the Generate_from_SUMO_NetFile.bat file. This file needs a referenced sumo folder (within the script its called 'sumo-svn'. You can download it from sumo.dlr.de/docs/Downloads.php . You will also need to have a running pyhton environment because the script is calling a python script which generates the files.

    • @bs-lj4jf
      @bs-lj4jf 4 ปีที่แล้ว

      @@Svenman11 but the sumo-svn.meta is already exist in the project
      and I downloaded sumo version 0.31.0
      and still files not created

    • @siyathokozankosi5469
      @siyathokozankosi5469 ปีที่แล้ว

      @@bs-lj4jf that's because sumo-svn is a directory and not just some file. If you actually look at the generatesumo3d.bat file you'll realize that sumo-svn is referenced as an embedded sumo version, you can tell by all the environment variables, once you figured that out it'll work just as described in the video

  • @bs-lj4jf
    @bs-lj4jf 4 ปีที่แล้ว

    hi thank you for the video
    but where can I find the map.rou.xml
    and map.poly.xml
    I can't find them in the project

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว

      Hey! Check out the Generate_from_SUMO_NetFile.bat, this script will generate the necessary files you need. Regards

    • @bs-lj4jf
      @bs-lj4jf 4 ปีที่แล้ว

      @@Svenman11 thanx

    • @bs-lj4jf
      @bs-lj4jf 4 ปีที่แล้ว

      @multirotor but why when the output file has created I just find additional.xml
      map.net.xml
      map.sumo.cfg and start simulation.bat
      why the other files which in the video not created?

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว

      @@ghofrannasr6526 Its located in the GenerateSimulationForUnity3D folder (see git repo). Regards

  • @sargammahajan9022
    @sargammahajan9022 4 ปีที่แล้ว

    We are getting an error related to Spline- declared as a variable but used as a type. How do we proceed further?

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว

      Hey there! I think the problem results from missing SuperSplines references which I used in the scripts but had to remove for github due to license reasons. Check out: assetstore.unity.com/packages/tools/level-design/supersplines-pro-2110

    • @sargammahajan9022
      @sargammahajan9022 4 ปีที่แล้ว

      @@Svenman11 Thank you for replying, but since it is a paid asset is there any alternative for the same?

    • @sala70mn8
      @sala70mn8 3 ปีที่แล้ว

      @@sargammahajan9022 do you find any way?

  • @gabrielmoise6979
    @gabrielmoise6979 2 ปีที่แล้ว +1

    Hi, amazing work! I can't connect Unity3D to Sumo for simulation. Can you help me, please?

    • @siyathokozankosi5469
      @siyathokozankosi5469 ปีที่แล้ว

      Same problem 💁‍♂️, i think it depends on a couple of things 1) your sumo version, 2) your unity version 3) your asset collection, if you can somehow figure out a way to sync all these things , you should be able to reproduce the solution above. Additionally I also figured out that the batch are missing some paths such as the embedded sumo version, that and the fact that if you cannot afford the SuperSplines Pro asset (a very crucial asset for the project) this all likely crumbles and might never see the light of day, so you have to find some work around in an attempt to recreate the solution above. Anyway sorry for the long essay and lack of solutions I'm just sharing my experience here since I also require assistance as this is truly a unique project.

    • @ahmadmohammadi2396
      @ahmadmohammadi2396 ปีที่แล้ว

      @@siyathokozankosi5469 I am also looking for a solution for this integration, have you figured out a way?

  • @TheDutchFighters
    @TheDutchFighters 4 ปีที่แล้ว

    you should add a detector on the 2d map for if a player drives through a red light.
    You should add police to.

  • @zhiweiheng1249
    @zhiweiheng1249 4 ปีที่แล้ว

    Is that possible to show more how you make this?

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว

      Hi! Please check my video discription, I recently uploaded the code. Maybe it will help you!

  • @educatingtheheartngo7256
    @educatingtheheartngo7256 6 ปีที่แล้ว +1

    Can you please explain to me the steps to connect SUMO with unity?? can you help me with the code??

    • @Svenman11
      @Svenman11  6 ปีที่แล้ว +2

      Hi! Unfortunately I cannot make the code public at the moment because of copyright reasons. But it is not that hard to do, but one has to invest some time ;-) . I will explain shortly what to do.
      There are two parts: (1) The communication with SUMO and (2) The environment/terrain generation:
      For (1): I ported the Traci4J Library (github.com/egueli/TraCI4J) to c# for being able to include this code into my Unity3D project. Therefore I used a tool (dont remember the name, there are various) which converts java code to c# code for lazyness reasons. I then just removed all the erros within the code (java e.g. has unsigned bytes, c# can distinguish between them). Then it is possible to connect to a SUMO instance via UDP connection and to use the standard commands from TraCi (sumo.dlr.de/wiki/TraCI). With these commands you can get all vehicles, their positions etc. as well as almost everything else from the simulation. I then placed 3D objects to the scene (vehicles) and update their positions in every step with the aforementioned data from SUMO. That's all.
      For (2): I used XSD.exe to create c# classes from the SUMO map.net.xsd file (xml-description file for the network, see here stackoverflow.com/questions/5217665/how-to-generate-net-4-0-classes-from-xsd). With these classes it is very easy to parse any map.net.xml as they are all in the structure of the given xsd (which btw is included in every SUMO release). Using the parsed map.net data, I just place meshes where the roads are located, all the information is given within the map.net.xml (there are coordinates for all vertices and edges, even the polygons for the intersections etc.). You will need to place textures on them. The terrain is then generated with some random placement algorithm, you can be creative there.
      Hope this helps a little bit ;-)

    • @educatingtheheartngo7256
      @educatingtheheartngo7256 6 ปีที่แล้ว +2

      Thank you multirotor. I hope it works. I really appreciate your quick reply :-)

    • @karlozzz92
      @karlozzz92 6 ปีที่แล้ว +1

      Hii have anyone done it and willing to share the code ? I am writing my master thesis in Deep Reinforcement learning ! I cannot afford time to do it by my self

  • @coenheems
    @coenheems 5 ปีที่แล้ว

    Dear Multirotor I was wandering if you have are able to have your source since it has been a year?

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว

      Hi! Please check my video discription, I recently uploaded the code. Maybe it will help you!

  • @arturkaczan1776
    @arturkaczan1776 4 ปีที่แล้ว

    Hello, is there possibility to send me a project? Best wishes.

    • @zhiweiheng1249
      @zhiweiheng1249 4 ปีที่แล้ว

      Same here

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว

      Hi! Please check my video discription, I recently uploaded the code. Maybe it will help you!

  • @Leosan1909
    @Leosan1909 4 ปีที่แล้ว

    Share the library please.

    • @Svenman11
      @Svenman11  4 ปีที่แล้ว

      Hi! Please check my video discription, I recently uploaded the code. Maybe it will help you!

  • @igorboroda1626
    @igorboroda1626 4 ปีที่แล้ว

    O_o