How to create a drivingScenario based on openstreetmap with building information?

10 views (last 30 days)
In matlab example “
Simulate GNSS Multipath Effects in Urban Canyon Environment
”, a drivingScenario containing 3D buildings is imported (according to the description, this drivingScenario is generated based on openstreetmap), which is used for subsequent GNSS NLOS detection. I want to know how I can generate my own drivingScenario with 3D building and road information based on openstreetmap?

Answers (1)

Altaïr
Altaïr on 20 Mar 2025
Edited: Altaïr on 20 Mar 2025
For creating roads using OpenStreetMap data, please refer to this example: https://www.mathworks.com/help/releases/R2023b/driving/ug/import-openstreetmap-data-into-driving-scenario.html
The remainder of the explanation focuses on adding building meshes to the scenario. The downtownBostonDrivingScenario.mat file includes a drivingScenario object named scenario. Within this file, the last actor represents the buildings, with its velocity set to [0,0,0].
To add buildings programmatically once the mesh is available, consider the following approach:
% Create a driving scenario
scenario = drivingScenario;
% Define a straight road with two lanes
roadCenters = [-100 400; 100 400]; % 200 meters long road
laneSpecification = lanespec(2); % Two lanes
road(scenario, roadCenters, 'Lanes', laneSpecification);
% Add a moving vehicle actor
movingVehicle = vehicle(scenario, 'ClassID', 1); % ClassID 1 for cars
movingVehicle.Position = [-95 400 0]; % Start position on the road
movingVehicle.Yaw = -45; %Set a yaw angle of -45 degrees
% Create a building actor with a custom mesh
building = actor(scenario, 'ClassID', 10,'Mesh',buildingActor.Mesh,...
'Position',buildingActor.Position,'PlotColor',buildingActor.PlotColor,...
'Length',buildingActor.Length, 'Width',buildingActor.Width,'Height',buildingActor.Height);
% Visualize the scenario
plot(scenario, 'RoadCenters', 'on','Meshes','on');
In the above snippet, the 17th actor from the original example, corresponding to the buildings, is stored in a variable named buildingActor. The ClassID for the building object is set to a unique value outside the default range. More details can be found here:
Open Driving Scenario Designer using the drivingScenarioDesigner command. To view the scenario in Driving Scenario Designer, create an additional class with the same ClassID (10) using the "Add Actor > New Actor Class" option.
The following command opens the drivingScenario object:
drivingScenarioDesigner(scenario)
Select "Default Layout" from the DESIGNER tab and ensure "Show Actor Meshes" is enabled by right clicking in the Ego-Centric View pane to view the building meshes.
For further information, the following documentation pages may be useful:

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!