Main Content

Place Cones on Formula Student Skidpad Track Using Simulation 3D Animation Functions

This example shows how to use a Simulink® model and Simulink® 3D Animation™ functions to place cones on the outline of a Formula Student skidpad track from sets of x- and y-coordinates. The Simulink model skidpadcourse.slx contains a Simulation 3D Scene Configuration block that creates a 3D environment and a Simulation 3D Actor (Simulink 3D Animation) block that executes the custom skidpad_cone_placement.m script. The script creates the track actor and the cone actors.

For an example that simulates a Formula Student Vehicle on a Formula Student skidpad track, see Generate Skidpad Test.

Open Model

Open the Simulink model.

  open_system("skidpadcourse.slx");

Simulink model containing a scene configuration block and an actor block.

Simulink 3D Scene Configuration Block Configuration

The Simulation 3D Scene Configuration block parameters for this example are preset to these values.

Parameter

Value

Scene source

Default Scenes

Scene name

Open Surface

Scene view

Scene Origin

Simulink 3D Actor Block Configuration

The Simulation 3D Actor block Initialization script is preset to the skidpadConePlacement.m script. The sections in this example detail the procedure defined in the script for creating the track, assigning cone coordinates for specific cone types, and creating the cones.

Assign Cone Locations

The track in this example is formed using two concentric circles. You need cone locations for these track paths:

  • Entry path

  • Right inner and outer ring paths

  • Left inner and outer ring paths

  • Exit path

  • Timekeeping line

Formula Student skidpad track with cone locations marked.

The cone x- and y-coordinates used in this example are determined by Formula Student scenario specifications. You can specify your own sets of x- and y-coordinates for your specific track.

Entry Path Cone Locations

Define the array entryConesLoc with the cone x- and y-coordinates for the entry path. Use the fliplr function to account for the Unreal Game® engine coordinates.

  dbtype skidpadConePlacement.m 1:9;
1     entryWidth =3.453;
2     conesZ0 = 0;
3     
4     entryConesLoc = [entryWidth/2 -12;...
5                      -entryWidth/2 -12;...
6                      -entryWidth/2 -10;...
7                      entryWidth/2 -10];
8     
9     entryConesLoc= fliplr(entryConesLoc); % account for game engine coords

Right Inner and Outer Ring Locations

Define the arrays rightInnerRingLoc and rightOuterRingLoc with the cone x- and y-coordinates for the right inner and outer ring paths, respectively. Use the fliplr function to account for the Unreal Game engine coordinates.

  dbtype skidpadConePlacement.m 11:45;
11    rightInnerRingLoc = [entryWidth/2 0;...%1
12                      4.58/2 -2.834;...%2
13                      7.787/2 -5.231;...%3
14                      12.588/2 -6.835;...%4
15                      18.25/2 -7.398;...%5
16                      23.912/2 -6.835;...%6
17                      28.713/2 -5.231;...%7
18                      31.92/2 -2.834;...%8
19                      33.047/2 0;...%9
20                      31.92/2 2.834;...%10
21                      28.713/2 5.231;...%11
22                      23.912/2 6.835;...%12
23                      18.25/2 7.398;...%13
24                      12.588/2 6.835;...%14
25                      7.787/2 5.231;...%15
26                      4.58/2 2.834;...%16    
27                      ];
28    
29    rightOuterRingLoc = [entryWidth/2 7.939;...% right side entry to exit zone
30                          9.945/2 10.026;...
31                          18.25/2 10.852;...
32                          26.555/2 10.026;...
33                          33.596/2 7.673;...
34                          38.301/2 4.153;...
35                          39.953/2 0;...
36                          38.301/2 -4.153;...
37                          33.596/2 -7.673;...
38                          26.555/2 -10.026;...
39                          18.25/2 -10.852;...
40                          9.945/2 -10.026;...                      
41                          entryWidth/2 -7.939;...% right side after entry zone                      
42                          ];
43    
44    rightInnerRingLoc = fliplr(rightInnerRingLoc);
45    rightOuterRingLoc = fliplr(rightOuterRingLoc);

Left Inner and Outer Ring Locations

Define the arrays leftInnerRingLoc and leftOuterRingLoc with the cone x- and y-coordinates for the left inner and outer ring paths, respectively. Note that the left ring cone locations are symmetrical to the right ring cone locations.

  dbtype skidpadConePlacement.m 47:48;
47    leftInnerRingLoc = rightInnerRingLoc.*[1 -1];
48    leftOuterRingLoc = rightOuterRingLoc.*[1 -1];

Exit Cone Locations

Define the array exitConesLoc with the cone x- and y-coordinates for the exit path. Use the fliplr function to account for the Unreal Game engine coordinates.

  dbtype skidpadConePlacement.m 50:60;
50    exitConesLoc = [entryWidth/2 16;...
51                     -entryWidth/2 16;...
52                     entryWidth/2-1 16;...
53                     -entryWidth/2+1 16;...
54                     -entryWidth/2 14;...
55                     entryWidth/2 14;...
56                     -entryWidth/2 12;...
57                     entryWidth/2 12;...
58                     -entryWidth/2 10;...
59                     entryWidth/2 10];
60    exitConesLoc= fliplr(exitConesLoc); % account for game engine coords

Timekeeping Line Cone Locations

Define the array timeConesLoc with the cone x- and y-coordinates for the timekeeping line. Use the fliplr function to account for the Unreal Game engine coordinates.

  dbtype skidpadConePlacement.m 62:66;
62    timeConesLoc = [entryWidth/2 .5;...
63                     -entryWidth/2 .5;...
64                     entryWidth/2 -.5;...
65                     -entryWidth/2 -.5];
66    timeConesLoc = fliplr(timeConesLoc);

Assign Cone Types

Determine the type of cones to place on the track. This example uses these cones.

Cone Type

Track Path

Blue cones

Right outer ring

Left inner ring

Yellow cones

Right inner ring

Left outer ring

Small orange cones

Entry

Exit

Large orange cones

Timekeeping line

Assign the arrays defined with the cone locations to variables that describe the cone types.

  dbtype skidpadConePlacement.m 68:71;
68    blueCones = [rightOuterRingLoc; leftInnerRingLoc];
69    yellowCones = [rightInnerRingLoc; leftOuterRingLoc];
70    smallOrangeCones = [entryConesLoc; exitConesLoc];
71    largeOrangeCones = timeConesLoc;

Create Formula Student Skidpad Track Using sim3d.Actor and createShape Functions

To create the Formula Student skidpad track, use the sim3d.Actor (Simulink 3D Animation) function to instantiate an actor object. Using the createShape (Simulink 3D Animation) function, build a 45 meter by 45 meter box shape for the actor object to represent the driving surface. Specify the vdynskidpad.png image as the texture for the actor object to overlay on top of the box. The image was scaled to represent the typical lane markings of a Formula Student skidpad track. Finally, specify additional actor properties to define the track appearance.

  dbtype skidpadConePlacement.m 73:83;
73    skidSurface = sim3d.Actor('ActorName','BaseSurface');
74    createShape(skidSurface, 'box', [45,45,+0.03]);
75    skidSurface.Color = [68 68 71]./100;
76    skidSurface.Translation = [0 0 0]; 
77    skidSurface.Texture = fullfile(pwd,"vdynskidpad.png"); 
78    skidSurface.TextureTransform.Scale = [1 1];
79    skidSurface.TextureTransform.Angle = 0;
80    skidSurface.Shininess = 0;
81    skidSurface.Transparency = 0;
82    skidSurface.TextureMapping.Blend = 1;
83    skidSurface.TextureMapping.Roughness = .8;

Add the actor object to the world.

  dbtype skidpadConePlacement.m 85;
85    World.add(skidSurface,Actor);

Create and Place Cones on Track

Create cones to place on the track. This example uses assets from the Vehicle Dynamics Blockset Interface for Unreal Engine® Projects support package to set the appearance of the cone actors. The color of the cone is indicted by the name of the cone asset. For example, the SM_Cone.SM_Cone asset is the default orange cone, and the SM_Cone_Blue.SM_Cone_Blue asset is a blue cone.

To create the cones, use the sim3d.Actor function to instantiate cone actors. Specify the 'Mesh' name-value argument to define the path to the cone asset and the 'Scale' name-value argument to define the cone size. Specify the 'Translation' name-value argument to define the cone locations. Finally, specify additional actor properties to define the cone behavior.

The Vehicle Dynamics Blockset™ Interface for Unreal Engine Projects support package must be installed to access the cone assests. For more information, see Install Support Package and Configure Environment.

  dbtype skidpadConePlacement.m 87:96;
87    nCones = length(largeOrangeCones);
88    for coneNum = 1:nCones
89        coneName = "LCone_" + num2str(coneNum);
90        conLoc = [largeOrangeCones(coneNum,:) conesZ0];
91        cone = sim3d.Actor('ActorName',coneName,...
92            'Mesh','/Game/Environment/Industrial/Props/Cone/Mesh/SM_Cone.SM_Cone',...
93            'Mobility', sim3d.utils.MobilityTypes.Movable,...
94            'SimulatePhysics', true,...
95            'Translation',conLoc,...
96            'EnableGravity', true);

Add the actor object to the world.

  dbtype skidpadConePlacement.m 97;
97        World.add(cone,Actor);

Repeat these steps for each cone type.

Run Animation

Run the animation. The model is configured to run for 30 seconds. If you want to adjust the animation length, change the Stop Time parameter value from the Simulation tab in the model.

sim("skidpadcourse.slx");

When you run the animation, view the track in the Simulation 3D Viewer. To navigate in the 3D environment, use keyboard shortcuts. For more information, see Navigate in 3D environment (Simulink 3D Animation).

Visualization of a Skidpad track with cones place long the right inner and outer edges, left inner and outer edges, entry path, exit path, and timekeeping line.

References

[1] FSG Competition Handbook 2024. 11 Dec. 2023, https://www.formulastudent.de/fileadmin/user_upload/all/2024/important_docs/FSG24_Competition_Handbook_v1.0.pdf.