-1

In the example/sumo/grid.py, we know how to add tl with detector in the network because that is the net we build manually. Now the network is .net.xml and it has included all the tls information and I can't use the add() to add the tls with detector to cover the old one. Anyone know how to solve the problem?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
tmaccc
  • 1
  • Please provide enough code so others can better understand or reproduce the problem. – Community Sep 17 '21 at 06:52
  • You can change the traffic light type to actuated in netedit if it is that what you want. The detector will be added then automatically. – Michael Oct 22 '21 at 14:16
  • @Michael Thank you so much for your reply. Now the problem is "I have a net.xml format map, and I want to add a traffic light in a junction which has no traffic light originally. I don't want use netedit or other software to set it, instead, I want to use python to edit and through sumo to set it. Do you have any solution?" – tmaccc Nov 01 '21 at 06:35
  • @Michael Hope you can help me. Let me make it clear. I have a task. I got a map in net.xml where the junction(node) has two types, one is traffic light and other is Not-TL. Now I need to set a traffic light in Not-TL junction. I don't want to use netedit or josm applications to set it. Instead, I want to use python Traci or sumo tools to make it. Have you done it before? – tmaccc Nov 01 '21 at 06:42
  • @Michael For example, I want to add a tl in node '30769868' of a xml Map I got, I use the add()function from the Traci python like "tl_logic.add(node_id = '30769868', tls_type ='actuated', phases = phases)", but "Error: No initial signal plan loaded for tls '30769868'." happened. – tmaccc Nov 01 '21 at 07:35

1 Answers1

0

You cannot change the junction type using TraCI or sumolib. What you could do is to convert the net to plain XML using netconvert -s input.net.xml --plain input then parse the resulting input.nod.xml and change the junction type for the relevant junction, then convert it back using netconvert -n changed_input.nod.xml -e input.edg.xml -x input.con.xml -i input.tll.xml -o output.net.xml.

Michael
  • 3,510
  • 1
  • 11
  • 23
  • Thanks. It really helps. Actually I want to control this light-setting process via TraCI or Sumolib, but it failed. Now I would try to use python script to get interaction with Ubuntu terminal in order to set the light. Do you agree that it could work? – tmaccc Nov 02 '21 at 02:45