Path: blob/main/tests/complex/traci/vehicle/cfmodel/CACC/runner.py
169779 views
#!/usr/bin/env python1# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2# Copyright (C) 2009-2025 German Aerospace Center (DLR) and others.3# This program and the accompanying materials are made available under the4# terms of the Eclipse Public License 2.0 which is available at5# https://www.eclipse.org/legal/epl-2.0/6# This Source Code may also be made available under the following Secondary7# Licenses when the conditions for such availability set forth in the Eclipse8# Public License 2.0 are satisfied: GNU General Public License, version 29# or later which is available at10# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later1213# @file runner.py14# @author Lena Kalleske15# @author Daniel Krajzewicz16# @author Michael Behrisch17# @author Jakob Erdmann18# @author Leonhard Luecken19# @date 2009-03-262021# @author Robert Alms22# @date 2023-02.232324from __future__ import absolute_import25from __future__ import print_function2627import os28import sys2930# we need to import python modules from the $SUMO_HOME/tools directory31try:32sys.path.append(os.path.join(os.environ.get("SUMO_HOME", os.path.join(33os.path.dirname(__file__), "..", "..", "..", "..")), "tools"))34except ImportError:35sys.exit("please declare environment variable 'SUMO_HOME'")36import traci37from sumolib import checkBinary383940def run(mode, fname):41traci.start([sumoBinary,42"-n", "input_net.net.xml",43"-r", "input_routes.rou.xml",44"--fcd-output", fname,45"--fcd-output.attributes", "speed",46"--default.speeddev", "0",47"--step-length", "0.5",48"--no-step-log"])4950traci.vehicle.setParameter("ego", "carFollowModel.caccCommunicationsOverrideMode", str(mode))51print("Set OverrideMode: %s , get OverrideMode: %s" % (52mode,53traci.vehicle.getParameter("ego", "carFollowModel.caccCommunicationsOverrideMode")))5455while traci.simulation.getMinExpectedNumber() > 0:56traci.simulationStep()57traci.close()585960sumoBinary = checkBinary('sumo')61for mode, fname in zip(range(0, 4), ['fcd.xml', 'fcd2.xml', 'fcd3.xml', 'fcd4.xml']):62run(mode, fname)636465