Main Content

Virtual Mcity

Virtual Mcity 3D environment

Description

The Virtual Mcity scene is a 3D environment containing a virtual representation of Mcity®, which is a testing ground belonging to the University of Michigan. For more details, see Mcity Test Facility.

The scene is rendered using the Unreal Engine® from Epic Games®.

Virtual MCity scene

Setup

To simulate a driving algorithm in this scene:

  1. Add a Simulation 3D Scene Configuration block to your Simulink® model.

  2. In this block, set the Scene source parameter to Default Scenes.

  3. Set the enabled Scene name parameter to Virtual Mcity.

Examples

expand all

Explore the 3D Virtual Mcity scene and inspect its dimensions by using a corresponding 2D top-view image of the scene.

You can use this image to inspect the scene before simulation and choose starting coordinates for vehicles. For details on using these images to select waypoints for path-following applications, see the Select Waypoints for Unreal Engine Simulation example.

Load the 2D spatial referencing object that corresponds to the scene. This imref2d object describes the relationship between the pixels in the image and the world coordinates of the scene.

data = load('sim3d_SpatialReferences.mat');
spatialRef = data.spatialReference.VirtualMCity
spatialRef = 
  imref2d with properties:

           XWorldLimits: [-159.3500 253.3500]
           YWorldLimits: [-94.4500 318.2500]
              ImageSize: [4645 4645]
    PixelExtentInWorldX: 0.0888
    PixelExtentInWorldY: 0.0888
    ImageExtentInWorldX: 412.7000
    ImageExtentInWorldY: 412.7000
       XIntrinsicLimits: [0.5000 4.6455e+03]
       YIntrinsicLimits: [0.5000 4.6455e+03]

Display the image corresponding to the scene. Use the spatial referencing object to display the axes in the world coordinates of the scene. Units are in meters.

By default, the imshow function displays Y-axis values that increase from top to bottom. To align with the Automated Driving Toolbox™ world coordinate system, set the Y-direction to 'normal' so that Y-axis values increase from bottom to top.

The image displays only the area of the scene containing the city. The full scene has a length of 541.44 meters and a width of 342.98 meters.

figure
fileName = 'sim3d_VirtualMCity.jpg';
I = imshow(fileName,spatialRef);
set(gca,'YDir','normal')
xlabel('X (m)')
ylabel('Y (m)')

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains an object of type image.

Zoom in on the origin of the scene. Place a marker at the origin.

xlim([-20 50])
ylim([-40 30])

hold on
plot(0,0,'o','MarkerFaceColor','r','MarkerEdgeColor','k','MarkerSize',8)
offset = 1; % px
text(offset,offset,'(0,0)','Color','k','FontWeight','bold','FontSize',12)
hold off

Figure contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains 3 objects of type image, line, text. One or more of the lines displays its values using only markers

Limitations

Version History

Introduced in R2019b