This tutorial will guide you through the steps required to build the FlatRoad model.
The input arguments s and w are common to all the road functions that we need to define and are included in the base function definitions. These definitions can then be used to define our position function as follows:s: x-coordinate in world frame (x-axis is road heading direction) w: y-coordinate in world frame (y-axis is lateral displacement)
function linePosition "Determine point on road" extends VehicleInterfaces.Roads.Interfaces.Base.position; algorithm r_0 := {s,w,0}; end linePosition;
function constantOffset "Determine offset from road centre line" extends VehicleInterfaces.Roads.Interfaces.Base.trackOffset; input Modelica.SIunits.Distance offset; algorithm trackOffset := {0,offset,0}; end constantOffset;
function lineNormal "Determine unit normal on road" extends VehicleInterfaces.Roads.Interfaces.Base.normal; algorithm e_n_0 := {0,0,1}; end lineNormal;
function lineHeadingDirection "Determine unit heading direction on road" extends VehicleInterfaces.Roads.Interfaces.Base.headingDirection; algorithm e_s_0 := {1,0,0}; end lineHeadingDirection;
function lineFrictionCoefficient "Determine friction coefficient at point on road" extends VehicleInterfaces.Roads.Interfaces.Base.frictionCoefficient; input Real mu_fixed "Friction coefficient"; algorithm mu := mu_fixed; end lineFrictionCoefficient;
model FlatRoad "Straight road along x-axis (perpendicular to world z-axis)" extends VehicleInterfaces.Roads.Interfaces.Base( redeclare final function position = linePosition, redeclare final function trackOffset = constantOffset(offset=offset) redeclare final function normal = lineNormal, redeclare final function headingDirection = lineHeadingDirection, redeclare final function frictionCoefficient = lineFrictionCoefficient(mu_fixed=mu)); //rest of definition ... end FlatRoad;