TrafficLight

Package: simu5g.mobility.trafficLightMobility

compound module TrafficLight

Simulates a traffic light in an urban environment. It incorporates a stationary mobility submodule to represent the fixed position of the traffic light, and a TrafficLightController submodule to model the traffic light’s states (green, yellow, red) and its interactions with vehicles.

Usage diagram

Used in

Name

Type

Description

UrbanNetwork

network

(no description)

Parameters

Name

Type

Default value

Description

bidirectional

bool

false

Properties

Name

Value

Description

display

i=misc/node2_s;bgb=200,100

Unassigned submodule parameters

Name

Type

Default value

Description

mobility ↗.displayStringTextFormat

string

“p: {position}\nv: {velocity}”

Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information

mobility ↗.subjectModule

string

“^”

The module path that determines the subject module, the motion of which this mobility model describes. The default value is the parent module

mobility ↗.coordinateSystemModule

string

“”

The module path of the geographic coordinate system module; optional, empty disables geographic conversion (and the {geo_position} directive)

mobility ↗.updateDisplayString

bool

true

Enables continuous update of the subject module’s position by modifying its display string

mobility ↗.constraintAreaMinX

double

-inf m

The minimum x position of the constraint area. It is unconstrained by default (negative infinity)

mobility ↗.constraintAreaMinY

double

-inf m

The minimum y position of the constraint area. It is unconstrained by default (negative infinity)

mobility ↗.constraintAreaMinZ

double

-inf m

The minimum z position of the constraint area. It is unconstrained by default (negative infinity)

mobility ↗.constraintAreaMaxX

double

inf m

The maximum x position of the constraint area. It is unconstrained by default (positive infinity)

mobility ↗.constraintAreaMaxY

double

inf m

The maximum y position of the constraint area. It is unconstrained by default (positive infinity)

mobility ↗.constraintAreaMaxZ

double

inf m

The maximum z position of the constraint area. It is unconstrained by default (positive infinity)

mobility ↗.initialX

double

uniform(this.constraintAreaMinX, this.constraintAreaMaxX)

mobility ↗.initialY

double

uniform(this.constraintAreaMinY, this.constraintAreaMaxY)

mobility ↗.initialZ

double

nanToZero(uniform(this.constraintAreaMinZ, this.constraintAreaMaxZ))

mobility ↗.initialLatitude

double

nan deg

mobility ↗.initialLongitude

double

nan deg

mobility ↗.initialAltitude

double

0m

mobility ↗.initialHeading

double

0deg

mobility ↗.initialElevation

double

0deg

mobility ↗.initialBank

double

0deg

mobility ↗.initFromDisplayString

bool

true

Enables one-time initialization from the subject module’s display string

mobility ↗.updateFromDisplayString

bool

true

Enables continuous update from the subject module’s display string for dragging and rotating it

trafficLightController.mobilityModule

string

“^.mobility”

trafficLightController.greenPeriod

double

1s

trafficLightController.yellowPeriod

double

1s

trafficLightController.redPeriod

double

1s

trafficLightController.startTime

double

1s

trafficLightController.startState

string

“RED”

Do not use OFF or YELLOW for now

trafficLightController.meanCarLength

double

4m

trafficLightController.areaWidth

double

1m

Source code

//
// Simulates a traffic light in an urban environment.
// It incorporates a stationary mobility submodule to represent the fixed position
// of the traffic light, and a ~TrafficLightController submodule to model
// the traffic light's states (green, yellow, red) and its interactions with vehicles.
//
module TrafficLight
{
    parameters:
        @display("i=misc/node2_s;bgb=200,100");
        bool bidirectional = default(false);

    submodules:
        mobility: StationaryMobility {
            parameters:
                @display("p=142,52;is=s");
        }
        trafficLightController: TrafficLightController {
            parameters:
                @display("p=48,52;is=s");
                mobilityModule = default("^.mobility");
                bidirectional = parent.bidirectional;
        }
}

File: src/simu5g/mobility/trafficLightMobility/TrafficLight.ned