Main Content

Generate Skidpad Test

This example shows how to simulate a skidpad test similar to events held in student competitions by Formula Student, Formula SAE, and other organizations internationally. In these, student teams build, operate, and present vehicles of their own design.

In this example, the vehicle starts from rest, then:

  1. Accelerates to enter the course

  2. Completes two clockwise laps

  3. Reverses its steering direction

  4. Completes two counterclockwise laps

  5. Exits and brakes to a stop

Open Model

The skidpad model includes a reference path, driver, vehicle, and visualization aides. To open the model, use this command.

open_system('vdynblksskidpad');

The model workspace variable TrackPoints contains the reference waypoints used to define the reference pose. You can edit or replace them with waypoints of your own. To plot the waypoints, use this code.

mdlWks = get_param('vdynblksskidpad','ModelWorkspace');
TrackPoints = evalin(mdlWks,'TrackPoints');
figure;
plot(TrackPoints(:,2),TrackPoints(:,1),'ro-')
hold on
arrowLen = 1.5;
quiver(TrackPoints(:,2),TrackPoints(:,1),arrowLen*sin(TrackPoints(:,3)),arrowLen*cos(TrackPoints(:,3)),'b','LineWidth',1,'MaxHeadSize',arrowLen)
box on
grid on
xlabel('Y [m]')
ylabel('X [m]')
axis equal
legend('Waypoints','Path Direction')

Figure contains an axes object. The axes object with xlabel Y [m], ylabel X [m] contains 2 objects of type line, quiver. These objects represent Waypoints, Path Direction.

The default vehicle path follows the centerline of the course, with some X,Y points duplicated because the vehicle completes multiple laps. You can change factors such as the number of laps or scaling via the blocks found in the Skidpad Reference subsystem. You can also experiment with path points to improve lap times.

Simulate Model

To run the model and observe the vehicle completing the course, use this command.

sim('vdynblksskidpad');

Figure Vehicle Position contains an axes object. The axes object with xlabel Y Distance [m], ylabel X Distance [m] contains 7 objects of type line, patch. One or more of the lines displays its values using only markers

Figure G-diagram contains an axes object. The axes object with xlabel Lateral Acceleration [G], ylabel Longitudinal Acceleration [G] contains 24 objects of type patch.

By default, an overhead figure depicting the reference and simulated vehicle path, and acceleration diagram are opened and updated during simulation. Lap times are estimated and displayed in order at the top level of the model via a Display block.

You can model the vehicle as either of two variant subsystems, using blocks from the Vehicle Dynamics Blockset library: Simulink Physics or Game Engine Physics. To set the vehicle type, double-click the Formula Student Vehicle block and select from the Vehicle Type list. To set the vehicle type programmatically, use the set_param command.

By default, the Simulink Physics setting uses a 7DOF vehicle containing multiple subsystems and components, including an ideal powertrain, driveline, tires, and chassis. The Game Engine Physics setting has similar parameters but uses a simulation 3D interface to configure and solve for the dynamic response of the predefined vehicle template. Given the differences in tire models and solver engines between the two settings, differences in results are to be expected. Choose your setting based on your modeling and visualization preferences.

Use this command to set the model to use the game engine vehicle.

vehType = "Game Engine Physics"
vehType = 
"Game Engine Physics"
% set_param( 'vdynblksskidpad/Formula Student Vehicle','vehType',vehType);

Enable 3D Visualization

Before running the model in the 3D visualization environment, review the Unreal Engine Simulation Environment Requirements and Limitations. To enable the 3D visualization, use these commands.

 set_param('vdynblksskidpad/Visualization/3D Visualization','engine3D','Enabled - Simulink 3D Vehicle')
 

To add cones and a skidpad lane boundary texture use the following:

set_param('vdynblksskidpad/Visualization/3D Visualization','conesOn','on');

To include tire force, vehicle and driveline annotations use the following:

set_param('vdynblksskidpad/Visualization/3D Visualization','annotOn','on');

And now run the simulation:

sim('vdynblksskidpad');
Warning: The published message size 231 more than the declared size 222 of the topic publisher 'AnnotationActor3/AnnotationConfiguration_OUT'. Updating the publisher QOS.
Warning: The published message size 232 more than the declared size 231 of the topic publisher 'AnnotationActor3/AnnotationConfiguration_OUT'. Updating the publisher QOS.
Warning: The published message size 233 more than the declared size 232 of the topic publisher 'AnnotationActor3/AnnotationConfiguration_OUT'. Updating the publisher QOS.
Warning: The published message size 234 more than the declared size 233 of the topic publisher 'AnnotationActor3/AnnotationConfiguration_OUT'. Updating the publisher QOS.
Warning: The published message size 235 more than the declared size 234 of the topic publisher 'AnnotationActor3/AnnotationConfiguration_OUT'. Updating the publisher QOS.

Figure G-diagram contains an axes object. The axes object with xlabel Lateral Acceleration [G], ylabel Longitudinal Acceleration [G] contains 24 objects of type patch.

Figure Vehicle Position contains an axes object. The axes object with xlabel Y Distance [m], ylabel X Distance [m] contains 7 objects of type line, patch. One or more of the lines displays its values using only markers

You can also place cones with Simulink 3D Animation to better define the skid pad course when using the 3D visualization engine. You can adjust cone placement through the initialization script in the Simulation 3D Actor block.

See Also

| (Simulink 3D Animation)

Related Topics