Hi,
The `roadBoundaries` function does not take individual road objects as input. Instead, it extracts the boundaries from the entire scenario. To get the boundaries for individual road segments, you'll need to extract them from the scenario after all roads have been added.
Please refer the below sample code:
1. Create the driving scenario and add the road segments.
scenario = drivingScenario(); % Create a driving scenario
laneSpecification = lanespec(2); % Define the two lanes for the roads
% Define a straight road segment
straightRoadCenters = [0 0; 100 0];
straightRoad = road(scenario, straightRoadCenters, 'Lanes', laneSpecification);
% Define a curved road segment
theta = linspace(0, pi/2, 30);
radius = 50;
curvedRoadCenters = radius * [cos(theta)' sin(theta)'];
curvedRoad = road(scenario, curvedRoadCenters, 'Lanes', laneSpecification);
Please refer the below documentation for ‘drivingScenario’ and ‘road’ functions:
- https://in.mathworks.com/help/driving/ref/drivingscenario.html
- https://in.mathworks.com/help/driving/ref/drivingscenario.road.html
2. Use the `roadBoundaries` function to extract all road boundaries from the scenario and display them.
roadBoundariesInfo = roadBoundaries(scenario); % Extract the road boundaries for the entire scenario
% Display the road boundaries
figure;
for i = 1:length(roadBoundariesInfo)
boundary = roadBoundariesInfo{i};
plot(boundary(:,1), boundary(:,2));
end
The boundaries are stored in `roadBoundariesInfo' which is a cell array where each cell contains the boundary points for a particular road segment.
Note: If you need to distinguish between the boundaries of the straight and curved roads, you will need to implement additional logic based on the known geometry of the roads you've defined.
I hope this helps!