This repository is to interlock SUMO simulator to MORAI simulator Traffic flow generated from SUMO simulator is visualized in MORAI Simulator via ROS communication
Overall repository is based on Unbuntu 18.04.6 LTS and ROS Melodic
sudo add-apt-repository ppa:sumo/stable
sudo apt-get update
sudo apt-get install sumo sumo-tools sumo-doc
for setting environment variable SUMO_HOME=/usr/share/sumo, refer SUMO Environment Setting
SUMO Version 1.10.0 is used
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo apt update
sudo apt install ros-melodic-desktop-full
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo rosdep init
rosdep update
More detailed description, please refer to ROS
This repository is tested only for the openDRIVE based map format.
In order to get test_map.xodr files for the map, please contect MORAI
If you already have test_map.xodr files, you need to move test_map.xodr files to sumo2morai/sumo/xodrs
Then test_map.xodr file has to be converted to SUMO net file with following command
netconvert --opendrive sumo2morai/sumo/xodrs/test_map.xodr -o sumo2morai/sumo/nets/test_map.net.xml
Using the SUMO net file, random trips can be generated in route file as belows.
python /usr/share/sumo/tools/randomTrips.py -n sumo2morai/sumo/nets/suburb_02.net.xml -e 3600 -r sumo2morai/sumo/routes/suburb_02.rou.xml --period 2 --binomial 2 --trip-attributes 'departLane="0" departSpeed="max" departPos="0"' --weights-prefix sumo2morai/sumo/weights/suburb_02 --random
More detail information on the random trip of SUMO simulator, please refer SUMO-randomTrips.py
Finally, in sumo2morai/sumo/sumocfgs/, please make test_map.sumocfg file with text editor.
<configuration>
<input>
<net-file value="../nets/test_map.net.xml"/>
<route-files value="../routes/test_map.rou.xml"/>
</input>
<time>
<begin value="0"/>
<end value="3600"/>
</time>
</configuration>
For specifying the map and trips generated in SUMO simulation configuration,
find Line 123 in test.py in src/npc_ghost_test/scrips which is follows.
traci.start([sumoBinary, "-c", "sumo/sumocfgs/test_map.sumocfg","--step-length", "0.01"])
you need to modify above command with your custom map name as
traci.start([sumoBinary, "-c", "sumo/sumocfgs/KAIST_Munji_Campus.sumocfg","--step-length", "0.01"])
In sumo2morai/,
catkin_make
source devel/setup.bash
- Run MORAI Simulator and select test_map
- In new terminal
roscore
- In new terminal,
cd <repository_root>/sumo2morai
source devel/setup.bash
roslaunch rosbridge_server rosbridge_websocket.launch
- In MORAI simulator, PlayMode -> Ghost -> NPC Ghost Mode -> Apply
- In new terminal,
cd <repository_root>/sumo2morai
source devel/setup.bash
rosrun npc_ghost_test test.py
- In SUMO simulator, make Delay(ms) as 1000
- run the SUMO simulator