### Setup vcpkg for SUMO Libraries Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/Windows_Build.md Steps to set up vcpkg and install necessary libraries for building SUMO. Avoid running 'vcpkg integrate install' unless intended. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg install arrow gdal xerces-c gettext fmt eigen3 ``` -------------------------------- ### Start SUMO Simulation in Java Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Libsumo.md Example Java code to start, step through, and close a SUMO simulation using libsumo. Preloading libraries might be necessary on Windows. ```java import org.eclipse.sumo.libsumo.Simulation; import org.eclipse.sumo.libsumo.StringVector; public class Test { public static void main(String[] args) { Simulation.preloadLibraries(); Simulation.start(new StringVector(new String[] {"sumo", "-c", "test.sumocfg"})); for (int i = 0; i < 5; i++) { Simulation.step(); } Simulation.close(); } } ``` -------------------------------- ### Start SUMO Simulation in C# Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Libsumo.md Example C# code to start, step through, and close a SUMO simulation using libsumo. Ensure SWIG-generated bindings and libsumocs.dll are correctly referenced. ```csharp using Eclipse.Sumo.Libsumo; internal class Program { static void Main(String[] args) { Simulation.start(new StringVector(new String[] {"sumo", "-c", "test.sumocfg"})); for (int i = 0; i < 5; i++) { Simulation.step(); } Simulation.close(); } } ``` -------------------------------- ### View netgenerate help output Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Basics/Using_the_Command_Line_Applications.md Example of the information printed when an application is started without parameters. ```text Eclipse SUMO netgenerate Version {{Version}} Build features: Linux-4.1.39-56-default Proj GDAL GUI Copyright (C) 2001-2020 German Aerospace Center (DLR) and others; https://sumo.dlr.de License EPL-2.0: Eclipse Public License Version 2 Use --help to get the list of options. ``` -------------------------------- ### Run Examples and Tests Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/MacOS_Build.md Build examples and execute the unit test suite. ```bash cd $SUMO_HOME CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target examples test ``` -------------------------------- ### Install Proj, GDAL, and Fox Libraries Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/Linux_Build_Libraries.md Build and install Proj, GDAL, and Fox libraries from source. Use `--prefix=$HOME` for manual installation without root privileges. The 'make install' for GDAL may show Python binding errors, which can be safely ignored. ```bash tar xzf fox-1.6.36.tar.gz cd fox-1.6.36 ./configure --prefix=$HOME && make install cd .. tar xzf gdal-1.5.1.tar.gz cd gdal-1.5.1 ./configure --prefix=$HOME && make install cd .. tar xzf proj-4.6.0.tar.gz cd proj-4.6.0 ./configure --prefix=$HOME && make install ``` -------------------------------- ### Start SUMO Simulation in C++ Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Libsumo.md Example C++ code to start, step through, and close a SUMO simulation using libsumo. Define HAVE_LIBSUMOGUI if using the GUI on Windows or with a custom build. ```cpp #include #define HAVE_LIBSUMOGUI // if you are on Windows or have libsumo compiled yourself without GUI you should remove this line #include using namespace libsumo; int main(int argc, char* argv[]) { Simulation::start({"sumo", "-c", "test.sumocfg"}); for (int i = 0; i < 5; i++) { Simulation::step(); } Simulation::close(); } ``` -------------------------------- ### Configure SUMO Build with Installed Libraries Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/Linux_Build_Libraries.md Configure the SUMO build process after installing required libraries. Specify the installation paths for Fox, Proj/GDAL, and Xerces using the respective flags. ```bash ./configure --with-fox-config=$HOME/bin/fox-config --with-proj-gdal=$HOME --with-xerces=$HOME ``` -------------------------------- ### Install Homebrew Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/MacOS_Build.md Command to install Homebrew if it is not already present on the system. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" ``` -------------------------------- ### Install Googletest Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/MacOS_Build.md Install the testing framework required for unit tests. ```bash brew install googletest ``` -------------------------------- ### Start SUMO Simulation in Python Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Libsumo.md Use this snippet to start a SUMO simulation using libsumo in Python. Ensure libsumo is installed via pip. ```python import libsumo libsumo.start(["sumo", "-c", "test.sumocfg"]) libsumo.simulationStep() ``` -------------------------------- ### Edge-Based Origin-Destination Restriction Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Tools/Turns.md Define OD counts based on specific start and end edges. This example counts routes starting on edge A and ending on edge D. ```xml ``` -------------------------------- ### Serve documentation locally Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/README.md Starts the development server to preview changes. Use --dirtyreload for faster incremental builds. ```bash mkdocs serve ``` ```bash mkdocs serve --dirtyreload ``` -------------------------------- ### TraaS Example: Connect Multiple Clients (Client 2) Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/TraCI/TraaS.md Example Java code demonstrating how to connect as the second client using TraaS. This is part of a multi-client setup. ```java package data; import java.io.IOException; import de.tamu.traas.client.TraCIException; import de.tamu.traas.client.TraCIConnection; import de.tamu.traas.client.Simulation; public class MultiClient2 { public static void main(String[] args) { TraCIConnection conn = null; try { conn = new TraCIConnection("localhost", 8080); conn.connect(); System.out.println("Client 2 connected."); // Do something as client 2 System.out.println("Time: " + conn.do_job_get(Simulation.getTime())); } catch (IOException | TraCIException e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } } ``` -------------------------------- ### Start SUMO Simulation Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Tutorials/Trace_File_Generation.md Use this command to start a SUMO simulation with a given configuration file. ```bash sumo -c myConfig.sumocfg ``` -------------------------------- ### Example Configuration Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Specification/Containers.md An XML example demonstrating the usage of containers, tranships, transports, and stops within a Sumo route. ```APIDOC # Example The following is an example for a container which gets transhiped to a train station, gets transported by a train, gets unloaded and transhiped to a place, where it's stored (stopped) for some time and finally gets transported again. ```xml ``` ``` -------------------------------- ### TraaS Example: Connect Multiple Clients (Client 1) Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/TraCI/TraaS.md Example Java code demonstrating how to connect as the first client using TraaS. This is part of a multi-client setup. ```java package data; import java.io.IOException; import de.tamu.traas.client.TraCIException; import de.tamu.traas.client.TraCIConnection; import de.tamu.traas.client.Simulation; public class MultiClient1 { public static void main(String[] args) { TraCIConnection conn = null; try { conn = new TraCIConnection("localhost", 8080); conn.connect(); System.out.println("Client 1 connected."); // Do something as client 1 System.out.println("Time: " + conn.do_job_get(Simulation.getTime())); // Wait for client 2 Thread.sleep(5000); } catch (IOException | TraCIException | InterruptedException e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } } ``` -------------------------------- ### Run SUMO GUI (Network Visualization) Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Tutorials/Output_Parsing.md Launches the SUMO graphical user interface to visualize the generated network. ```bash sumo-gui -n circular.net.xml ``` -------------------------------- ### Set up Virtual Environment for SUMO Testing Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Downloads.md Create and activate a Python virtual environment, install SUMO, and print the SUMO_HOME path. This is useful for testing new SUMO versions or nightly builds without affecting your system's Python installation. ```bash python -m venv sumo_test . sumo_test/bin/activate pip install eclipse-sumo python -c "import sumo; print('SUMO_HOME=' + sumo.SUMO_HOME)" ``` -------------------------------- ### Configure and Build SUMO via Command Line Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/Windows_Build.md Commands to initialize a build directory and generate the Visual Studio solution using CMake. ```bash cd D:\projects\sumo mkdir cmake-build && cd cmake-build cmake .. -G "Visual Studio 16 2019 Win64" cmake --help cmake --build . --config Release ``` -------------------------------- ### CMake Python Configuration Output Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/MacOS_Build.md Example output from CMake when detecting the default Python 2.7 installation. ```text -- Found PythonInterp: /usr/bin/python (found version "2.7.16") -- Found Python: /usr/bin/python ... -- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.16") ``` -------------------------------- ### GUI Settings File Example Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/sumo-gui.md Example of a GUI settings file (viewsettings.xml) defining viewport, delay, decals, and breakpoints. ```xml ... ``` -------------------------------- ### Define a GitHub Actions workflow for SUMO integration Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Developer/Github_Actions_CI_Test.md A YAML configuration for a GitHub Actions workflow that clones repositories, installs dependencies, and runs tests. This example includes matrix builds for different SUMO installation methods. ```yaml name: linux-build # workflow name as stated under your project's GitHub 'Actions' tab on: # define triggers on which to run this workflow push: pull_request: schedule: - cron: '42 0 * * *' jobs: # define individual jobs to run build: # ID of this job runs-on: ubuntu-latest # VM type to run this job on env: # define environment variables for this job OMNET_VERSION: 5.6.2 strategy: # define job variations fail-fast: false # do not cancel all in-progress jobs if any job variation fails matrix: # define variation parameters and their values sumo_build: [ubuntu, ppa, nightly] steps: # define this job's individual steps - name: Cloning Veins # this step's name uses: actions/checkout@v2 # predefined and reusable action for this step (see https://github.com/actions/checkout) with: # set values for the predefined action's parameters path: src/veins - name: Cloning OMNeT++ uses: actions/checkout@v2 with: repository: omnetpp/omnetpp ref: omnetpp-${{ env.OMNET_VERSION }} # evaluate the environment variable OMNET_VERSION defined above path: src/omnetpp - name: Preparing Build System run: | # define a custom multi-line command (instead of a reusable action) for this step if [[ "${{ matrix.sumo_build }}" == "ppa" ]]; then sudo add-apt-repository ppa:sumo/stable; fi sudo apt-get update sudo apt-get install build-essential gcc g++ bison flex perl python3 libxml2-dev zlib1g-dev default-jre doxygen graphviz - name: Installing SUMO from repo if: matrix.sumo_build != 'nightly' # only run this step if the condition is true run: | sudo apt-get install sumo sumo-tools echo "SUMO_HOME=/usr/share/sumo" >> $GITHUB_ENV - name: Installing SUMO from PyPI if: matrix.sumo_build == 'nightly' run: | python -m pip install --index-url https://test.pypi.org/simple/ eclipse-sumo python -c "import sumo; print('SUMO_HOME=' + sumo.SUMO_HOME)" >> $GITHUB_ENV - name: Adapting PATH run: | echo "PATH=$PWD/src/omnetpp/bin:$SUMO_HOME/bin:$PATH" >> $GITHUB_ENV cat $GITHUB_ENV - name: Building OMNeT run: | cd src/omnetpp cp configure.user.dist configure.user ./configure WITH_TKENV=no WITH_QTENV=no WITH_OSG=no WITH_OSGEARTH=no make -j4 - name: Building Veins run: | cd src/veins ./configure make -j4 - name: Running Veins Test run: | cd src/veins/examples/veins echo $SUMO_HOME; sumo ../../bin/veins_launchd -vv --daemon -L veins_launchd.log ./run -u Cmdenv - name: Upload Test log if: ${{ always() }} uses: actions/upload-artifact@v2 # see https://github.com/actions/upload-artifact with: name: veins-${{ matrix.sumo_build }}.log path: | src/veins/examples/veins/veins_launchd.log ``` -------------------------------- ### C++ Simulation Control Example Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Libtraci.md Basic C++ implementation to start, step, and close a SUMO simulation using libtraci headers. ```cpp #include #include using namespace libtraci; int main(int argc, char* argv[]) { Simulation::start({"sumo", "-n", "net.net.xml"}); for (int i = 0; i < 5; i++) { Simulation::step(); } Simulation::close(); } ``` -------------------------------- ### Initialize Application Options Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Developer/Implementation_Notes/Options_Sub_System.md Set application metadata and descriptions within the OptionsCont container. ```cpp OptionsCont &oc = OptionsCont::getOptions(); // give some application descriptions oc.setApplicationDescription("Road network importer / builder for the road traffic simulation SUMO."); #ifdef WIN32 oc.setApplicationName("netconvert.exe", "SUMO netconvert Version " + (string)VERSION_STRING); #else oc.setApplicationName("sumo-netconvert", "SUMO netconvert Version " + (string)VERSION_STRING); #endif ``` -------------------------------- ### Example TraCIAPI Client Library Usage Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/TraCI/C++TraCIAPI.md Illustrates basic usage of the TraCIAPI client library, including getting the current simulation time and advancing the simulation. ```cpp SUMOTime t = simulation.getCurrentTime(); std::vector = edge.getIDList(); ``` -------------------------------- ### Prepare and Upload Ubuntu PPA Package Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Developer/HowToRelease.md Prepares a special source release, builds the Ubuntu package, and uploads it to the PPA. Requires devscripts and all SUMO dependencies to be installed. ```bash tar xzf sumo_{{Version}}.orig.tar.gz cd sumo-{{Version}} && tools/build_config/ubuntu_release.sh dput -f ppa:sumo/stable ../sumo_{{Version}}*_source.changes ``` -------------------------------- ### Start OSM Web Wizard Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Tutorials/OSMWebWizard.md Invoke the OSM Web Wizard script from the tools directory in your SUMO installation. This command initiates the web-based interface for scenario generation. ```bash python osmWebWizard.py ``` -------------------------------- ### SUMO Configuration File Example Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/sumo-gui.md Example of a SUMO configuration file (.sumocfg) that specifies network and GUI settings files. ```xml ``` -------------------------------- ### Install SUMO on Ubuntu Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Downloads.md Add the stable PPA, update package lists, and install SUMO and related tools on Ubuntu systems. ```bash sudo add-apt-repository ppa:sumo/stable sudo apt-get update sudo apt-get install sumo sumo-tools sumo-doc ``` -------------------------------- ### VISSIM/VISUM O-Format Example Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Demand/Importing_O/D_Matrices.md This format lists each origin, destination, and the amount in a single line. Lines starting with '*' are comments and can be omitted. The second non-comment line specifies the time range. ```plaintext $OR;D2 * From-Time To-Time 7.00 8.00 * Factor 1.00 * some * additional * comments 1 1 1.00 1 2 2.00 1 3 3.00 2 1 4.00 2 2 5.00 2 3 6.00 3 1 7.00 3 2 8.00 3 3 9.00 ``` -------------------------------- ### TAZ-Based Origin-Destination Restriction Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Tools/Turns.md Define OD counts between Traffic Assignment Zones (TAZs). This example counts routes starting on any edge within TAZ '1_2' and ending on any edge within TAZ '2_0'. ```xml ``` -------------------------------- ### Install Core Dependencies Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/MacOS_Build.md Install essential libraries required for compiling and executing SUMO. ```bash brew install --cask xquartz brew install xerces-c fox proj gdal gl2ps ``` -------------------------------- ### Retrieve Time Loss for All Vehicles Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/TraCI/Interfacing_TraCI_from_Python.md This example demonstrates how to subscribe to vehicle speeds around a junction and calculate the total time loss for all vehicles in the network over time. It requires setting up a SUMO configuration and starting the simulation. ```python import traci import traci.constants as tc traci.start(["sumo", "-c", "my.sumocfg"]) # pick an arbitrary junction junctionID = traci.junction.getIDList()[0] # subscribe around that junction with a sufficiently large # radius to retrieve the speeds of all vehicles in every step traci.junction.subscribeContext( junctionID, tc.CMD_GET_VEHICLE_VARIABLE, 1000000, [tc.VAR_SPEED, tc.VAR_ALLOWED_SPEED] ) stepLength = traci.simulation.getDeltaT()) while traci.simulation.getMinExpectedNumber() > 0: traci.simulationStep() scResults = traci.junction.getContextSubscriptionResults(junctionID) halting = 0 if scResults: relSpeeds = [d[tc.VAR_SPEED] / d[tc.VAR_ALLOWED_SPEED] for d in scResults.values()] # compute values corresponding to summary-output running = len(relSpeeds) halting = len([1 for d in scResults.values() if d[tc.VAR_SPEED] < 0.1]) meanSpeedRelative = sum(relSpeeds) / running timeLoss = (1 - meanSpeedRelative) * running * stepLength print(traci.simulation.getTime(), timeLoss, halting) traci.close() ``` -------------------------------- ### Run SUMO GUI with Configuration Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Tutorials/CityMobil.md Command to launch the SUMO graphical user interface with a specific scenario configuration file. ```bash sumo-gui park05_cyber.sumocfg ``` -------------------------------- ### SUMO Counting Data XML Output Example Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Tutorials/2025.md This XML structure represents hourly traffic counts, generated by edgeDataFromFlow.py. It includes intervals with start and end times, edge IDs, and the counted volumes for different vehicle types (e.g., cars, trucks). ```xml ``` -------------------------------- ### Run sumo-gui with Edge Data Visualization Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Tools/Visualization.md Use this command to launch sumo-gui and visualize edge data. Specify the network file, edge data files, step length, and end time. Ensure the edge data files contain attributes that can be used for coloring and scaling. ```bash sumo-gui -n NET --edgedata-files FILE --step-length 3600 --end 24:0:0 ``` -------------------------------- ### Build JuPedSim with Custom Install Directory Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/Linux_Build.md Specify an alternative installation directory for JuPedSim if you do not want to install it system-wide. This allows for local installation. ```bash cmake -B build -DCMAKE_INSTALL_PREFIX=$PWD/../jupedsim-install . cmake --build build cmake --install build ``` -------------------------------- ### Install Executable Source: https://github.com/eclipse-sumo/sumo/blob/main/src/polyconvert/CMakeLists.txt Installs the 'polyconvert' executable to the 'bin' directory as a runtime component. This makes the executable available after installation. ```cmake install(TARGETS polyconvert RUNTIME DESTINATION bin COMPONENT runtime) ``` -------------------------------- ### Build and Install Xerces-C Library Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/Linux_Build_Libraries.md Build and install the Xerces-C library from source. This process involves autoconf and a specific configure script. Ensure the XERCESCROOT environment variable is set correctly. ```bash tar xzf xerces-c-current.tar.gz export XERCESCROOT=${HOME}/xerces-c-src_3_0_1 cd $XERCESCROOT/src/xercesc autoconf ./runConfigure -plinux -cgcc -xg++ -minmem -nsocket -tnative -rpthread -P$HOME make make install ``` -------------------------------- ### Install Google Test on Older Ubuntu Versions Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Developer/Unit_Tests.md Follow these steps to install Google Test on older Ubuntu versions. This involves installing build tools and CMake, then compiling and installing Google Test from source. ```bash sudo apt install libgtest-dev build-essential cmake cd /usr/src/googletest sudo cmake . sudo cmake --build . --target install ``` -------------------------------- ### Build SUMO on Ubuntu Source: https://github.com/eclipse-sumo/sumo/blob/main/README.md Steps to build SUMO on Ubuntu, including installing dependencies and compiling the source code. ```bash cd # please insert the correct directory name here export SUMO_HOME="$PWD" sudo apt-get install $(cat build_config/build_req_deb.txt build_config/tools_req_deb.txt) cmake -B build . cmake --build build -j$(nproc) ``` -------------------------------- ### Run SUMO Simulation Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Tutorials/Hello_SUMO.md Command to start a SUMO simulation using a configuration file. ```bash sumo -c hello.sumocfg ``` -------------------------------- ### Install Homebrew on macOS Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/Installing/index.md Use this command to install Homebrew if it is not already present on your system. This is a prerequisite for installing SUMO via Homebrew. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Install SUMO Data Directory Source: https://github.com/eclipse-sumo/sumo/blob/main/CMakeLists.txt Installs the 'data/' directory to the specified DATA_PATH destination, ensuring that all necessary data files are included in the installation. ```cmake install(DIRECTORY data/ DESTINATION ${DATA_PATH}data COMPONENT data) ``` -------------------------------- ### Minimal GUI Settings File Example Source: https://github.com/eclipse-sumo/sumo/blob/main/docs/web/docs/sumo-gui.md Minimal GUI settings file referencing a predefined scheme by name. ```xml ```