carla-simulator / scenario_runner

Traffic scenario definition and execution engine
https://carla-scenariorunner.readthedocs.io/en/latest/
MIT License
536 stars 365 forks source link

ScenarioRunner crashes when trying to spawn a new car at runtime. #1123

Closed vollkornholztuer closed 3 weeks ago

vollkornholztuer commented 1 month ago

Describe our question or idea ScenarioRunner crashes when excecuting an OpenSCENARIO-1.0 file, which tries to spawn a new car while the simulation is already running. The Cars that spawn in the Init-section, and therefore are present from the beginning, work. It kind of works like this:

I run the .xosc with ScenarioRunner, the simulations starts with two cars (Ego and Target). The target car begins to drive as predefined, the Ego car is stationary. As soon as the new car is supposed to spawn, the new car is visible for a single frame but it crashes. The error message from the terminal sadly is not very descriptive (see screenshots).

Expected behavior The car should spawn and the simulation should keep running and finish at some point.

Screenshots and Screencasts The error message from the terminal, when the scenario is executed: Screenshot from 2024-10-18 12-15-02_edit

A video of the execution of the given OpenSCENARIO-File (see "Other resources"): Screencast from 10-18-2024 12:44:33 PM.webm

Desktop (please complete the following information):

Other resources My OpenSCENARIO 1.0-file: spawnDespawnTest0_copy.zip

vollkornholztuer commented 1 month ago

I've found the "--debug" command for the cli. This is the ouptut, when running the provided .xosc file: spawnDespawnText0_debug.txt

I'm trying to read it, but it's very cryptic. I probably won't understand it on my own.

starrye commented 3 weeks ago

I don't quite understand your approach. I think the new car was actually generated at the beginning, but the location is not <WorldPosition x="-8.0" y="0.0" z="0.0" h="0.0" p="0.0" r= "0.0" />. Maybe you can print all the actor information after generation, or adjust the coordinates of new_car?

vollkornholztuer commented 3 weeks ago

The blue car "Ego", which spawns at around 0:09 of the provided video, is at the x=0, y=0 coordinates (between turn-left-lane and go-straight-lane). After two further seconds, at around 0:11 of the video, i try to spawn "new_car" at x=-8, y=0, which equals to the position behind the car at coordinate origin. new_car is then visible for a single frame before the simulation crashes. The coordinates itself are not an issue, because CARLA doesn't allow a vehicle to spawn, if the position is blocked by another entity/vehicle.

The red bus ("Target") was already given to me and it's only purpose is to keep the simulation running for debugging purposes, in that case, to display the cars for longer.

Here's the exact frame for reference, before the simulation crashes: Screenshot from 2024-11-04 09-31-18_with_comments

About the actor information, it should be found inside the spawnDespawnTest0_debug.txt file, as in the previous comment. This is the content of the last two ticks, where the car spawns and then the simulation crashes:

(if the following isn't the actor information you're expecting, please instruct me on how to find/get the actor information you need)

--------- Tick ---------

SCENARIO [*]
--> WeatherBehavior [*]
[-] behavior [*]
    (o) behavior [*]
        (-) ParametersInit [✓]
            --> InitialParameterSettings Done? [✓] -- 'InitialParameterSettings' comparison succeeded
            [-] OneShot [-]
                (o) ParametersInit [-]
                --> Mark Done [-]
        (-) EnvironmentBehavior [✓]
            --> InitialEnvironmentSettings Done? [✓] -- 'InitialEnvironmentSettings' comparison succeeded
            [-] OneShot [-]
                (o) EnvironmentBehavior [-]
                    (-) ChangeWeather [-]
                        --> InitialWeather Done? [-] -- 'InitialWeather' comparison failed
                        [-] OneShot [-]
                            --> ChangeWeather [-]
                            --> Mark Done [-]
                    (-) ChangeRoadFriction [-]
                        --> InitRoadFriction Done? [-] -- 'InitRoadFriction' comparison failed
                        [-] OneShot [-]
                            --> ChangeRoadFriction [-]
                            --> Mark Done [-]
                --> Mark Done [-]
        (-) InitBehaviour [✓]
            --> InitialActorSettings Done? [✓] -- 'InitialActorSettings' comparison succeeded
            [-] OneShot [-]
                (o) InitBehaviour [-]
                    [-] InitActornew_car [-]
                        --> ChangeActorControl [-]
                    [-] InitActorTarget [-]
                        --> ChangeActorControl [-]
                --> Mark Done [-]
        (o) OSCStories [*]
            (-) MyStory [*]
                --> >MyStory Done? [✕] -- '>MyStory' comparison failed
                [-] OneShot [*]
                    (o) MyStory [*]
                        [-] Act StartConditions and behaviours [*]
                            (o) StartConditions Group [✓]
                                (o) StartConditions [✓]
                                    (o) Condition Group [✓]
                                        (-) SimulationTimeCondition [✓]
                                            --> Behavior>None>None>act_start Done? [✕] -- 'Behavior>None>None>act_start' comparison failed
                                            [-] OneShot [✓]
                                                --> SimulationTimeCondition [✓]
                                                --> Mark Done [✓] -- success
                            (o) Maneuver + EndConditions Group [*]
                                --> Maneuvers [*]
                                    (o) Maneuvers [*]
                                        (-) RoutingManeuver [*]
                                            --> Behavior>RoutingManeuver Done? [✕] -- 'Behavior>RoutingManeuver' comparison failed
                                            [-] RoutingManeuver [*]
                                                [-] RepeatableBehaviour of Behavior>RoutingManeuver [*]
                                                    --> RoutingManeuver [*]
                                                        (o) RoutingManeuver [*]
                                                            (-) Maneuver FollowingRouteManeuver [*]
                                                                --> Behavior>RoutingManeuver>FollowingRouteManeuver Done? [✕] -- 'Behavior>RoutingManeuver>FollowingRouteManeuver' comparison failed
                                                                [-] OneShot [*]
                                                                    --> Maneuver FollowingRouteManeuver [*]
                                                                        (o) Maneuver FollowingRouteManeuver [*]
                                                                            (-) Event TrajectoryEvent [*]
                                                                                --> Behavior>RoutingManeuver>TrajectoryEvent Done? [✕] -- 'Behavior>RoutingManeuver>TrajectoryEvent' comparison failed
                                                                                [-] Event TrajectoryEvent [*]
                                                                                    (o) Parallel Condition Groups [✓]
                                                                                        (o) Condition Group [✓]
                                                                                            (-) SimulationTimeCondition [✓]
                                                                                                --> Behavior>RoutingManeuver>TrajectoryEvent>None>None>StartAction Done? [✕] -- 'Behavior>RoutingManeuver>TrajectoryEvent>None>None>StartAction' comparison failed
                                                                                                [-] OneShot [✓]
                                                                                                    --> SimulationTimeCondition [✓]
                                                                                                    --> Mark Done [✓] -- success
                                                                                    --> Actions [*]
                                                                                        (o) Actions [*]
                                                                                            (-) FollowRoute [*]
                                                                                                --> Behavior>RoutingManeuver>TrajectoryEvent>FollowRoute>1 Done? [✕] -- 'Behavior>RoutingManeuver>TrajectoryEvent>FollowRoute>1' comparison failed
                                                                                                [-] OneShot [*]
                                                                                                    --> FollowRoute [*]
                                                                                                        --> FollowRoute [*]
                                                                                                    --> Mark Done [-]
                                                                                    --> Mark Done [-]
                                                                    --> Mark Done [-]
                                                    --> Clear Descendant Variables of Behavior>RoutingManeuver [-]
                                                --> Mark Done [-]
                        [-] Act StartConditions and behaviours [*]
                            (o) StartConditions Group [✓]
                                (o) StartConditions [✓]
                                    (o) Condition Group [✓]
                                        (-) SimulationTimeCondition [✓]
                                            --> spawnCar>None>None>act_start Done? [✕] -- 'spawnCar>None>None>act_start' comparison failed
                                            [-] OneShot [✓]
                                                --> SimulationTimeCondition [✓]
                                                --> Mark Done [✓] -- success
                            (o) Maneuver + EndConditions Group [*]
                                --> Maneuvers [*]
                                    (o) Maneuvers [*]
                                        (-) new_car_car_manGroup [*]
                                            --> spawnCar>new_car_car_manGroup Done? [✕] -- 'spawnCar>new_car_car_manGroup' comparison failed
                                            [-] new_car_car_manGroup [*]
                                                [-] RepeatableBehaviour of spawnCar>new_car_car_manGroup [*]
                                                    --> new_car_car_manGroup [*]
                                                        (o) new_car_car_manGroup [*]
                                                            (-) Maneuver new_car_maneuver [*]
                                                                --> spawnCar>new_car_car_manGroup>new_car_maneuver Done? [✕] -- 'spawnCar>new_car_car_manGroup>new_car_maneuver' comparison failed
                                                                [-] OneShot [*]
                                                                    --> Maneuver new_car_maneuver [*]
                                                                        (o) Maneuver new_car_maneuver [*]
                                                                            (-) Event spawn_new_car_car_event [*]
                                                                                --> spawnCar>new_car_car_manGroup>spawn_new_car_car_event Done? [✕] -- 'spawnCar>new_car_car_manGroup>spawn_new_car_car_event' comparison failed
                                                                                [-] Event spawn_new_car_car_event [*]
                                                                                    (o) Parallel Condition Groups [*]
                                                                                        (o) Condition Group [*]
                                                                                            (-) SimulationTimeCondition [*]
                                                                                                --> spawnCar>new_car_car_manGroup>spawn_new_car_car_event>None>None>spawn_new_car_car_trigger Done? [✕] -- 'spawnCar>new_car_car_manGroup>spawn_new_car_car_event>None>None>spawn_new_car_car_trigger' comparison failed
                                                                                                [-] OneShot [*]
                                                                                                    --> SimulationTimeCondition [*]
                                                                                                    --> Mark Done [-]
                                                                                    --> Actions [-]
                                                                                        (o) Actions [-]
                                                                                            (-) SpawnActor [-]
                                                                                                --> spawnCar>new_car_car_manGroup>spawn_new_car_car_event>spawn_new_car_car_action>0 Done? [-]
                                                                                                [-] OneShot [-]
                                                                                                    --> SpawnActor [-]
                                                                                                        --> SpawnActor [-]
                                                                                                    --> Mark Done [-]
                                                                                            (-) new_car_action [-]
                                                                                                --> spawnCar>new_car_car_manGroup>spawn_new_car_car_event>new_car_action>0 Done? [-]
                                                                                                [-] OneShot [-]
                                                                                                    --> new_car_action [-]
                                                                                                        --> new_car_action [-]
                                                                                                    --> Mark Done [-]
                                                                                    --> Mark Done [-]
                                                                    --> Mark Done [-]
                                                    --> Clear Descendant Variables of spawnCar>new_car_car_manGroup [-]
                                                --> Mark Done [-]
                    --> Mark Done [-]
(o) EndConditions (Criteria Group) [*]
--> TimeOut [*]
--> UpdateAllActorControls [*]

--------- Tick ---------

[ERROR] SpawnActor           : A behaviour returned an invalid status, setting to INVALID [None][SpawnActor]

SCENARIO [✕]
--> WeatherBehavior [-]
[-] behavior [✕]
    (o) behavior [✕]
        (-) ParametersInit [✓]
            --> InitialParameterSettings Done? [✓] -- 'InitialParameterSettings' comparison succeeded
            [-] OneShot [-]
                (o) ParametersInit [-]
                --> Mark Done [-]
        (-) EnvironmentBehavior [✓]
            --> InitialEnvironmentSettings Done? [✓] -- 'InitialEnvironmentSettings' comparison succeeded
            [-] OneShot [-]
                (o) EnvironmentBehavior [-]
                    (-) ChangeWeather [-]
                        --> InitialWeather Done? [-] -- 'InitialWeather' comparison failed
                        [-] OneShot [-]
                            --> ChangeWeather [-]
                            --> Mark Done [-]
                    (-) ChangeRoadFriction [-]
                        --> InitRoadFriction Done? [-] -- 'InitRoadFriction' comparison failed
                        [-] OneShot [-]
                            --> ChangeRoadFriction [-]
                            --> Mark Done [-]
                --> Mark Done [-]
        (-) InitBehaviour [✓]
            --> InitialActorSettings Done? [✓] -- 'InitialActorSettings' comparison succeeded
            [-] OneShot [-]
                (o) InitBehaviour [-]
                    [-] InitActornew_car [-]
                        --> ChangeActorControl [-]
                    [-] InitActorTarget [-]
                        --> ChangeActorControl [-]
                --> Mark Done [-]
        (o) OSCStories [✕]
            (-) MyStory [✕]
                --> >MyStory Done? [✕] -- '>MyStory' comparison failed
                [-] OneShot [✕]
                    (o) MyStory [✕]
                        [-] Act StartConditions and behaviours [-]
                            (o) StartConditions Group [-]
                                (o) StartConditions [-]
                                    (o) Condition Group [-]
                                        (-) SimulationTimeCondition [-]
                                            --> Behavior>None>None>act_start Done? [-] -- 'Behavior>None>None>act_start' comparison failed
                                            [-] OneShot [-]
                                                --> SimulationTimeCondition [-]
                                                --> Mark Done [-]
                            (o) Maneuver + EndConditions Group [-]
                                --> Maneuvers [-]
                                    (o) Maneuvers [-]
                                        (-) RoutingManeuver [-]
                                            --> Behavior>RoutingManeuver Done? [-] -- 'Behavior>RoutingManeuver' comparison failed
                                            [-] RoutingManeuver [-]
                                                [-] RepeatableBehaviour of Behavior>RoutingManeuver [-]
                                                    --> RoutingManeuver [-]
                                                        (o) RoutingManeuver [-]
                                                            (-) Maneuver FollowingRouteManeuver [-]
                                                                --> Behavior>RoutingManeuver>FollowingRouteManeuver Done? [-] -- 'Behavior>RoutingManeuver>FollowingRouteManeuver' comparison failed
                                                                [-] OneShot [-]
                                                                    --> Maneuver FollowingRouteManeuver [-]
                                                                        (o) Maneuver FollowingRouteManeuver [-]
                                                                            (-) Event TrajectoryEvent [-]
                                                                                --> Behavior>RoutingManeuver>TrajectoryEvent Done? [-] -- 'Behavior>RoutingManeuver>TrajectoryEvent' comparison failed
                                                                                [-] Event TrajectoryEvent [-]
                                                                                    (o) Parallel Condition Groups [-]
                                                                                        (o) Condition Group [-]
                                                                                            (-) SimulationTimeCondition [-]
                                                                                                --> Behavior>RoutingManeuver>TrajectoryEvent>None>None>StartAction Done? [-] -- 'Behavior>RoutingManeuver>TrajectoryEvent>None>None>StartAction' comparison failed
                                                                                                [-] OneShot [-]
                                                                                                    --> SimulationTimeCondition [-]
                                                                                                    --> Mark Done [-]
                                                                                    --> Actions [-]
                                                                                        (o) Actions [-]
                                                                                            (-) FollowRoute [-]
                                                                                                --> Behavior>RoutingManeuver>TrajectoryEvent>FollowRoute>1 Done? [-] -- 'Behavior>RoutingManeuver>TrajectoryEvent>FollowRoute>1' comparison failed
                                                                                                [-] OneShot [-]
                                                                                                    --> FollowRoute [-]
                                                                                                        --> FollowRoute [-]
                                                                                                    --> Mark Done [-]
                                                                                    --> Mark Done [-]
                                                                    --> Mark Done [-]
                                                    --> Clear Descendant Variables of Behavior>RoutingManeuver [-]
                                                --> Mark Done [-]
                        [-] Act StartConditions and behaviours [✕]
                            (o) StartConditions Group [✓]
                                (o) StartConditions [✓]
                                    (o) Condition Group [✓]
                                        (-) SimulationTimeCondition [✓]
                                            --> spawnCar>None>None>act_start Done? [✕] -- 'spawnCar>None>None>act_start' comparison failed
                                            [-] OneShot [✓]
                                                --> SimulationTimeCondition [✓]
                                                --> Mark Done [✓] -- success
                            (o) Maneuver + EndConditions Group [✕]
                                --> Maneuvers [✕]
                                    (o) Maneuvers [✕]
                                        (-) new_car_car_manGroup [✕]
                                            --> spawnCar>new_car_car_manGroup Done? [✕] -- 'spawnCar>new_car_car_manGroup' comparison failed
                                            [-] new_car_car_manGroup [✕]
                                                [-] RepeatableBehaviour of spawnCar>new_car_car_manGroup [✕]
                                                    --> new_car_car_manGroup [✕]
                                                        (o) new_car_car_manGroup [✕]
                                                            (-) Maneuver new_car_maneuver [✕]
                                                                --> spawnCar>new_car_car_manGroup>new_car_maneuver Done? [✕] -- 'spawnCar>new_car_car_manGroup>new_car_maneuver' comparison failed
                                                                [-] OneShot [✕]
                                                                    --> Maneuver new_car_maneuver [✕]
                                                                        (o) Maneuver new_car_maneuver [✕]
                                                                            (-) Event spawn_new_car_car_event [✕]
                                                                                --> spawnCar>new_car_car_manGroup>spawn_new_car_car_event Done? [✕] -- 'spawnCar>new_car_car_manGroup>spawn_new_car_car_event' comparison failed
                                                                                [-] Event spawn_new_car_car_event [✕]
                                                                                    (o) Parallel Condition Groups [✓]
                                                                                        (o) Condition Group [✓]
                                                                                            (-) SimulationTimeCondition [✓]
                                                                                                --> spawnCar>new_car_car_manGroup>spawn_new_car_car_event>None>None>spawn_new_car_car_trigger Done? [✕] -- 'spawnCar>new_car_car_manGroup>spawn_new_car_car_event>None>None>spawn_new_car_car_trigger' comparison failed
                                                                                                [-] OneShot [✓]
                                                                                                    --> SimulationTimeCondition [✓]
                                                                                                    --> Mark Done [✓] -- success
                                                                                    --> Actions [✕]
                                                                                        (o) Actions [✕]
                                                                                            (-) SpawnActor [✕]
                                                                                                --> spawnCar>new_car_car_manGroup>spawn_new_car_car_event>spawn_new_car_car_action>0 Done? [✕] -- 'spawnCar>new_car_car_manGroup>spawn_new_car_car_event>spawn_new_car_car_action>0' comparison failed
                                                                                                [-] OneShot [-]
                                                                                                    --> SpawnActor [-]
                                                                                                        --> SpawnActor [-]
                                                                                                    --> Mark Done [-]
                                                                                            (-) new_car_action [-]
                                                                                                --> spawnCar>new_car_car_manGroup>spawn_new_car_car_event>new_car_action>0 Done? [-] -- 'spawnCar>new_car_car_manGroup>spawn_new_car_car_event>new_car_action>0' comparison failed
                                                                                                [-] OneShot [-]
                                                                                                    --> new_car_action [-]
                                                                                                        --> new_car_action [-]
                                                                                                    --> Mark Done [-]
                                                                                    --> Mark Done [-]
                                                                    --> Mark Done [-]
                                                    --> Clear Descendant Variables of spawnCar>new_car_car_manGroup [-]
                                                --> Mark Done [-]
                    --> Mark Done [-]
(o) EndConditions (Criteria Group) [-]
--> TimeOut [-]
--> UpdateAllActorControls [-]
ScenarioManager: Terminated due to failure
Nothing to analyze, this scenario has no criteria
Not all scenario tests were successful
Please run with --output for further information
No more scenarios .... Exiting
starrye commented 3 weeks ago

I doubt there is a bug, you can update srunner scenariomanager/scenarioatomics/atomic_behaviors class AddActorupdate method to verify.

    def update(self):
        new_status = py_trees.common.Status.RUNNING
        try:
            new_actor = CarlaDataProvider.request_new_actor(
                self._actor_type, self._spawn_point, color=self._color)
            if new_actor:
                new_status = py_trees.common.Status.SUCCESS
        except:  # pylint: disable=bare-except
            print("ActorSource unable to spawn actor")
            new_status = py_trees.common.Status.FAILURE
        finally:
            return new_status
vollkornholztuer commented 3 weeks ago

I'll try it out and will update soon.

vollkornholztuer commented 3 weeks ago

I tried it out and it worked. The car now spawns, stays there and doesn't crash the simulation. Thank you very much :)