main content

automate control of intelligent vehicles by using stateflow charts -凯发k8网页登录

this example shows how to model a highway scenario with intelligent vehicles that are controlled by the same decision logic. each vehicle determines when to speed up, slow down, or change lanes based on the logic defined by a standalone stateflow® chart. because the driving conditions (including the relative position and speed of nearby vehicles) differ from vehicle to vehicle, separate chart objects in matlab® control the individual vehicles on the highway.

open driving scenario

to start the example, run the script sf_driver_demo.m. the script displays a 3-d animation of a long highway and several vehicles. the view focuses on a single vehicle and its surroundings. as this vehicle moves along the highway, the standalone stateflow chart sf_driver shows the decision logic that determines its actions.

starting from a random position, each vehicle attempts to travel at a target speed. because the target speeds are chosen at random, the vehicles can obstruct one another. in this situation, a vehicle will try to change lanes and resume its target speed.

the class file highwayscenario defines a (automated driving toolbox) object that represents the 3-d environment that contains the highway and the vehicles on it. to control the motion of the vehicles, the drivingscenario object creates an array of stateflow chart objects. each chart object controls a different vehicle in the simulation.

execute decision logic for vehicles

the stateflow chart sf_driver consists of two top-level states, lanekeep and lanechange.

when the lanekeep state is active, the corresponding vehicle stays in its lane of traffic. in this state, there are two possible substates:

  • cruise is active when the zone directly in front of the vehicle is empty and the vehicle can travel at its target speed.

  • follow becomes active when the zone directly in front of the vehicle is occupied and its target speed is faster than the speed of the vehicle in front. in this case, the vehicle is forced to slow down and attempt to change lanes.

when the lanechange state is active, the corresponding vehicle attempts to change lanes. in this state, there are two possible substates:

  • continue is active when the zone next to the vehicle is empty and the vehicle can change lanes safely.

  • abort becomes active when the zone next to the vehicle is occupied. in this case, the vehicle is forced to remain in its lane.

the transitions between the states lanekeep and lanechange are guarded by the value of islanechanging. in the lanekeep state, the chart sets this local data to true when the substate follow is active and there is enough room beside the vehicle to change lanes. in the lanechange state, the chart sets this local data to false when the vehicle finishes changing lanes.

see also

(automated driving toolbox)

related topics

网站地图