安装
$ sudo apt install gnupg software-properties-common
$ sudo mkdir -m755 -p /etc/apt/keyrings$ sudo wget -O /etc/apt/keyrings/qgis-archive-keyring.gpg https://download.qgis.org/downloads/qgis-archive-keyring.gpg
Types: deb deb-src
URIs: https://qgis.org/debian
Suites: focal
Architectures: amd64
Components: main
Signed-By: /etc/apt/keyrings/qgis-archive-keyring.gpg
$ sudo apt update
$ sudo apt install qgis qgis-plugin-grass
clone https://github.com/carla-simulator/traffic-generation-editor.git$ cd traffic-generation-editor$ pip3 install --user -r /path/to/requirements.txt git
使用实例
为后续的正确使用,需要对坐标系进行设置。单击状态栏上的 CRS 图标以显示 “Project Properties”窗口,并从左侧的选项卡菜单中选择“CRS” 。在“Filter”文本框中输入“WGS 84”,在“Predefined Coordinate Reference Systems”窗口中会相关的坐标系列表,从“Geographic Coordinate Systems”中选择“WGS84(EPSD:4326)”,然后单击“OK”按钮。
横向和纵向行为需要设置的内容和其含义如下表所示。
单击OpenSCENARIO Editor Toolkit工具栏的Export OpenSCENARIO file按钮,并在弹出的Export XOSC窗口中选择Road Network为“Town06”,点击Save to文本框右侧的“...”按钮后选择文件夹并设置文件名(此处设置为“tge_example”)后点击“OK”,即可导出OpenSCENARIO文件。
需要注意的是,当前TGE版本(commit 98ce87b)有个问题,当为某个交通参与者配置多个行为时,每个行为都要单独添加,其生成的OpenSCENARIO文件中会将同一个交通参与者的不同行为错误放置到多个“Maneuver”中,而正确的方式应该是放置到同一“Maneuver”的不同“Event”中。
下面为上述导出的OpenSCENARIO文件中描述Vehicle_1的横向和纵向行为的内容,可以看到横向行为(第4~31行)和纵向行为(第3~61行)在两个“Maneuver”中,并且各含有一个“Actors”内容(第4~6行和第33~35行),这样的描述是错误的。
1.<!-- *** Vehicle_1的所有Maneuver *** -->
2.<ManeuverGroup maximumExecutionCount="1" name="Maneuver group for Vehicle_1">
3. <!-- *** 横向行为 *** -->
4. <Actors selectTriggeringEntities="false">
5. <EntityRef entityRef="Vehicle_1"/>
6. </Actors>
7. <Maneuver name="Maneuver ID 1">
8. <Event name="Event Maneuver ID 1" priority="overwrite">
9. <Action name="Action for Manuever ID 1">
10. <PrivateAction>
11. <LateralAction>
12. <LaneChangeAction>
13. <LaneChangeActionDynamics dynamicsShape="linear" value="30" dynamicsDimension="distance"/>
14. <LaneChangeTarget>
15. <RelativeTargetLane entityRef="Vehicle_1" value="1"/>
16. </LaneChangeTarget>
17. </LaneChangeAction>
18. </LateralAction>
19. </PrivateAction>
20. </Action>
21. <StartTrigger>
22. <ConditionGroup>
23. <Condition name="Condition for Maneuver ID 1" delay="0" conditionEdge="rising">
24. <ByValueCondition>
25. <SimulationTimeCondition value="20.0" rule="greaterThan"/>
26. </ByValueCondition>
27. </Condition>
28. </ConditionGroup>
29. </StartTrigger>
30. </Event>
31. </Maneuver>
32. <!-- *** 纵向行为 *** -->
33. <Actors selectTriggeringEntities="false">
34. <EntityRef entityRef="Vehicle_1"/>
35. </Actors>
36. <Maneuver name="Maneuver ID 3">
37. <Event name="Event Maneuver ID 3" priority="overwrite">
38. <Action name="Action for Manuever ID 3">
39. <PrivateAction>
40. <LongitudinalAction>
41. <SpeedAction>
42. <SpeedActionDynamics dynamicsShape="linear" value="1" dynamicsDimension="rate"/>
43. <SpeedActionTarget>
44. <AbsoluteTargetSpeed value="15"/>
45. </SpeedActionTarget>
46. </SpeedAction>
47. </LongitudinalAction>
48. </PrivateAction>
49. </Action>
50. <StartTrigger>
51. <ConditionGroup>
52. <Condition name="Condition for Maneuver ID 3" delay="0" conditionEdge="rising">
53. <ByValueCondition>
54. <SimulationTimeCondition value="20.0" rule="greaterThan"/>
55. </ByValueCondition>
56. </Condition>
57. </ConditionGroup>
58. </StartTrigger>
59. </Event>
60. </Maneuver>
61.</ManeuverGroup>
下面为将上述错误手动修复后的正确内容,横向行为和纵向行为由同一个“Maneuver”中的两个“Event”来描述,大伙可对比一下。
1.<!-- *** Vehicle_1的所有Maneuver *** -->
2.<ManeuverGroup maximumExecutionCount="1" name="Maneuver group for Vehicle_1">
3. <Actors selectTriggeringEntities="false">
4. <EntityRef entityRef="Vehicle_1"/>
5. </Actors>
6. <Maneuver name="Maneuver ID 1">
7. <!-- *** 横向行为 *** -->
8. <Event name="Event Maneuver ID 1" priority="overwrite">
9. <Action name="Action for Manuever ID 1">
10. <PrivateAction>
11. <LateralAction>
12. <LaneChangeAction>
13. <LaneChangeActionDynamics dynamicsShape="linear" value="30" dynamicsDimension="distance"/>
14. <LaneChangeTarget>
15. <RelativeTargetLane entityRef="Vehicle_1" value="1"/>
16. </LaneChangeTarget>
17. </LaneChangeAction>
18. </LateralAction>
19. </PrivateAction>
20. </Action>
21. <StartTrigger>
22. <ConditionGroup>
23. <Condition name="Condition for Maneuver ID 1" delay="0" conditionEdge="rising">
24. <ByValueCondition>
25. <SimulationTimeCondition value="20.0" rule="greaterThan"/>
26. </ByValueCondition>
27. </Condition>
28. </ConditionGroup>
29. </StartTrigger>
30. </Event>
31. <!-- *** 纵向行为 *** -->
32. <Event name="Event Maneuver ID 3" priority="overwrite">
33. <Action name="Action for Manuever ID 3">
34. <PrivateAction>
35. <LongitudinalAction>
36. <SpeedAction>
37. <SpeedActionDynamics dynamicsShape="linear" value="1" dynamicsDimension="rate"/>
38. <SpeedActionTarget>
39. <AbsoluteTargetSpeed value="15"/>
40. </SpeedActionTarget>
41. </SpeedAction>
42. </LongitudinalAction>
43. </PrivateAction>
44. </Action>
45. <StartTrigger>
46. <ConditionGroup>
47. <Condition name="Condition for Maneuver ID 3" delay="0" conditionEdge="rising">
48. <ByValueCondition>
49. <SimulationTimeCondition value="20.0" rule="greaterThan"/>
50. </ByValueCondition>
51. </Condition>
52. </ConditionGroup>
53. </StartTrigger>
54. </Event>
55. </Maneuver>
56.</ManeuverGroup>
参考《仿真测试入门参考(22):CARLA的交通场景》中运行OpenSCENARIO文件的说明,运行导出的OpenSCENARIO文件。
首先,打开一个终端,启动CARLA:
cd /path/to/carla
./CarlaUE4.sh
然后,再开一个终端,运行ScenarioRunner:
cd /path/to/scenario_runner
python3 scenario_runner.py --output --openscenario tge_example.xosc
成功运行的画面如下图所示。