Main Content

Vehicle Terrain Sensor

Vehicle and tire distances to objects

Vehicle Terrian Sensor will be removed in a future release. Use Simulation 3D Terrain Sensor instead. For more information, see Version History.

  • Vehicle Terrain Sensor block

Libraries:
Vehicle Dynamics Blockset / Vehicle Scenarios / Sim3D / Sim3D Vehicle / Components

Description

Note

Simulating models with the Vehicle Terrain Sensor block requires Simulink® 3D Animation™.

The Vehicle Terrain Sensor block implements ray tracing to detect the terrain below the tires and objects in front of the vehicle. Specifically, for these actor components, the block returns the hit location (in the world coordinate system) and the distance to an object.

  • Vehicle body

  • Left front wheel

  • Right front wheel

  • Left rear wheel

  • Right rear wheel

Tip

Verify that the Vehicle Terrain Sensor block executes before the Simulation 3D Fisheye Camera block. That way, the Unreal Engine® 3D visualization environment prepares the data before the Vehicle Terrain Sensor block receives it. To check the block execution order, right-click the blocks and select Properties. On the General tab, confirm these Priority settings:

  • Simulation 3D Scene Configuration0

  • Vehicle Terrain Sensor1

For more information about execution order, see Control and Display Execution Order.

Actors are scene objects that support 3D translation, rotation, and scale. Parts are actor components. Components do not exist by themselves; they are associated with an actor.

Hit Distance

To calculate the hit distances shown in the illustration, the block implements these equations.

Front of vehicle to object, DistToHitVhAdjust
DistToHitVh = GetLength(CntrLocVh,HitLocVh)
DistToHitVhAdjust = DistToHitVh - VehCntrLngthVal

EndLocVh = CntrLocVh + VehRayLngth - VehRayOffset
VehRayOffset = CntrLocVh - StartLocVh
VehRayLngth = StartLocVh - EndLocVh

Tires to terrain, DistToHitTrAdjust

DistToHitTr = GetLength(CntrLocTr, HitLocTr)
DistToHitTrAdjust = DistToHitTr - TireRadiiVal

EndLocTr = CntrLocTr + LengthTr - OffsetTr
OffsetTr = CntrLocTr - StartLocTr
LengthTr = StartLocTr - EndLocTr

Image of vehicle showing object and terrain

This illustration and equations use these variables.

CntrLocVh

Vehicle center location

DistToHitVh

Distance from vehicle center location to object

DistToHitVhAdjust

Distance from the front of the vehicle to object

EndLocVh

Vehicle ray trace end

HitLocVh

Vehicle hit location

OffsetVh

Vehicle trace offset

StartLocVh

Vehicle ray trace start

VehRayLngth

Vehicle trace length

VehCntrLngthVal

Distance from vehicle center to front

CntrLocTr

Tire center location

DistToHitTr

Distance from tire center location to terrain

DistToHitTrAdjust

Distance from tire to terrain

HitLocTr

Tire hit location

EndLocTr

Tire ray trace end

OffsetTr

Tire trace offset

StartLocTr

Tire ray trace start

LengthTr

Tire trace length

TireRadiiVal

Tire radius

Hit Event

To determine a hit event, the block uses the ray trace. The block provides the hit location in the world coordinate system.

Illustration of start location, hit location, and object

Miss Event

To determine a miss event, the block uses the ray trace.

Illustration of start location and object

Examples

Ports

Input

expand all

Distance from the vehicle center to front, VehCntrLngthVal, in m.

Dependencies

Distance to vehicle centerCreates PortCreates Parameter
Constant

None

Distance from vehicle center to front, VehCntrLngthVal
External inputVehCntrNone

Tire radii, TireRadiiVal, in m.

Dependencies

Distance to tire center SettingCreates PortCreates Parameter
Constant

None

Distance from tire center to ground, TireRadiiVal
External inputTireRadii

None

Output

expand all

Bus signal containing block values. The signals are arrays that depend on the wheel location.

SignalDescriptionVariableUnits
HitFlg

Vehicle and wheel hit flag:

  • Hit an object – 1

  • Miss an object – 0

[VehicleFrontLeftFrontRightRearLeftRearRight]

NA

HitLoc

Vehicle, HitLocVh, and tire, HitLocTr, hit locations, in world coordinate system X-, Y, and Z- axes, respectively

[VehicleXVehicleYVehicleZFrontLeftXFrontLeftYFrontLeftZFrontRightXFrontRightYFrontRightZRearLeftXRearLeftYRearLeftZRearRearXRearRearYRearRearZ]

m

StartLoc

Vehicle, StartLocVh, and tire, StartLocTr, ray trace start locations, in world coordinate system X-, Y, and Z- axes, respectively

m

Distance from the front of the vehicle to object, DistToHitVhAdjust, in m.

Distance from tire to terrain, DistToHitTrAdjust, in m.

DistToHitTrAdjust = [FrontLeftFrontRightRearLefRearRight]

Parameters

expand all

Actor Setup

Actor name.

Actors are scene objects that support 3D translation, rotation, and scale. Parts are actor components. Components do not exist by themselves; they are associated with an actor.

The block does not support multiple instances of the same actor tag. To refer to the same scene actor when you use the 3D block pairs (e.g. Simulation 3D Actor Transform Get and Simulation 3D Actor Transform Set), specify the same Tag for actor in 3D scene, ActorTag parameter.

Configure how to provide the distance to the vehicle center.

Dependencies

Distance to vehicle centerCreates PortCreates Parameter
Constant

None

Distance from vehicle center to front, VehCntrLngthVal
External inputVehCntrNone

Configure how to provide the distance to the tire center.

Dependencies

Distance to tire center SettingCreates PortCreates Parameter
Constant

None

Distance from tire center to ground, TireRadiiVal
External inputTireRadii

None

Distance from the vehicle center to front, VehCntrLngthVal, in m.

Dependencies

Distance to vehicle centerCreates PortCreates Parameter
Constant

None

Distance from vehicle center to front, VehCntrLngthVal
External inputVehCntrNone

Tire radius, TireRadiiVal, in m.

Dependencies

Distance to tire center SettingCreates PortCreates Parameter
Constant

None

Distance from tire center to ground, TireRadiiVal
External inputTireRadii

None

Trace Lengths

Vehicle body trace length, VehRayLngth, in m.

Left front wheel trace length, LfRayLngth and LengthTr, in m.

Right front wheel trace length, RfRayLngth and LengthTr, in m.

Left rear wheel trace length, LrRayLngth and LengthTr, in m.

Right rear wheel trace length, RrRayLngth and LengthTr, in m.

Starting Point Offsets

Vehicle body trace offset, OffsetVh, in m.

Left front wheel trace offset, LfRayOffset and OffsetTr, in m.

Right front wheel trace offset, RfRayOffset and OffsetTr, in m.

Left rear wheel trace offset, LrRayOffset and OffsetTr, in m.

Right rear wheel trace offset, RrRayOffset and OffsetTr, in m.

Enable Traces

Enable vehicle body ray tracing.

Enable left front tire ray tracing.

Enable right front tire ray tracing.

Enable left rear tire ray tracing.

Enable right rear tire ray tracing.

Enable trace line visualization.

Sample time, Ts. The graphics frame rate is the inverse of the sample time.

Version History

Introduced in R2018a

expand all