Tamás Tettamanti, Tamás Luspay, István Varga

Road Traffic Modeling and Simulation

Tutorial


4.2.3. The whole MATLAB script of the TraCI example

 
%% SUMO TraCI example clear all close all format compact %smaller line spacing in Command Window clc %clears the Command Window %% Folder to add containing TraCI classes/methods and traci4matlab.jar tracisubfolders=genpath('/home/tamas/Downloads/traci4matlab/'); addpath(tracisubfolders) javaaddpath('/home/tamas/Downloads/traci4matlab/traci4matlab.jar') %% Main projectPath = [pwd filesep 'autonomous.sumocfg']; try system(['sumo-gui' ' -c ' projectPath ' --remote-port 8813' ' --step-length 0.1' ' --start &']); catch err end %initialization [traciVersion,sumoVersion] = traci.init() %test car's ID car1 = '1.0'; %sets the visualization scheme traci.gui.setSchema('View #0', 'real world'); %gets vehicle IDs vehicles= traci.vehicle.getIDList(); %sets how the values set by setSpeed() and slowDown() shall be treated traci.vehicle.setSpeedMode(car1,0); while i < 3600*10 %10 simulation steps (car following model) per second %this runs one simulation step traci.simulationStep(); %this command is used for tracking the car during the simulation traci.gui.trackVehicle('View #0', car1); %sets the speed of car1 to 20 (m/s) traci.vehicle.setSpeed(car1,20); %get actual speed of car1 disp(['Speed: ' num2str(traci.vehicle.getSpeed(car1)) ' m/s']); %lane nr. on which car1 is traveling currently disp(['Actual Lane ID: ' num2str(traci.vehicle.getLaneID(car1))]); %lane position (distance from the front bumper to the start of lane in [m]) disp(['Lane Pos.: ' num2str(traci.vehicle.getLanePosition(car1)) ' m']); i=i+1; end traci.close();


Kiadó: Akadémiai Kiadó

Online megjelenés éve: 2019

ISBN: 978 963 454 295 7

On the one hand, the workbook serves the English Master Program of Autonomous Vehicle Control Engineer at the Faculty of Transportation Engineering and Vehicle Engineering of Budapest University of Technology and Economics. The exercises provide basic tutorial training supporting the course of Road Traffic Modeling and Control. On the other hand, the traffic modeling and simulation basics given in this book also lay the groundwork for practical and theoretical contributions in the field of intelligent traffic systems and traffic control.

Hivatkozás: https://mersz.hu/tettamanti-luspay-varga-road-traffic-modeling-and-simulation//

BibTeXEndNoteMendeleyZotero

Kivonat
fullscreenclose
printsave