%% Create S-Curve Road and Export to ASAM OpenDRIVE Format
% Create the driving scenario with one road having an S-curve.

scenario = drivingScenario;
roadcenters = [-35 20 0; -20 -20 0; 0 0 0; 20 20 0; 35 -20 0];

% Create the lanes and add them to the road.

lm = [laneMarking("Solid",Color="w") ...
     laneMarking("Dashed",Color="y") ...
     laneMarking("Dashed",Color="y") ...
     laneMarking("Solid",Color="w")];
ls = lanespec(3,Marking=lm);
road(scenario,roadcenters,"Lanes",ls);

% Plot the scenario.

plot(scenario)

% Export the road network in the scenario to ASAM OpenDRIVE® file.

fileName = "scurveroad.xodr";
export(scenario,"OpenDRIVE",fileName,OpenDRIVEVersion=1.6)

% You can import the ASAM OpenDRIVE file to MATLAB® workspace by using the roadNetwork function.

scenario = drivingScenario;
roadNetwork(scenario,"OpenDRIVE",fileName)
plot(scenario)

% Copyright 2020-21 The MathWorks, Inc.