Skip to content

Commit 83103e6

Browse files
scpa1055cassava
authored andcommitted
VTD: Add support for xosc v1.0
this commit includes: - modifing vtd_binding.cpp to support reading of xosc xml tags - adding more roadmark_types to omni_sensor_component.cpp - adding xosc test case with corresponding xodr and osgb file
1 parent 2076e1f commit 83103e6

File tree

8 files changed

+467
-14
lines changed

8 files changed

+467
-14
lines changed

optional/vtd/contrib/projects/cloe_tests/Databases/Germany.2018

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Distros/Current/Databases/Germany_2018.opt.osgb
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../Distros/Current/Databases/Germany_2018.xodr
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- Demonstrate and test ACC controller -->
3+
<!-- A white car is driving with constant speed, set by init event -->
4+
<!-- The white car approaches a red leading car -->
5+
<!-- The red leading car will perform some maneuvers to exercise the ACC function -->
6+
7+
<OpenSCENARIO>
8+
<FileHeader revMajor="1" revMinor="0" date="2020-02-21T10:00:00" description="straight 500m" author="Patrick Schuster, Bosch"/>
9+
<CatalogLocations>
10+
<VehicleCatalog>
11+
<Directory path="Distros/Current/Config/Players/Vehicles" />
12+
</VehicleCatalog>
13+
</CatalogLocations>
14+
<RoadNetwork>
15+
<LogicFile filepath="Projects/Current/Databases/Germany.2018/Germany_2018.xodr"/>
16+
<SceneGraphFile filepath="Projects/Current/Databases/Germany.2018/Germany_2018.opt.osgb"/>
17+
</RoadNetwork>
18+
<Entities>
19+
<ScenarioObject name="Ego">
20+
<Vehicle name="Audi_A3_2009_black" vehicleCategory="car">
21+
<ParameterDeclarations/>
22+
<Performance maxSpeed="69.444" maxAcceleration="200" maxDeceleration="10.0"/>
23+
<BoundingBox>
24+
<Center x="1.5" y="0.0" z="0.9"/>
25+
<Dimensions width="2.1" length="4.5" height="1.8"/>
26+
</BoundingBox>
27+
<Axles>
28+
<FrontAxle maxSteering="0.5" wheelDiameter="0.6" trackWidth="1.8" positionX="3.1" positionZ="0.3"/>
29+
<RearAxle maxSteering="0.0" wheelDiameter="0.6" trackWidth="1.8" positionX="0.0" positionZ="0.3"/>
30+
</Axles>
31+
<Properties>
32+
<Property name="control" value="external"/>
33+
</Properties>
34+
</Vehicle>
35+
</ScenarioObject>
36+
<ScenarioObject name="Opponent">
37+
<Vehicle name="Audi_A3_2009_white" vehicleCategory="car">
38+
<ParameterDeclarations/>
39+
<Performance maxSpeed="69.444" maxAcceleration="200" maxDeceleration="10.0"/>
40+
<BoundingBox>
41+
<Center x="1.5" y="0.0" z="0.9"/>
42+
<Dimensions width="2.1" length="4.5" height="1.8"/>
43+
</BoundingBox>
44+
<Axles>
45+
<FrontAxle maxSteering="0.5" wheelDiameter="0.6" trackWidth="1.8" positionX="3.1" positionZ="0.3"/>
46+
<RearAxle maxSteering="0.0" wheelDiameter="0.6" trackWidth="1.8" positionX="0.0" positionZ="0.3"/>
47+
</Axles>
48+
<Properties>
49+
<Property name="control" value="internal"/>
50+
</Properties>
51+
</Vehicle>
52+
</ScenarioObject>
53+
</Entities>
54+
<Storyboard>
55+
<Init>
56+
<Actions>
57+
<Private entityRef="Ego">
58+
<PrivateAction>
59+
<TeleportAction>
60+
<Position>
61+
<!--<LanePosition roadId="1" laneId="-1" offset="0" s="10"/>-->
62+
<WorldPosition x="3641.578" y="-7263.547" z="0" h="0" p="0" r="0" />
63+
</Position>
64+
</TeleportAction>
65+
</PrivateAction>
66+
<PrivateAction>
67+
<LongitudinalAction>
68+
<SpeedAction>
69+
<SpeedActionDynamics dynamicsShape="step" value="0" dynamicsDimension="time"/>
70+
<SpeedActionTarget>
71+
<AbsoluteTargetSpeed value="30" />
72+
</SpeedActionTarget>
73+
</SpeedAction>
74+
</LongitudinalAction>
75+
</PrivateAction>
76+
</Private>
77+
<Private entityRef="Opponent">
78+
<PrivateAction>
79+
<TeleportAction>
80+
<Position>
81+
<!--<LanePosition roadId="1" laneId="-1" offset="0" s="10"/>-->
82+
<WorldPosition x="3661.578" y="-7263.547" z="0" h="0" p="0" r="0" />
83+
</Position>
84+
</TeleportAction>
85+
</PrivateAction>
86+
</Private>
87+
</Actions>
88+
</Init>
89+
<Story name="Story1">
90+
<Act name="Act1">
91+
<ManeuverGroup name="Sequence2" maximumExecutionCount="1">
92+
<Actors selectTriggeringEntities="true">
93+
<EntityRef entityRef="Opponent" />
94+
</Actors>
95+
<Maneuver name="Maneuver1">
96+
<Event name="Event1" priority="overwrite">
97+
<Action name="Action1">
98+
<PrivateAction>
99+
<LongitudinalAction>
100+
<SpeedAction>
101+
<SpeedActionDynamics dynamicsShape="step" value="0" dynamicsDimension="time" />
102+
<SpeedActionTarget>
103+
<AbsoluteTargetSpeed value="30" />
104+
</SpeedActionTarget>
105+
</SpeedAction>
106+
</LongitudinalAction>
107+
</PrivateAction>
108+
</Action>
109+
<StartTrigger>
110+
<ConditionGroup>
111+
<Condition name="StartCondition1" delay="0" conditionEdge="rising">
112+
<ByValueCondition>
113+
<SimulationTimeCondition value="0" rule="greaterThan" />
114+
</ByValueCondition>
115+
</Condition>
116+
</ConditionGroup>
117+
</StartTrigger>
118+
</Event>
119+
</Maneuver>
120+
<Maneuver name="Maneuver2">
121+
<Event name="Event2" priority="overwrite">
122+
<Action name="Action2">
123+
<PrivateAction>
124+
<LongitudinalAction>
125+
<SpeedAction>
126+
<SpeedActionDynamics dynamicsShape="step" value="0" dynamicsDimension="time" />
127+
<SpeedActionTarget>
128+
<AbsoluteTargetSpeed value="40" />
129+
</SpeedActionTarget>
130+
</SpeedAction>
131+
</LongitudinalAction>
132+
</PrivateAction>
133+
</Action>
134+
<StartTrigger>
135+
<ConditionGroup>
136+
<Condition name="StartCondition2" delay="0" conditionEdge="rising">
137+
<ByValueCondition>
138+
<SimulationTimeCondition value="5" rule="greaterThan" />
139+
</ByValueCondition>
140+
</Condition>
141+
</ConditionGroup>
142+
</StartTrigger>
143+
</Event>
144+
</Maneuver>
145+
</ManeuverGroup>
146+
<ManeuverGroup name="Sequence3" maximumExecutionCount="1">
147+
<Actors selectTriggeringEntities="true">
148+
<EntityRef entityRef="Opponent" />
149+
</Actors>
150+
<Maneuver name="Maneuver3">
151+
<Event name="Event3" priority="overwrite">
152+
<Action name="Action3">
153+
<PrivateAction>
154+
<LongitudinalAction>
155+
<SpeedAction>
156+
<SpeedActionDynamics dynamicsShape="step" value="0" dynamicsDimension="time" />
157+
<SpeedActionTarget>
158+
<AbsoluteTargetSpeed value="25" />
159+
</SpeedActionTarget>
160+
</SpeedAction>
161+
</LongitudinalAction>
162+
</PrivateAction>
163+
</Action>
164+
<StartTrigger>
165+
<ConditionGroup>
166+
<Condition name="StartCondition3" delay="0" conditionEdge="rising">
167+
<ByValueCondition>
168+
<SimulationTimeCondition value="10" rule="greaterThan" />
169+
</ByValueCondition>
170+
</Condition>
171+
</ConditionGroup>
172+
</StartTrigger>
173+
</Event>
174+
</Maneuver>
175+
</ManeuverGroup>
176+
<StartTrigger>
177+
</StartTrigger>
178+
<StopTrigger>
179+
</StopTrigger>
180+
</Act>
181+
</Story>
182+
<StopTrigger>
183+
<ConditionGroup>
184+
<Condition name="StopCondition1" delay="0" conditionEdge="rising">
185+
<ByValueCondition>
186+
<SimulationTimeCondition value="15" rule="greaterThan" />
187+
</ByValueCondition>
188+
</Condition>
189+
</ConditionGroup>
190+
</StopTrigger>
191+
</Storyboard>
192+
</OpenSCENARIO>

optional/vtd/src/omni_sensor_component.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ const std::map<int, cloe::LaneBoundary::Type> vtd_roadmark_type_map = {
149149
{RDB_ROADMARK_TYPE_GRASS, cloe::LaneBoundary::Type::Grass},
150150
{RDB_ROADMARK_TYPE_BOTDOT, cloe::LaneBoundary::Type::Unknown},
151151
{RDB_ROADMARK_TYPE_OTHER, cloe::LaneBoundary::Type::Unknown},
152+
{RDB_ROADMARK_TYPE_SOLID_SOLID, cloe::LaneBoundary::Type::Unknown},
153+
{RDB_ROADMARK_TYPE_BROKEN_SOLID, cloe::LaneBoundary::Type::Unknown},
154+
{RDB_ROADMARK_TYPE_SOLID_BROKEN, cloe::LaneBoundary::Type::Unknown},
155+
{RDB_ROADMARK_TYPE_LANE_CENTER, cloe::LaneBoundary::Type::Unknown},
152156
};
153157

154158
/**

optional/vtd/src/vtd_binding.cpp

+44-13
Original file line numberDiff line numberDiff line change
@@ -627,19 +627,50 @@ class VtdBinding : public cloe::Simulator {
627627
}
628628

629629
void apply_scp_scenario_response(boost::property_tree::ptree& xml) {
630-
auto trafficcontrol = xml.get_child("Scenario").get_child("TrafficControl");
631-
for (auto& it : trafficcontrol) {
632-
if (it.first != "Player") continue;
633-
auto p = it.second;
634-
std::string control = p.get("Description.<xmlattr>.Control", "default");
635-
if (control == "external") {
636-
auto name = p.get("Description.<xmlattr>.Name", "unspecified");
637-
agents_expected_.insert(name);
638-
639-
// Ask VTD to create a vehicle dynamics instance for this vehicle
640-
scp::DynamicsPluginConfig cfg;
641-
cfg.name = name;
642-
scp_client_->send(cfg);
630+
boost::optional<boost::property_tree::ptree&> scenario = xml.get_child_optional("Scenario");
631+
if (scenario) {
632+
auto tc = xml.get_child("Scenario").get_child("TrafficControl");
633+
for (auto& it : tc) {
634+
if (it.first != "Player") {
635+
continue;
636+
}
637+
auto p = it.second;
638+
std::string control = p.get("Description.<xmlattr>.Control", "default");
639+
if (control == "external") {
640+
auto name = p.get("Description.<xmlattr>.Name", "unspecified");
641+
agents_expected_.insert(name);
642+
643+
// Ask VTD to create a vehicle dynamics instance for this vehicle
644+
scp::DynamicsPluginConfig cfg;
645+
cfg.name = name;
646+
scp_client_->send(cfg);
647+
}
648+
}
649+
} else {
650+
auto& entities = xml.get_child("OpenSCENARIO").get_child("Entities");
651+
for (auto& it : entities) {
652+
if (it.first != "ScenarioObject") {
653+
continue;
654+
}
655+
auto& obj = it.second;
656+
boost::optional<boost::property_tree::ptree&> properties_avail = obj.get_child("Vehicle").get_child_optional("Properties");
657+
if (!properties_avail) {
658+
continue;
659+
}
660+
auto& properties = obj.get_child("Vehicle").get_child("Properties");
661+
for (auto& property : properties) {
662+
auto prop = property.second;
663+
std::string control = prop.get("<xmlattr>.value", "default");
664+
if (control == "external") {
665+
auto name = obj.get("<xmlattr>.name", "unspecified");
666+
agents_expected_.insert(name);
667+
668+
// Ask VTD to create a vehicle dynamics instance for this vehicle
669+
scp::DynamicsPluginConfig cfg;
670+
cfg.name = name;
671+
scp_client_->send(cfg);
672+
}
673+
}
643674
}
644675
}
645676
}

0 commit comments

Comments
 (0)