'How to add detector in the traffice light junction?

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?



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael