Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BACKEND: Improve planning code #59

Open
2 of 6 tasks
Tracked by #36
TomCC7 opened this issue Nov 22, 2022 · 3 comments
Open
2 of 6 tasks
Tracked by #36

BACKEND: Improve planning code #59

TomCC7 opened this issue Nov 22, 2022 · 3 comments

Comments

@TomCC7
Copy link
Member

TomCC7 commented Nov 22, 2022

Task Description

The current vehicle planning & control code is a bit messy and hard to extend. As we are going to add new features and more vehicle behaviors, it's time to refactor and improve the planning code.

Subtasks:

@TomCC7
Copy link
Member Author

TomCC7 commented Nov 22, 2022

Current control process

  1. vehicle is following trajectory generated from waypoints
  2. get steer angle from steering_control
  3. determine if is turning, which will set different speed for the vehicle
  4. get throttle based on
    • the target speed
    • vehicle in front of the following vehicle
    • the distance to a intersection

@TomCC7
Copy link
Member Author

TomCC7 commented Nov 22, 2022

Possible refactor plan: decision tree for each vehicle

  • following waypoint (vehicle in front too close?)
    • YES: want to change line(?)
      • YES: change line
      • NO: decrease speed
    • NO: approaching intersection?
      • YES: ignore light?
        • YES: keep move on
        • NO: slow down and stop at sign
      • NO: keep move on

@TomCC7 TomCC7 changed the title refactor planning code BACKEND: refactor planning code Feb 2, 2023
@TomCC7 TomCC7 changed the title BACKEND: refactor planning code BACKEND: Improve planning code Feb 2, 2023
@TomCC7 TomCC7 added this to the Improve planning code milestone Feb 2, 2023
@TomCC7
Copy link
Member Author

TomCC7 commented Feb 7, 2023

Scenario runner's Control Procss

  1. Parser load everything from file into a config object
  2. config passed to Scenario object and loaded into behavior tree
  3. each behavior is linked to some Atomic Behavior which executes corresponding command
  4. tick everything (most importantly the behavior tree)

Parser

The parser is separated into several stages:

  1. check version - check if the version is 1.0.0
  2. load catalog - don't understand
  3. set scenario name
  4. set carla town
  5. set actor information
  6. validate everything necessary

Behaviors

It uses Behavior Tree and a corresponding lib called py-trees to compose scenarios. An example from scenario runner is displayed below:

[-] behavior
    (o) behavior
        (-) ParametersInit
            --> InitialParameterSettings Done?
            [-] OneShot
                (o) ParametersInit
                --> Mark Done
        (-) EnvironmentBehavior
            --> InitialEnvironmentSettings Done?
            [-] OneShot
                (o) EnvironmentBehavior
                    (-) ChangeWeather
                        --> InitialWeather Done?
                        [-] OneShot
                            --> ChangeWeather
                            --> Mark Done
                    (-) ChangeRoadFriction
                        --> InitRoadFriction Done?
                        [-] OneShot
                            --> ChangeRoadFriction
                            --> Mark Done
                --> Mark Done
        (-) InitBehaviour
            --> InitialActorSettings Done?
            [-] OneShot
                (o) InitBehaviour
                    [-] InitActoradversary
                        --> ChangeActorControl
                    [-] InitActorstanding
                        --> ChangeActorControl
                    [-] InitActorhero
                        --> ChangeActorControl
                --> Mark Done
        (o) OSCStories
            (-) MyStory
                --> >MyStory Done?
                [-] OneShot
                    (o) MyStory
                        [-] Act StartConditions and behaviours
                            (o) StartConditions Group
                                (o) StartConditions
                                    (o) Condition Group
                                        (-) OverallStartCondition
                                            --> Behavior>None>None>OverallStartCondition Done?
                                            [-] OneShot
                                                --> OverallStartCondition
                                                --> Mark Done
                                        (-) SimulationTimeCondition
                                            --> Behavior>None>None>StartTime Done?
                                            [-] OneShot
                                                --> SimulationTimeCondition
                                                --> Mark Done
                            (o) Maneuver + EndConditions Group
                                --> Maneuvers
                                    (o) Maneuvers
                                        (-) ManeuverSequence
                                            --> Behavior>ManeuverSequence Done?
                                            [-] ManeuverSequence
                                                [-] RepeatableBehaviour of Behavior>ManeuverSequence
                                                    --> ManeuverSequence
                                                        (o) ManeuverSequence
                                                            (-) Maneuver LaneChangeSimpleManeuver
                                                                --> Behavior>ManeuverSequence>LaneChangeSimpleManeuver Done?
                                                                [-] OneShot
                                                                    --> Maneuver LaneChangeSimpleManeuver
                                                                        (o) Maneuver LaneChangeSimpleManeuver
                                                                            (-) Event AdversaryAccelerates
                                                                                --> Behavior>ManeuverSequence>AdversaryAccelerates Done?
                                                                                [-] Event AdversaryAccelerates
                                                                                    (o) Parallel Condition Groups
                                                                                        (o) Condition Group
                                                                                            (-) StartCondition
                                                                                                --> Behavior>ManeuverSequence>AdversaryAccelerates>None>None>StartCondition Done?
                                                                                                [-] OneShot
                                                                                                    --> StartCondition
                                                                                                    --> Mark Done
                                                                                    --> Actions
                                                                                        (o) Actions
                                                                                            (-) AdversaryAccelerates
                                                                                                --> Behavior>ManeuverSequence>AdversaryAccelerates>AdversaryAccelerates>0 Done?
                                                                                                [-] OneShot
                                                                                                    --> AdversaryAccelerates
                                                                                                        --> AdversaryAccelerates
                                                                                                    --> Mark Done
                                                                                    --> Mark Done
                                                                            (-) Event AdversaryChangesLane
                                                                                --> Behavior>ManeuverSequence>AdversaryChangesLane Done?
                                                                                [-] Event AdversaryChangesLane
                                                                                    (o) Parallel Condition Groups
                                                                                        (o) Condition Group
                                                                                            (-) completeStateCondition
                                                                                                --> Behavior>ManeuverSequence>AdversaryChangesLane>None>None>AfterAdversaryAccelerates Done?
                                                                                                [-] OneShot
                                                                                                    --> completeStateCondition
                                                                                                    --> Mark Done
                                                                                    --> Actions
                                                                                        (o) Actions
                                                                                            (-) AdversaryChangesLane
                                                                                                --> Behavior>ManeuverSequence>AdversaryChangesLane>AdversaryChangesLane>0 Done?
                                                                                                [-] OneShot
                                                                                                    --> AdversaryChangesLane
                                                                                                        --> AdversaryChangesLane
                                                                                                    --> Mark Done
                                                                                    --> Mark Done
                                                                    --> Mark Done
                                                    --> Clear Descendant Variables of Behavior>ManeuverSequence
                                                --> Mark Done
                                (o) EndConditions
                                    (o) Condition Group
                                        (-) EndCondition
                                            --> Behavior>None>None>EndCondition Done?
                                            [-] OneShot
                                                --> EndCondition
                                                --> Mark Done
                    --> Mark Done
--> TimeOut
--> WeatherBehavior
--> UpdateAllActorControls
(o) EndConditions (Criteria Group)
    (o) Evaluation Criteria for multiple ego vehicles
        --> RunningStopTest
    (o) Evaluation Criteria for multiple ego vehicles
        --> RunningRedLightTest
    (o) Evaluation Criteria for multiple ego vehicles
        --> WrongLaneTest
    (o) Evaluation Criteria for multiple ego vehicles
        --> OnSidewalkTest
    (o) Evaluation Criteria for multiple ego vehicles
        --> CheckKeepLane
    (o) Evaluation Criteria for multiple ego vehicles
        --> CollisionTest
    (o) Evaluation Criteria for multiple ego vehicles
        --> CheckDrivenDistance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant