Main Content

driving.scenario.jerseyBarrierMesh

Mesh representation of Jersey barrier in driving scenario

Since R2021a

Description

barrierMesh = driving.scenario.jerseyBarrierMesh creates a mesh representation of a Jersey barrier as an extendedObjectMesh object, mesh.

example

Examples

collapse all

Add the prebuilt Jersey barrier mesh to a driving scenario. Then, use lidarPointCloudGenerator System object™ to generate a point cloud of the Jersey barrier mesh.

Create and show the prebuilt Jersey barrier mesh.

mesh = driving.scenario.jerseyBarrierMesh;
show(mesh);

Figure contains an axes object. The axes object contains an object of type patch.

Create a driving scenario.

s = drivingScenario;

Add a straight road to the driving scenario. The road has one lane in each direction.

road1 = road(s, [0 0 0; 25 0 0], 'Lanes', lanespec([1 1]));

Add a Jersey barrier to the road along the right edge.

barrier(s, road1, 'Mesh', mesh); 

Add a car as an ego vehicle and as a non-ego actor and apply the car mesh to both using driving.scenario.carMesh.

carMesh = driving.scenario.carMesh;
egoVehicle = vehicle(s,'ClassID',1,'Mesh',carMesh);
smoothTrajectory(egoVehicle,[1 -2 0; 21.3 -2 0], 20);
car = vehicle(s,'Position',[15 2 0],'Yaw',180,'ClassID',1,'Mesh',carMesh);

Plot the driving scenario. Set name-value pair 'Meshes','on' to show the meshes of the actors in the plot.

plot(s,'Meshes','on');

Create a lidarPointCloudGenerator System object. Set the actor profiles of the System object to those in the driving scenario.

lidar = lidarPointCloudGenerator;
lidar.ActorProfiles = actorProfiles(s);

Generate a lidar point cloud of the driving scenario.

player = pcplayer([-20 20],[-10 10],[0 4]);
while advance(s)
  tgts = targetPoses(egoVehicle);
  rdmesh = roadMesh(egoVehicle);
  [ptCloud, isValidTime] = lidar(tgts,rdmesh,s.SimulationTime);
  if isValidTime
      view(player,ptCloud);
  end
end

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains 6 objects of type patch, line.

Figure Point Cloud Player contains an axes object. The axes object with xlabel X, ylabel Y contains an object of type scatter.

Output Arguments

collapse all

Mesh representation of Jersey barrier, returned as an extendedObjectMesh object. The origin of the mesh is located at its geometric center.

You can develop your own meshes by using this prebuilt Jersey barrier mesh as a starting point. At the MATLAB® command line, enter:

edit driving.scenario.jerseybarrierMesh

Version History

Introduced in R2021a