carla-simulator / scenario_runner

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

Can we define present Traffic light and Intersection scenarios in OpenSCENARIO? #334

Closed deepakreddy63 closed 3 years ago

deepakreddy63 commented 5 years ago

Hi @fabianoboril ,

I was trying to implement the traffic light scenarios in current Traffic scenarios in openSCENARIO format and was confused as to how to include traffic lights or intersection details in the openScenario file. I don't see any support for these in openSCENARIO schema. Any help is appreciated.

Also, can we use Waypoint follower for longitudinal action in openSCENARIO by adding terminal conditions similar to KeepVelocity atomic behavior. This will make vehicle follow the path as keepVelocity is causing vehicle to move out of lane sometimes.

Thanks P.S: I could add Lateral action from my side extending the current OpenSCENARIO features

fabianoboril commented 5 years ago

Hi @deepakreddy63,

great to hear that you can support the development. This is always very welcome. The standard process is that you open a pull request for your addition, and then we review this PR. So, if you have something already at hand for lateral actions, we are more than happy to integrate it.

Regarding the traffic lights. OpenSCENARIO has conditions that make use of States (ByState), and one of them uses Signals. `

` The waypoint follower is already used for Routing actions :) Bests
deepakreddy63 commented 5 years ago

Hi @fabianoboril,

Thanks for the response. I'm glad to contribute. How do I create a pull request as I don't have write access to scenario_runner repository. Can you give any suggestions as to how to proceed with this.

Thanks

fabianoboril commented 5 years ago

Hi, you can fork the repo into your own github space, update the code there and then create a PR here :)

jS5t3r commented 4 years ago

Can the traffic lights edited via Infrastructure or Roadnetwork? When I start the scenario, I want to have the traffic lights in an exact state. I think that now it is just for conditions... in the storyboard...

<Event name="PedestrianStartsWalking" priority="overwrite">
    <Action name="PedestrianStartsWalking">
        <Private>
            <Longitudinal>
                <Speed>
                    <Dynamics shape="step" rate="0" distance="8" />
                    <Target>
                        <Absolute value="10.0" />
                    </Target>
                </Speed>
            </Longitudinal>
        </Private>
    </Action>
    <StartConditions>
        <ConditionGroup>
            <Condition name="StartCondition" delay="0" edge="rising">
                <ByState>
                    <Signal name="20" state="RED" />
                </ByState>
            </Condition>
        </ConditionGroup>
    </StartConditions>
</Event>

Error Message:

The scenario cannot be loaded
ByState Signal conditions are not yet supported
No more scenarios .... Exiting

In the current master branch, line 315: https://github.com/carla-simulator/scenario_runner/blob/master/srunner/tools/openscenario_parser.py

fabianoboril commented 4 years ago

Hi,

this will work inside a maneuver section:

                     <Event name="TrafficLight" priority="overwrite">
                        <Action name="TrafficLight">
                            <Global>
                                <Infrastructure>
                                    <Signal>
                                        <SetState name="158" state="green" />
                                    </Signal>
                                </Infrastructure>
                            </Global>
                        </Action>
                        <StartConditions>
                          ...
                        </StartConditions>
                    </Event>
jS5t3r commented 4 years ago

Hi, Thanks. Almost working. Every time, when I start: ` , where 158 is the actor id. Every time, when I start OpenSCENARIO (python scenario_runner.py --openscenario srunner/examples/traffic.xosc --reloadWorld), the traffic lights have different IDs. Aren't there any global IDs?

    def show_closest_trafficlights(self):
        def print_trafficlightlist(traffic_lights):
            print("==========================================")
            print("=== Prints a list of closest traffic lights: ")
            for tf in traffic_lights:
                print(tf[0], tf[1].id, tf[1].type_id)
            print("==========================================")

        self.actors_list = self.world.get_actors().filter('traffic.traffic_light*')
        closest_traffic_lights = []
        for actor in self.actors_list:
            d = euclidean_dist(self.vehicle, actor)
            closest_traffic_lights.append((d, actor))

        closest_traffic_lights.sort(key=itemgetter(0))
        print_trafficlightlist(closest_traffic_lights)

My solution: give a traffic light a fix number in the xosc file. If this number occurs I have saved the location and compared it with the location of all traffic lights. If I have found this location, I get the id of this traffic light. I would program that in the scenario manager. Is there a more generic solution?

fabianoboril commented 4 years ago

Hi, the IDs change if CARLA is not properly restarted. Maybe this should be addressed at the CARLA main repo. We used the other work around a while ago as well. However, I would prefer to ensure that the traffic light IDs do not change (at the moment I recommend to restart the CARLA server).

fabianoboril commented 3 years ago

IDs are meanwhile supported.

ssap09 commented 4 months ago

Hi, I am trying to use carla and import an osc file to simulate the scenario. I am not able to find any osc file which has traffic signal information, Can anyone please share an example osc file which has traffic signals information which can be imported to carla? Any help is appreciated. Thanks in advance.