How to import matlab function in driving scenario app

3 Ansichten (letzte 30 Tage)
Muhammad Sohail
Muhammad Sohail am 27 Mär. 2022
I have created a driving scenario using driving scenario designer app, and then exported as matlab functions after some changings i again want to test those changes in driving scenario app. But i don't know with which extensiopn i need to save the file? I am unable to import that scenario/function from matlab to driving scenario app

Antworten (1)

Anjaneyulu Bairi
Anjaneyulu Bairi am 7 Jan. 2025
Hi,
To test the changes made to a scenario exported from the Driving Scenario Designer app in MATLAB, follow these steps:
Export the Scenario:
  • Export your created scenario to a MATLAB function using the Driving Scenario Designer app.
Modify the MATLAB Function:
  • Open the exported MATLAB function in MATLAB.
Save the Scenario Data:
  • At the end of the function, add the following line to save the scenario data to the workspace:
save("data.mat") % It will save the data to workspace
Launch the drivingScenarioDesigne app:
  • Now Run the below command to open the scenario in drivingScenarioDesigner app
drivingScenarioDesigner(data.scenario) % Here we are trying to load the scenario into drivingScenario app
% please check the scenario object name and modify it accordingly
  • Now you can visualize the changed scenario in "drivingScenarioDesinger" application.
Please refer the below code for reference:
function scenario = createDrivingScenario()
% createDrivingScenario Returns the drivingScenario defined in the Designer
% Generated by MATLAB(R) 24.2 (R2024b) and Automated Driving Toolbox 24.2 (R2024b).
% Generated on: 07-Jan-2025 14:19:08
% Construct a drivingScenario object.
scenario = drivingScenario;
% Add all road segments
roadCenters = [38.2 9.9 0;
37.3 -1.2 0;
30.5 -7.9 0;
27.6 -13.5 0;
29.6 0.1 0];
road(scenario, roadCenters, 'Name', 'Road1'); % Chnaged the Road name to Road1
save("data.mat")
Hope it helps!

Produkte


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by