scenario_runner icon indicating copy to clipboard operation
scenario_runner copied to clipboard

Controlling Ego Vehicle openSCENARIO

Open werewolfdev opened this issue 4 years ago • 25 comments

Hey , I am using openSCENARIO for creating scenarios with CARLA and would like to control the ego vehicle in autopilot , provide a constant velocity or particular dynamics and assign a route to the ego vehicle

I have provided vehicle.set_autopilot(True) in manual_control.py and used the function of enable constant velocity as well. I would like to know if we can assign a route to the ego vehicle while in autopilot mode . Can you kindly let me know fi there is any support for this.

I couldnot find the simple_vehicle_control in github similar to some other friends who mentioned the same in some other ticket.Thanks in advance

  • OS: [e.g. Ubuntu 18.04]
  • CARLA Version [e.g. CARLA 0.9.11]
  • Python version [e.g. 2.7]
  • Version [e.g. 0.9.11]

werewolfdev avatar Sep 20 '21 13:09 werewolfdev

I could find a simple_vehicle_control python script in the atomics folder .But Iam uncertain of how to use it with openSCENARIO

werewolfdev avatar Sep 20 '21 13:09 werewolfdev

Hi, you can find an example here: https://github.com/carla-simulator/scenario_runner/blob/05a811a6248c8033e4c76185ff40ae5eccad7e69/srunner/examples/OscControllerExample.xosc#L77 Just replace external_control with simple_vehicle_control

fabianoboril avatar Sep 20 '21 14:09 fabianoboril

@fabianoboril Hi, Thanks for the quick response. So I replace the control type with simple_vehicle_control and then for providing a route for my ego vehicle how can I go forth doing it. Sorry I couldnt understand it still

werewolfdev avatar Sep 20 '21 14:09 werewolfdev

You provide the route through a Route Maneuver, e.g.

         <Action name="TakingPrio1Drive2">
            <PrivateAction>
              <RoutingAction>
                <AssignRouteAction>
                  <Route name="TurnRight" closed="false">
                    <Waypoint routeStrategy="fastest">
                      <Position>
                        <WorldPosition x="88" y="300" z="0" h="0"/>
                      </Position>
                    </Waypoint>
                    <Waypoint routeStrategy="fastest">
                      <Position>
                        <WorldPosition x="88" y="322" z="0" h="0"/>
                      </Position>
                    </Waypoint>
                    <Waypoint routeStrategy="fastest">
                      <Position>
                        <WorldPosition x="87" y="328" z="0" h="0"/>
                      </Position>
                    </Waypoint>
                    <Waypoint routeStrategy="fastest">
                      <Position>
                        <WorldPosition x="82" y="330" z="0" h="0"/>
                      </Position>
                    </Waypoint>
                    <Waypoint routeStrategy="fastest">
                      <Position>
                        <WorldPosition x="70" y="330" z="0" h="0"/>
                      </Position>
                    </Waypoint>
                    <Waypoint routeStrategy="fastest">
                      <Position>
                        <WorldPosition x="68" y="330" z="0" h="0"/>
                      </Position>
                    </Waypoint>
                    <Waypoint routeStrategy="fastest">
                      <Position>
                        <WorldPosition x="65" y="330" z="0" h="0"/>
                      </Position>
                    </Waypoint>
                  </Route>
                </AssignRouteAction>
              </RoutingAction>
            </PrivateAction>
          </Action>

fabianoboril avatar Sep 20 '21 14:09 fabianoboril

Hi , Will try this out and update here soon

werewolfdev avatar Sep 20 '21 14:09 werewolfdev

@fabianoboril Preparing scenario: LaneChangeSimple Warning: Maneuvergroup ManeuverSequence does not use reference actors! ScenarioManager: Running scenario OpenScenario Traceback (most recent call last): File "scenario_runner.py", line 405, in _load_and_run_scenario self.manager.run_scenario() File "/home/schemba/carla/scenario_runner-0.9.11/srunner/scenariomanager/scenario_manager.py", line 133, in run_scenario self._tick_scenario(timestamp) File "/home/schemba/carla/scenario_runner-0.9.11/srunner/scenariomanager/scenario_manager.py", line 174, in _tick_scenario self.scenario_tree.tick_once() File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/behaviour.py", line 158, in tick_once for unused in self.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 578, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 494, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 578, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 578, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 494, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 578, in tick for node in child.tick(): File "/home/schemba/carla/scenario_runner-0.9.11/srunner/tools/py_trees_port.py", line 61, in tick for node in self.decorated.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 578, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 309, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 494, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 494, in tick for node in child.tick(): File "/home/schemba/carla/scenario_runner-0.9.11/srunner/tools/py_trees_port.py", line 61, in tick for node in self.decorated.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 578, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 309, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 494, in tick for node in child.tick(): File "/home/schemba/carla/scenario_runner-0.9.11/srunner/tools/py_trees_port.py", line 61, in tick for node in self.decorated.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 578, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 309, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 494, in tick for node in child.tick(): File "/home/schemba/carla/scenario_runner-0.9.11/srunner/tools/py_trees_port.py", line 61, in tick for node in self.decorated.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 578, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 309, in tick for node in child.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/composites.py", line 494, in tick for node in child.tick(): File "/home/schemba/carla/scenario_runner-0.9.11/srunner/tools/py_trees_port.py", line 61, in tick for node in self.decorated.tick(): File "/home/schemba/.local/lib/python2.7/site-packages/py_trees/behaviour.py", line 247, in tick self.initialise() File "/home/schemba/carla/scenario_runner-0.9.11/srunner/scenariomanager/scenarioatomics/atomic_behaviors.py", line 746, in initialise if not actor_dict or not self._actor.id in actor_dict: AttributeError: 'NoneType' object has no attribute 'id' 'NoneType' object has no attribute 'id' Resetting ego-vehicle! Destroying ego vehicle 207 ERROR: failed to destroy actor 207 : unable to destroy actor: not found No more scenarios .... Exiting

After running the xosc file, the ego vehicle just starts to move and the window closes with these error messages. Can you kindly let me know what this is about. Thanks in advance.

werewolfdev avatar Sep 21 '21 06:09 werewolfdev

Can you share the scenario file?

fabianoboril avatar Sep 21 '21 06:09 fabianoboril

Yes sure @fabianoboril

werewolfdev avatar Sep 21 '21 06:09 werewolfdev

And I have provided vehilce.set_autopilot(True) in manual_control.py

werewolfdev avatar Sep 21 '21 06:09 werewolfdev

werewolfdev avatar Sep 21 '21 06:09 werewolfdev

werewolfdev avatar Sep 21 '21 06:09 werewolfdev

@fabianoboril I have attached the xosc file

werewolfdev avatar Sep 21 '21 06:09 werewolfdev

You don't need manual control anymore, as the ego vehicle is now controlled through simple_vehicle_control. If you like, you can add a camera like this:

                            <Controller name="HeroAgent">
                                <Properties>
                                    <Property name="module" value="simple_vehicle_control"/>
                                    <Property name="attach_camera" value="true"/>
                                </Properties>
                            </Controller>

In our scenario, there is one mistake:

    <ManeuverGroup maximumExecutionCount="1" name="ManeuverSequence">
      <Actors selectTriggeringEntities="false">
        <EntityRef entityRef="ego_vehicle"/>
      </Actors>

Instead of ego_vehicle, this has to be hero.

Have you seen the graphical scenario creation tool? I think this will be helpful, to avoid such mistakes.

fabianoboril avatar Sep 21 '21 06:09 fabianoboril

Reagrding the graphical scenario creation tool, do you mean esmini scenario editor. In other cases I havent seen

werewolfdev avatar Sep 21 '21 07:09 werewolfdev

@fabianoboril I received a small window. 3 questions about this:

a) The ego vehicle is moving but cannot find the stationary target b)Is there are a way to increase the window size c)The coordinates x and y displayed on the window doesnt match the ones given in the xosc for teleport action

I actually tried another xosc file but no window opens but at the end output window displays traveled distance as 200 m and all. IS it a bug

werewolfdev avatar Sep 21 '21 09:09 werewolfdev

In order to see a camera window, please add "<Property name="attach_camera" value="true"/>" to the controller, as I mentioned above.

The window size can be adapted in the code: https://github.com/carla-simulator/scenario_runner/blob/master/srunner/scenariomanager/actorcontrols/visualizer.py

The displayed window is an OpenCV camera capture. The x-y-coordinates are pixel coordinates and have no correlation with CARLA coordinates.

fabianoboril avatar Sep 21 '21 14:09 fabianoboril

Hi @fabianoboril Thanks for that.

a) But I couldnot find the stationary object which I have coded in the above txt .Also other xosc scenarios which I have created just seems to be run but without displaying any output window. Do you have any inputs on these questions too. I have actually already added camera as you mentioned while defining the controller b) ABout visualizer.py, Iam suing SR 0.9.11 and has no visualizer python script inside actor controls folder . Any comments on that too would be helpful

c)openSCENARIO Editor GUI . CAn u kidnly share the link for that . I could find one editor called edabi based on esmini but with very little or zero docu

werewolfdev avatar Sep 21 '21 14:09 werewolfdev

Can you update to the 0.9.11 branch (not tag)? This will most likely solve many of your issues.

fabianoboril avatar Sep 21 '21 15:09 fabianoboril

Yes will try that out. Thanks

werewolfdev avatar Sep 21 '21 15:09 werewolfdev

Hi @fabianoboril Traceback (most recent call last): File "scenario_runner.py", line 37, in from srunner.scenariomanager.scenario_manager import ScenarioManager File "/home/schemba/carla/scenario_runner-0.9.11/srunner/scenariomanager/scenario_manager.py", line 23, in from srunner.scenariomanager.watchdog import Watchdog File "/home/schemba/carla/scenario_runner-0.9.11/srunner/scenariomanager/watchdog.py", line 14, in import simple_watchdog_timer as swt File "/home/schemba/.local/lib/python2.7/site-packages/simple_watchdog_timer.py", line 11 def init(self, callback, check_interval_sec: float = 0.01, trigger_delta_sec: float = 1, identifier=None): ^ SyntaxError: invalid syntax Received this error when trying to run a xosc example from the 0.9.11 branch. I have installed watch dog timer version 0.1.1

werewolfdev avatar Sep 21 '21 15:09 werewolfdev

Hi @fabianoboril Do you ahve any insights on this

werewolfdev avatar Sep 22 '21 06:09 werewolfdev

incase of adding the camera would adding that single line suffice? Is there any way to save the images that come from the camera sensors by defining in the xosc file ?

NaveedBhuiyan avatar Feb 17 '23 09:02 NaveedBhuiyan

@werewolfdev Were you able to run the xosc file successfully?

arjunsk07 avatar Mar 06 '23 10:03 arjunsk07