diff --git a/sim/contrib/examples/Configurations/AEB/VehicleModelsCatalog.xosc b/sim/contrib/examples/Configurations/AEB/VehicleModelsCatalog.xosc index e35b29a301cf8e3295ed2a5a95651a5dc08480b0..01e51226d74a35c6c530d02fd15341203ea8b602 100644 --- a/sim/contrib/examples/Configurations/AEB/VehicleModelsCatalog.xosc +++ b/sim/contrib/examples/Configurations/AEB/VehicleModelsCatalog.xosc @@ -25,7 +25,7 @@ <Center x="1.25" y="0.0" z="0.84"/> <Dimensions width="2.04" length="3.96" height="1.68"/> </BoundingBox> - <Performance maxSpeed="41.67" maxDeceleration="9.80665"/> + <Performance maxSpeed="41.67" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5282" wheelDiameter="0.682" trackWidth="1.8" positionX="2.52" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -61,7 +61,7 @@ <Center x="1.285" y="0.0" z="0.72"/> <Dimensions width="1.96" length="4.63" height="1.44"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5012" wheelDiameter="0.634" trackWidth="1.8" positionX="2.81" positionZ="0.317"/> <RearAxle maxSteering="0.0" wheelDiameter="0.634" trackWidth="1.8" positionX="0.0" positionZ="0.317"/> @@ -97,7 +97,7 @@ <Center x="1.46" y="0.0" z="0.755"/> <Dimensions width="2.18" length="5.26" height="1.51"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5226" wheelDiameter="0.682" trackWidth="1.8" positionX="3.22" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -133,7 +133,7 @@ <Center x="1.485" y="0.0" z="0.745"/> <Dimensions width="2.16" length="5.27" height="1.49"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5279" wheelDiameter="0.682" trackWidth="1.8" positionX="3.25" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -168,7 +168,7 @@ <Center x="1.35" y="0.0" z="0.71"/> <Dimensions width="1.89" length="3.8" height="1.42"/> </BoundingBox> - <Performance maxSpeed="58.33" maxDeceleration="9.80665"/> + <Performance maxSpeed="58.33" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.4766" wheelDiameter="0.59" trackWidth="1.8" positionX="2.48" positionZ="0.295"/> <RearAxle maxSteering="0.0" wheelDiameter="0.59" trackWidth="1.8" positionX="0.0" positionZ="0.295"/> @@ -204,7 +204,7 @@ <Center x="2.815" y="0.0" z="1.92"/> <Dimensions width="2.91" length="13.23" height="3.84"/> </BoundingBox> - <Performance maxSpeed="33.33" maxDeceleration="9.80665"/> + <Performance maxSpeed="33.33" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.6972" wheelDiameter="0.808" trackWidth="1.8" positionX="6.64" positionZ="0.404"/> <RearAxle maxSteering="0.0" wheelDiameter="0.808" trackWidth="1.8" positionX="0.0" positionZ="0.404"/> @@ -240,7 +240,7 @@ <Center x="2.685" y="0.0" z="1.74"/> <Dimensions width="3.16" length="8.83" height="3.48"/> </BoundingBox> - <Performance maxSpeed="25.0" maxDeceleration="9.80665"/> + <Performance maxSpeed="25.0" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.4352" wheelDiameter="0.808" trackWidth="1.8" positionX="4.36" positionZ="0.404"/> <RearAxle maxSteering="0.0" wheelDiameter="0.808" trackWidth="1.8" positionX="0.0" positionZ="0.404"/> @@ -274,7 +274,7 @@ <Center x="0.175" y="0.0" z="0.9325"/> <Dimensions width="0.5" length="1.89" height="1.865"/> </BoundingBox> - <Performance maxSpeed="10.0" maxDeceleration="9.80665"/> + <Performance maxSpeed="10.0" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="1.5708" wheelDiameter="0.636" trackWidth="0.1" positionX="1.04" positionZ="0.318"/> <RearAxle maxSteering="0.0" wheelDiameter="0.636" trackWidth="0.1" positionX="0.0" positionZ="0.318"/> diff --git a/sim/contrib/examples/Configurations/Pedestrian_AFDM/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/Pedestrian_AFDM/ProfilesCatalog.xml deleted file mode 100644 index 321d38c1865882423011a159c7befabd502abde7..0000000000000000000000000000000000000000 --- a/sim/contrib/examples/Configurations/Pedestrian_AFDM/ProfilesCatalog.xml +++ /dev/null @@ -1,203 +0,0 @@ -<Profiles SchemaVersion="0.4.3"> - <AgentProfiles> - <AgentProfile Name="LuxuryClassCarAgent" Type="Dynamic"> - <DriverProfiles> - <DriverProfile Name="Regular" Probability="1.0"/> - </DriverProfiles> - <VehicleProfiles> - <VehicleProfile Name="BMW 7 g12 2016" Probability="0.5"/> - <VehicleProfile Name="BMW 7 f01 2010" Probability="0.5"/> - </VehicleProfiles> - </AgentProfile> - <AgentProfile Name="MiddleClassCarAgent" Type="Dynamic"> - <DriverProfiles> - <DriverProfile Name="Regular" Probability="1.0"/> - </DriverProfiles> - <VehicleProfiles> - <VehicleProfile Name="Mini Cooper f56 2015" Probability="0.4"/> - <VehicleProfile Name="BMW i3 i01 2013" Probability="0.3"/> - <VehicleProfile Name="BMW 3 f30 2015" Probability="0.3"/> - </VehicleProfiles> - </AgentProfile> - <AgentProfile Name="TruckAgent" Type="Dynamic"> - <DriverProfiles> - <DriverProfile Name="RegularTruck" Probability="1.0"/> - </DriverProfiles> - <VehicleProfiles> - <VehicleProfile Name="Truck Hyundai Xcient p540 4axle 2013" Probability="1.0"/> - </VehicleProfiles> - </AgentProfile> - <AgentProfile Name="BusAgent" Type="Dynamic"> - <DriverProfiles> - <DriverProfile Name="RegularBus" Probability="1.0"/> - </DriverProfiles> - <VehicleProfiles> - <VehicleProfile Name="Bus MAN Lions Coach c 2007" Probability="1.0"/> - </VehicleProfiles> - </AgentProfile> - <AgentProfile Name="Pedestrian" Type="Dynamic"> - <DriverProfiles> - <DriverProfile Name="Pedestrian" Probability="1.0"/> - </DriverProfiles> - <VehicleProfiles> - <VehicleProfile Name="Pedestrian" Probability="1.0"/> - </VehicleProfiles> - </AgentProfile> - </AgentProfiles> - <VehicleProfiles> - <VehicleProfile Name="BMW 7 g12 2016"> - <Model Name="car_bmw_7_1"/> - <Components/> - <Sensors/> - </VehicleProfile> - <VehicleProfile Name="BMW 7 f01 2010"> - <Model Name="car_bmw_7_2"/> - <Components/> - <Sensors/> - </VehicleProfile> - <VehicleProfile Name="Mini Cooper f56 2015"> - <Model Name="car_mini_cooper"/> - <Components/> - <Sensors/> - </VehicleProfile> - <VehicleProfile Name="BMW i3 i01 2013"> - <Model Name="car_bmw_i3"/> - <Components/> - <Sensors/> - </VehicleProfile> - <VehicleProfile Name="BMW 3 f30 2015"> - <Model Name="car_bmw_3"/> - <Components/> - <Sensors/> - </VehicleProfile> - <VehicleProfile Name="Truck Hyundai Xcient p540 4axle 2013"> - <Model Name="truck"/> - <Components/> - <Sensors/> - </VehicleProfile> - <VehicleProfile Name="Bus MAN Lions Coach c 2007"> - <Model Name="bus"/> - <Components/> - <Sensors/> - </VehicleProfile> - <VehicleProfile Name="Pedestrian"> - <Model Name="pedestrian_adult"/> - <Components/> - <Sensors/> - </VehicleProfile> - </VehicleProfiles> - <ProfileGroup Type="Driver"> - <Profile Name="Pedestrian"> - <String Key="Type" Value="AlgorithmAgentFollowingDriverModel"/> - <String Key="AlgorithmLateralModule" Value="Algorithm_LateralAfdm"/> - <String Key="AlgorithmLongitudinalModule" Value="Algorithm_LongitudinalAfdm"/> - <Double Key="VelocityWish" Value="1.0"/> - </Profile> - <Profile Name="Regular"> - <String Key="Type" Value="AlgorithmAgentFollowingDriverModel"/> - <String Key="AlgorithmLateralModule" Value="Algorithm_LateralAfdm"/> - <String Key="AlgorithmLongitudinalModule" Value="Algorithm_LongitudinalAfdm"/> - <Double Key="VelocityWish" Value="36.11"/> - <Double Key="Delta" Value="4.0"/> - <Double Key="TGapWish" Value="1.5"/> - <Double Key="MinDistance" Value="2.0"/> - <Double Key="MaxAcceleration" Value="1.4"/> - <Double Key="MaxDeceleration" Value="2.0"/> - </Profile> - <Profile Name="RegularBus"> - <String Key="Type" Value="AlgorithmAgentFollowingDriverModel"/> - <String Key="AlgorithmLateralModule" Value="Algorithm_LateralAfdm"/> - <String Key="AlgorithmLongitudinalModule" Value="Algorithm_LongitudinalAfdm"/> - <Double Key="VelocityWish" Value="24.24"/> - <Double Key="Delta" Value="4.0"/> - <Double Key="TGapWish" Value="1.5"/> - <Double Key="MinDistance" Value="2.0"/> - <Double Key="MaxAcceleration" Value="1.4"/> - <Double Key="MaxDeceleration" Value="2.0"/> - </Profile> - <Profile Name="RegularTruck"> - <String Key="Type" Value="AlgorithmAgentFollowingDriverModel"/> - <String Key="AlgorithmLateralModule" Value="Algorithm_LateralAfdm"/> - <String Key="AlgorithmLongitudinalModule" Value="Algorithm_LongitudinalAfdm"/> - <Double Key="VelocityWish" Value="24.24"/> - <Double Key="Delta" Value="4.0"/> - <Double Key="TGapWish" Value="1.5"/> - <Double Key="MinDistance" Value="2.0"/> - <Double Key="MaxAcceleration" Value="1.4"/> - <Double Key="MaxDeceleration" Value="2.0"/> - </Profile> - </ProfileGroup> - <ProfileGroup Type="TrafficGroup"> - <Profile Name="LightVehicles"> - <List Name="AgentProfiles"> - <ListItem> - <String Key="Name" Value="LuxuryClassCarAgent"/> - <Double Key="Weight" Value="0.4"/> - </ListItem> - <ListItem> - <String Key="Name" Value="MiddleClassCarAgent"/> - <Double Key="Weight" Value="0.6"/> - </ListItem> - </List> - <NormalDistribution Key="Velocity" Max="43.685" Mean="31.475" Min="19.265" SD="6.105"/> - <LogNormalDistribution Key="TGap" Max="80" Min="0.5" Mu="1.5" Sigma="1.7"/> - <DoubleVector Key="Homogeneity" Value="0.820, 1.0"/> - </Profile> - <Profile Name="HeavyVehicles"> - <List Name="AgentProfiles"> - <ListItem> - <String Key="Name" Value="TruckAgent"/> - <Double Key="Weight" Value="1.0"/> - </ListItem> - <ListItem> - <String Key="Name" Value="BusAgent"/> - <Double Key="Weight" Value="1.0"/> - </ListItem> - </List> - <NormalDistribution Key="Velocity" Max="25" Mean="22.22" Min="19.44" SD="1.39"/> - <LogNormalDistribution Key="TGap" Max="100" Min="0.5" Mu="1.94" Sigma="2.35"/> - <Bool Key="RightLaneOnly" Value="true"/> - </Profile> - </ProfileGroup> - <ProfileGroup Type="Spawner"> - <Profile Name="DefaultPreRunCommon"> - <List Name="SpawnPoints"> - <ListItem> - <StringVector Key="Roads" Value="1"/> - <IntVector Key="Lanes" Value="-1,-2,-3,-4,-5"/> - <Double Key="SStart" Value="0.0"/> - <Double Key="SEnd" Value="1000.0"/> - </ListItem> - </List> - <List Name="TrafficGroups"> - <ListItem> - <Double Key="Weight" Value="4"/> - <Reference Type="TrafficGroup" Name="LightVehicles"/> - </ListItem> - <ListItem> - <Double Key="Weight" Value="1"/> - <Reference Type="TrafficGroup" Name="HeavyVehicles"/> - </ListItem> - </List> - </Profile> - <Profile Name="DefaultRuntimeCommon"> - <List Name="SpawnPoints"> - <ListItem> - <StringVector Key="Roads" Value="1"/> - <IntVector Key="Lanes" Value="-1,-2,-3,-4,-5"/> - <Double Key="SCoordinate" Value="0.0"/> - </ListItem> - </List> - <List Name="TrafficGroups"> - <ListItem> - <Double Key="Weight" Value="4"/> - <Reference Type="TrafficGroup" Name="LightVehicles"/> - </ListItem> - <ListItem> - <Double Key="Weight" Value="1"/> - <Reference Type="TrafficGroup" Name="HeavyVehicles"/> - </ListItem> - </List> - </Profile> - </ProfileGroup> -</Profiles> diff --git a/sim/contrib/examples/Configurations/Pedestrian_AFDM/Scenario.xosc b/sim/contrib/examples/Configurations/Pedestrian_AFDM/Scenario.xosc deleted file mode 100644 index 8370fa1c27255b6ac1cd6195f12bde70b8758032..0000000000000000000000000000000000000000 --- a/sim/contrib/examples/Configurations/Pedestrian_AFDM/Scenario.xosc +++ /dev/null @@ -1,104 +0,0 @@ -<?xml version="1.0"?> -<OpenSCENARIO> - <FileHeader revMajor="1" revMinor="0" date="2020-06-26T00:17:00" description="openPASS default scenario" author="in-tech GmbH"/> - <ParameterDeclarations> - <ParameterDeclaration name="OP_OSC_SchemaVersion" parameterType="string" value="0.4.0"/> - </ParameterDeclarations> - <CatalogLocations> - <VehicleCatalog> - <Directory path="VehicleModelsCatalog.xosc"/> - </VehicleCatalog> - <PedestrianCatalog> - <Directory path="PedestrianModelsCatalog.xosc"/> - </PedestrianCatalog> - <ControllerCatalog> - <Directory path=""/> - </ControllerCatalog> - <ManeuverCatalog> - <Directory path=""/> - </ManeuverCatalog> - <MiscObjectCatalog> - <Directory path=""/> - </MiscObjectCatalog> - <EnvironmentCatalog> - <Directory path=""/> - </EnvironmentCatalog> - <TrajectoryCatalog> - <Directory path=""/> - </TrajectoryCatalog> - <RouteCatalog> - <Directory path=""/> - </RouteCatalog> - </CatalogLocations> - <RoadNetwork> - <LogicFile filepath="SceneryConfiguration.xodr"/> - <SceneGraphFile filepath=""/> - </RoadNetwork> - <Entities> - <ScenarioObject name="Ego"> - <CatalogReference catalogName="ProfilesCatalog.xml" entryName="MiddleClassCarAgent"/> - </ScenarioObject> - <ScenarioObject name="Pedestrian"> - <CatalogReference catalogName="ProfilesCatalog.xml" entryName="Pedestrian"/> - </ScenarioObject> - <EntitySelection name="ScenarioAgents"> - <Members> - <EntityRef entityRef="Pedestrian"/> - </Members> - </EntitySelection> - </Entities> - <Storyboard> - <Init> - <Actions> - <Private entityRef="Ego"> - <PrivateAction> - <TeleportAction> - <Position> - <LanePosition roadId="1" laneId="-1" offset="0.0" s="0.0"/> - </Position> - </TeleportAction> - </PrivateAction> - <PrivateAction> - <LongitudinalAction> - <SpeedAction> - <SpeedActionDynamics dynamicsShape="linear" value="0.0" dynamicsDimension="rate"/> - <SpeedActionTarget> - <AbsoluteTargetSpeed value="43.5"/> - </SpeedActionTarget> - </SpeedAction> - </LongitudinalAction> - </PrivateAction> - </Private> - <Private entityRef="Pedestrian"> - <PrivateAction> - <TeleportAction> - <Position> - <LanePosition roadId="1" laneId="-2" offset="0.0" s="100.0"/> - </Position> - </TeleportAction> - </PrivateAction> - <PrivateAction> - <LongitudinalAction> - <SpeedAction> - <SpeedActionDynamics dynamicsShape="linear" value="0.0" dynamicsDimension="rate"/> - <SpeedActionTarget> - <AbsoluteTargetSpeed value="1.0"/> - </SpeedActionTarget> - </SpeedAction> - </LongitudinalAction> - </PrivateAction> - </Private> - </Actions> - </Init> - <Story/> - <StopTrigger> - <ConditionGroup> - <Condition name="EndTime" delay="0" conditionEdge="rising"> - <ByValueCondition> - <SimulationTimeCondition value="30.0" rule="greaterThan"/> - </ByValueCondition> - </Condition> - </ConditionGroup> - </StopTrigger> - </Storyboard> -</OpenSCENARIO> diff --git a/sim/contrib/examples/Configurations/Pedestrian_AFDM/SceneryConfiguration.xodr b/sim/contrib/examples/Configurations/Pedestrian_AFDM/SceneryConfiguration.xodr deleted file mode 100644 index 0adf3590c2873077b12d245fb4864cfff9a64d9a..0000000000000000000000000000000000000000 --- a/sim/contrib/examples/Configurations/Pedestrian_AFDM/SceneryConfiguration.xodr +++ /dev/null @@ -1,64 +0,0 @@ -<OpenDRIVE> - <header revMajor="1" revMinor="1" name="Testfile" version="1" date="Thu Feb 8 14:24:06 2007" north="2.0000000000000000e+003" south="-2.0000000000000000e+003" east="2.0000000000000000e+003" west="-2.0000000000000000e+003"/> - <road name="" length="5139.7188686309819" id="1" junction="-1"> - <link/> - <planView> - <geometry s="0.0000000000000000e+000" x="0" y="7.5" hdg="0" length="4000"> - <line/> - </geometry> - <geometry s="4000" x="4000" y="7.5" hdg="0" length="285"> - <spiral curvStart="0.0000000000000000e+000" curvEnd="-0.0028500000000000066"/> - </geometry> - <geometry s="4285" x="4280.3350391612494" y="-30.629710830536482" hdg="-0.40612500000000096" length="183.7188686309816"> - <arc curvature="-0.0028500000000000066"/> - </geometry> - <geometry s="4468.7188686309819" x="4422.9323279193268" y="-143.12204699500415" hdg="-0.92972377559829977" length="571"> - <spiral curvStart="-0.0028500000000000066" curvEnd="0.0000000000000000e+000"/> - </geometry> - <geometry s="5039.7188686309819" x="4476.6651848689908" y="-694.88624436808436" hdg="-1.7453292519943295" length="100"> - <line/> - </geometry> - </planView> - <elevationProfile/> - <lateralProfile/> - <lanes> - <laneSection s="0.0000000000000000e+000"> - <left> - <lane id="1" type="sidewalk" level="true"> - <link> - <successor id="-2"/> - </link> - <width sOffset="0" a="1.5" b="0" c="0" d="0"/> - <roadMark weight="standard" sOffset="0" type="solid" color="standard" width="0.12" laneChange="none"/> - </lane> - </left> - <center> - <lane id="0" type="border" level="true"> - <link> - <successor id="0"/> - </link> - <roadMark weight="standard" sOffset="0" type="solid" color="standard" width="0.12" laneChange="none"/> - </lane> - </center> - <right> - <lane id="-1" type="driving" level="true"> - <link> - <successor id="-1"/> - </link> - <width sOffset="0" a="3.75" b="0" c="0" d="0"/> - <roadMark weight="standard" sOffset="0" type="solid" color="standard" width="0.12" laneChange="none"/> - </lane> - <lane id="-2" type="sidewalk" level="true"> - <link> - <successor id="-2"/> - </link> - <width sOffset="0" a="1.5" b="0" c="0" d="0"/> - <roadMark weight="standard" sOffset="0" type="solid" color="standard" width="0.12" laneChange="none"/> - </lane> - </right> - </laneSection> - </lanes> - <objects/> - <signals/> - </road> -</OpenDRIVE> diff --git a/sim/contrib/examples/Configurations/Pedestrian_Trajectory/ProfilesCatalog.xml b/sim/contrib/examples/Configurations/Pedestrian_Trajectory/ProfilesCatalog.xml index f31c1f6d0e8158974473f1759991e50be11db348..43ce2aa4f0bd57afa76521d2c69bc68b2cbd03ee 100644 --- a/sim/contrib/examples/Configurations/Pedestrian_Trajectory/ProfilesCatalog.xml +++ b/sim/contrib/examples/Configurations/Pedestrian_Trajectory/ProfilesCatalog.xml @@ -35,13 +35,12 @@ <VehicleProfile Name="Bus MAN Lions Coach c 2007" Probability="1.0"/> </VehicleProfiles> </AgentProfile> - <AgentProfile Name="Pedestrian" Type="Dynamic"> - <DriverProfiles> - <DriverProfile Name="Pedestrian" Probability="1.0"/> - </DriverProfiles> - <VehicleProfiles> - <VehicleProfile Name="Pedestrian" Probability="1.0"/> - </VehicleProfiles> + <AgentProfile Name="Pedestrian" Type="Static"> + <System> + <File>systemConfigPedestrian.xml</File> + <Id>0</Id> + </System> + <VehicleModel>pedestrian_adult</VehicleModel> </AgentProfile> </AgentProfiles> <VehicleProfiles> @@ -80,25 +79,8 @@ <Components/> <Sensors/> </VehicleProfile> - <VehicleProfile Name="Pedestrian"> - <Model Name="pedestrian_adult"/> - <Components> - <Component Type="Dynamics_TrajectoryFollower"> - <Profiles> - <Profile Name="BasicTrajectoryFollower" Probability="1.0"/> - </Profiles> - </Component> - </Components> - <Sensors/> - </VehicleProfile> </VehicleProfiles> <ProfileGroup Type="Driver"> - <Profile Name="Pedestrian"> - <String Key="Type" Value="AlgorithmAgentFollowingDriverModel"/> - <String Key="AlgorithmLateralModule" Value="Algorithm_LateralAfdm"/> - <String Key="AlgorithmLongitudinalModule" Value="Algorithm_LongitudinalAfdm"/> - <Double Key="VelocityWish" Value="1.0"/> - </Profile> <Profile Name="Regular"> <String Key="Type" Value="AlgorithmAgentFollowingDriverModel"/> <String Key="AlgorithmLateralModule" Value="Algorithm_LateralAfdm"/> diff --git a/sim/contrib/examples/Configurations/Pedestrian_Trajectory/systemConfigPedestrian.xml b/sim/contrib/examples/Configurations/Pedestrian_Trajectory/systemConfigPedestrian.xml new file mode 100644 index 0000000000000000000000000000000000000000..bb0fe3828b3ec704e5aa00d638fc07a1c6154d60 --- /dev/null +++ b/sim/contrib/examples/Configurations/Pedestrian_Trajectory/systemConfigPedestrian.xml @@ -0,0 +1,146 @@ +<systems> + <system> + <id>0</id> + <priority>0</priority> + <components> + <component> + <id>OpenScenarioActions</id> + <schedule> + <priority>400</priority> + <offset>0</offset> + <cycle>100</cycle> + <response>0</response> + </schedule> + <library>OpenScenarioActions</library> + <parameters/> + </component> + <component> + <id>Dynamics_TrajectoryFollower</id> + <schedule> + <priority>50</priority> + <offset>0</offset> + <cycle>100</cycle> + <response>0</response> + </schedule> + <library>Dynamics_TrajectoryFollower</library> + <parameters> + <parameter> + <id>EnforceTrajectory</id> + <type>bool</type> + <unit/> + <value>true</value> + </parameter> + <parameter> + <id>AutomaticDeactivation</id> + <type>bool</type> + <unit/> + <value>true</value> + </parameter> + </parameters> + </component> + <component> + <id>Dynamics_Collision</id> + <schedule> + <priority>50</priority> + <offset>0</offset> + <cycle>100</cycle> + <response>0</response> + </schedule> + <library>Dynamics_Collision</library> + <parameters/> + </component> + <component> + <id>PrioritizerDynamics</id> + <schedule> + <priority>25</priority> + <offset>0</offset> + <cycle>100</cycle> + <response>0</response> + </schedule> + <library>SignalPrioritizer</library> + <parameters> + <parameter> + <id>1</id> + <type>int</type> + <unit/> + <value>2</value> + </parameter> + <parameter> + <id>2</id> + <type>int</type> + <unit/> + <value>1</value> + </parameter> + </parameters> + </component> + <component> + <id>AgentUpdater</id> + <schedule> + <priority>1</priority> + <offset>0</offset> + <cycle>100</cycle> + <response>0</response> + </schedule> + <library>AgentUpdater</library> + <parameters/> + </component> + <component> + <id>Sensor_RecordState</id> + <schedule> + <priority>2</priority> + <offset>0</offset> + <cycle>100</cycle> + <response>0</response> + </schedule> + <library>Sensor_RecordState</library> + <parameters/> + </component> + </components> + <connections> + <connection> + <id>201</id> + <source> + <component>Dynamics_TrajectoryFollower</component> + <output>0</output> + </source> + <target> + <component>PrioritizerDynamics</component> + <input>2</input> + </target> + </connection> + <connection> + <id>401</id> + <source> + <component>Dynamics_Collision</component> + <output>0</output> + </source> + <target> + <component>PrioritizerDynamics</component> + <input>1</input> + </target> + </connection> + <connection> + <id>501</id> + <source> + <component>PrioritizerDynamics</component> + <output>0</output> + </source> + <target> + <component>AgentUpdater</component> + <input>0</input> + </target> + </connection> + <connection> + <id>8471</id> + <source> + <component>OpenScenarioActions</component> + <output>0</output> + </source> + <target> + <component>Dynamics_TrajectoryFollower</component> + <input>2</input> + </target> + </connection> + </connections> + </system> +</systems> diff --git a/sim/contrib/examples/Configurations/StaticAgentCollision/VehicleModelsCatalog.xosc b/sim/contrib/examples/Configurations/StaticAgentCollision/VehicleModelsCatalog.xosc index 0ef23c58572488b9941274655cb890ea2b2cc82a..01e51226d74a35c6c530d02fd15341203ea8b602 100644 --- a/sim/contrib/examples/Configurations/StaticAgentCollision/VehicleModelsCatalog.xosc +++ b/sim/contrib/examples/Configurations/StaticAgentCollision/VehicleModelsCatalog.xosc @@ -7,7 +7,7 @@ <Property name="AirDragCoefficient" value="0.3"/> <Property name="AxleRatio" value="1.0"/> <Property name="DecelerationFromPowertrainDrag" value="0.5"/> - <Property name="FrictionCoefficient" value="0.0"/> + <Property name="FrictionCoefficient" value="1.0"/> <Property name="FrontSurface" value="2.38"/> <Property name="GearRatio1" value="9.665"/> <Property name="Mass" value="1320.0"/> @@ -25,7 +25,7 @@ <Center x="1.25" y="0.0" z="0.84"/> <Dimensions width="2.04" length="3.96" height="1.68"/> </BoundingBox> - <Performance maxSpeed="41.67" maxDeceleration="9.80665"/> + <Performance maxSpeed="41.67" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5282" wheelDiameter="0.682" trackWidth="1.8" positionX="2.52" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -36,7 +36,7 @@ <Property name="AirDragCoefficient" value="0.3"/> <Property name="AxleRatio" value="2.813"/> <Property name="DecelerationFromPowertrainDrag" value="0.5"/> - <Property name="FrictionCoefficient" value="0.0"/> + <Property name="FrictionCoefficient" value="1.0"/> <Property name="FrontSurface" value="2.2"/> <Property name="GearRatio1" value="5.0"/> <Property name="GearRatio2" value="3.2"/> @@ -61,7 +61,7 @@ <Center x="1.285" y="0.0" z="0.72"/> <Dimensions width="1.96" length="4.63" height="1.44"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5012" wheelDiameter="0.634" trackWidth="1.8" positionX="2.81" positionZ="0.317"/> <RearAxle maxSteering="0.0" wheelDiameter="0.634" trackWidth="1.8" positionX="0.0" positionZ="0.317"/> @@ -72,7 +72,7 @@ <Property name="AirDragCoefficient" value="0.3"/> <Property name="AxleRatio" value="3.077"/> <Property name="DecelerationFromPowertrainDrag" value="0.5"/> - <Property name="FrictionCoefficient" value="0.0"/> + <Property name="FrictionCoefficient" value="1.0"/> <Property name="FrontSurface" value="2.42"/> <Property name="GearRatio1" value="5.0"/> <Property name="GearRatio2" value="3.2"/> @@ -97,7 +97,7 @@ <Center x="1.46" y="0.0" z="0.755"/> <Dimensions width="2.18" length="5.26" height="1.51"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5226" wheelDiameter="0.682" trackWidth="1.8" positionX="3.22" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -108,7 +108,7 @@ <Property name="AirDragCoefficient" value="0.3"/> <Property name="AxleRatio" value="3.077"/> <Property name="DecelerationFromPowertrainDrag" value="0.5"/> - <Property name="FrictionCoefficient" value="0.0"/> + <Property name="FrictionCoefficient" value="1.0"/> <Property name="FrontSurface" value="2.42"/> <Property name="GearRatio1" value="4.714"/> <Property name="GearRatio2" value="3.143"/> @@ -133,7 +133,7 @@ <Center x="1.485" y="0.0" z="0.745"/> <Dimensions width="2.16" length="5.27" height="1.49"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5279" wheelDiameter="0.682" trackWidth="1.8" positionX="3.25" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -144,7 +144,7 @@ <Property name="AirDragCoefficient" value="0.3"/> <Property name="AxleRatio" value="3.789"/> <Property name="DecelerationFromPowertrainDrag" value="0.5"/> - <Property name="FrictionCoefficient" value="0.0"/> + <Property name="FrictionCoefficient" value="1.0"/> <Property name="FrontSurface" value="2.07"/> <Property name="GearRatio1" value="4.154"/> <Property name="GearRatio2" value="2.45"/> @@ -168,7 +168,7 @@ <Center x="1.35" y="0.0" z="0.71"/> <Dimensions width="1.89" length="3.8" height="1.42"/> </BoundingBox> - <Performance maxSpeed="58.33" maxDeceleration="9.80665"/> + <Performance maxSpeed="58.33" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.4766" wheelDiameter="0.59" trackWidth="1.8" positionX="2.48" positionZ="0.295"/> <RearAxle maxSteering="0.0" wheelDiameter="0.59" trackWidth="1.8" positionX="0.0" positionZ="0.295"/> @@ -179,7 +179,7 @@ <Property name="AirDragCoefficient" value="0.8"/> <Property name="AxleRatio" value="4.0"/> <Property name="DecelerationFromPowertrainDrag" value="1.0"/> - <Property name="FrictionCoefficient" value="0.0"/> + <Property name="FrictionCoefficient" value="1.0"/> <Property name="FrontSurface" value="9.0"/> <Property name="GearRatio1" value="6.316"/> <Property name="GearRatio2" value="4.554"/> @@ -204,7 +204,7 @@ <Center x="2.815" y="0.0" z="1.92"/> <Dimensions width="2.91" length="13.23" height="3.84"/> </BoundingBox> - <Performance maxSpeed="33.33" maxDeceleration="9.80665"/> + <Performance maxSpeed="33.33" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.6972" wheelDiameter="0.808" trackWidth="1.8" positionX="6.64" positionZ="0.404"/> <RearAxle maxSteering="0.0" wheelDiameter="0.808" trackWidth="1.8" positionX="0.0" positionZ="0.404"/> @@ -215,7 +215,7 @@ <Property name="AirDragCoefficient" value="0.8"/> <Property name="AxleRatio" value="4.0"/> <Property name="DecelerationFromPowertrainDrag" value="1.0"/> - <Property name="FrictionCoefficient" value="0.0"/> + <Property name="FrictionCoefficient" value="1.0"/> <Property name="FrontSurface" value="9.0"/> <Property name="GearRatio1" value="6.316"/> <Property name="GearRatio2" value="4.554"/> @@ -240,7 +240,7 @@ <Center x="2.685" y="0.0" z="1.74"/> <Dimensions width="3.16" length="8.83" height="3.48"/> </BoundingBox> - <Performance maxSpeed="25.0" maxDeceleration="9.80665"/> + <Performance maxSpeed="25.0" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.4352" wheelDiameter="0.808" trackWidth="1.8" positionX="4.36" positionZ="0.404"/> <RearAxle maxSteering="0.0" wheelDiameter="0.808" trackWidth="1.8" positionX="0.0" positionZ="0.404"/> @@ -251,7 +251,7 @@ <Property name="AirDragCoefficient" value="0.3"/> <Property name="AxleRatio" value="3.0"/> <Property name="DecelerationFromPowertrainDrag" value="0.5"/> - <Property name="FrictionCoefficient" value="0.0"/> + <Property name="FrictionCoefficient" value="1.0"/> <Property name="FrontSurface" value="1.9"/> <Property name="GearRatio1" value="4.350"/> <Property name="GearRatio2" value="2.496"/> @@ -274,7 +274,7 @@ <Center x="0.175" y="0.0" z="0.9325"/> <Dimensions width="0.5" length="1.89" height="1.865"/> </BoundingBox> - <Performance maxSpeed="10.0" maxDeceleration="9.80665"/> + <Performance maxSpeed="10.0" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="1.5708" wheelDiameter="0.636" trackWidth="0.1" positionX="1.04" positionZ="0.318"/> <RearAxle maxSteering="0.0" wheelDiameter="0.636" trackWidth="0.1" positionX="0.0" positionZ="0.318"/> diff --git a/sim/contrib/examples/Configurations/StaticAgentProfiles/VehicleModelsCatalog.xosc b/sim/contrib/examples/Configurations/StaticAgentProfiles/VehicleModelsCatalog.xosc index e35b29a301cf8e3295ed2a5a95651a5dc08480b0..01e51226d74a35c6c530d02fd15341203ea8b602 100644 --- a/sim/contrib/examples/Configurations/StaticAgentProfiles/VehicleModelsCatalog.xosc +++ b/sim/contrib/examples/Configurations/StaticAgentProfiles/VehicleModelsCatalog.xosc @@ -25,7 +25,7 @@ <Center x="1.25" y="0.0" z="0.84"/> <Dimensions width="2.04" length="3.96" height="1.68"/> </BoundingBox> - <Performance maxSpeed="41.67" maxDeceleration="9.80665"/> + <Performance maxSpeed="41.67" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5282" wheelDiameter="0.682" trackWidth="1.8" positionX="2.52" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -61,7 +61,7 @@ <Center x="1.285" y="0.0" z="0.72"/> <Dimensions width="1.96" length="4.63" height="1.44"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5012" wheelDiameter="0.634" trackWidth="1.8" positionX="2.81" positionZ="0.317"/> <RearAxle maxSteering="0.0" wheelDiameter="0.634" trackWidth="1.8" positionX="0.0" positionZ="0.317"/> @@ -97,7 +97,7 @@ <Center x="1.46" y="0.0" z="0.755"/> <Dimensions width="2.18" length="5.26" height="1.51"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5226" wheelDiameter="0.682" trackWidth="1.8" positionX="3.22" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -133,7 +133,7 @@ <Center x="1.485" y="0.0" z="0.745"/> <Dimensions width="2.16" length="5.27" height="1.49"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5279" wheelDiameter="0.682" trackWidth="1.8" positionX="3.25" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -168,7 +168,7 @@ <Center x="1.35" y="0.0" z="0.71"/> <Dimensions width="1.89" length="3.8" height="1.42"/> </BoundingBox> - <Performance maxSpeed="58.33" maxDeceleration="9.80665"/> + <Performance maxSpeed="58.33" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.4766" wheelDiameter="0.59" trackWidth="1.8" positionX="2.48" positionZ="0.295"/> <RearAxle maxSteering="0.0" wheelDiameter="0.59" trackWidth="1.8" positionX="0.0" positionZ="0.295"/> @@ -204,7 +204,7 @@ <Center x="2.815" y="0.0" z="1.92"/> <Dimensions width="2.91" length="13.23" height="3.84"/> </BoundingBox> - <Performance maxSpeed="33.33" maxDeceleration="9.80665"/> + <Performance maxSpeed="33.33" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.6972" wheelDiameter="0.808" trackWidth="1.8" positionX="6.64" positionZ="0.404"/> <RearAxle maxSteering="0.0" wheelDiameter="0.808" trackWidth="1.8" positionX="0.0" positionZ="0.404"/> @@ -240,7 +240,7 @@ <Center x="2.685" y="0.0" z="1.74"/> <Dimensions width="3.16" length="8.83" height="3.48"/> </BoundingBox> - <Performance maxSpeed="25.0" maxDeceleration="9.80665"/> + <Performance maxSpeed="25.0" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.4352" wheelDiameter="0.808" trackWidth="1.8" positionX="4.36" positionZ="0.404"/> <RearAxle maxSteering="0.0" wheelDiameter="0.808" trackWidth="1.8" positionX="0.0" positionZ="0.404"/> @@ -274,7 +274,7 @@ <Center x="0.175" y="0.0" z="0.9325"/> <Dimensions width="0.5" length="1.89" height="1.865"/> </BoundingBox> - <Performance maxSpeed="10.0" maxDeceleration="9.80665"/> + <Performance maxSpeed="10.0" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="1.5708" wheelDiameter="0.636" trackWidth="0.1" positionX="1.04" positionZ="0.318"/> <RearAxle maxSteering="0.0" wheelDiameter="0.636" trackWidth="0.1" positionX="0.0" positionZ="0.318"/> diff --git a/sim/contrib/examples/DefaultConfigurations/PedestrianModelsCatalog.xosc b/sim/contrib/examples/DefaultConfigurations/PedestrianModelsCatalog.xosc index 84c1ac67df3189c1fcb287113dcd8d2377ba784b..bbda0b044d1890917d13fe64da9e7e3c14ff176c 100644 --- a/sim/contrib/examples/DefaultConfigurations/PedestrianModelsCatalog.xosc +++ b/sim/contrib/examples/DefaultConfigurations/PedestrianModelsCatalog.xosc @@ -4,6 +4,9 @@ <Catalog name="PedestrianCatalog"> <Pedestrian model="pedestrian_child" mass="30.0" name="pedestrian_child" pedestrianCategory="pedestrian"> <ParameterDeclarations/> + <Properties> + <Property name="Mass" value="40.0"/> + </Properties> <BoundingBox> <Center x="0.0645" y="0.0" z="0.577"/> <Dimensions width="0.298" length="0.711" height="1.154"/> @@ -12,6 +15,9 @@ </Pedestrian> <Pedestrian model="pedestrian_adult" mass="80.0" name="pedestrian_adult" pedestrianCategory="pedestrian"> <ParameterDeclarations/> + <Properties> + <Property name="Mass" value="70.0"/> + </Properties> <BoundingBox> <Center x="0.1" y="0.0" z="0.9"/> <Dimensions width="0.5" length="0.6" height="1.8"/> diff --git a/sim/contrib/examples/DefaultConfigurations/VehicleModelsCatalog.xosc b/sim/contrib/examples/DefaultConfigurations/VehicleModelsCatalog.xosc index e35b29a301cf8e3295ed2a5a95651a5dc08480b0..01e51226d74a35c6c530d02fd15341203ea8b602 100644 --- a/sim/contrib/examples/DefaultConfigurations/VehicleModelsCatalog.xosc +++ b/sim/contrib/examples/DefaultConfigurations/VehicleModelsCatalog.xosc @@ -25,7 +25,7 @@ <Center x="1.25" y="0.0" z="0.84"/> <Dimensions width="2.04" length="3.96" height="1.68"/> </BoundingBox> - <Performance maxSpeed="41.67" maxDeceleration="9.80665"/> + <Performance maxSpeed="41.67" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5282" wheelDiameter="0.682" trackWidth="1.8" positionX="2.52" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -61,7 +61,7 @@ <Center x="1.285" y="0.0" z="0.72"/> <Dimensions width="1.96" length="4.63" height="1.44"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5012" wheelDiameter="0.634" trackWidth="1.8" positionX="2.81" positionZ="0.317"/> <RearAxle maxSteering="0.0" wheelDiameter="0.634" trackWidth="1.8" positionX="0.0" positionZ="0.317"/> @@ -97,7 +97,7 @@ <Center x="1.46" y="0.0" z="0.755"/> <Dimensions width="2.18" length="5.26" height="1.51"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5226" wheelDiameter="0.682" trackWidth="1.8" positionX="3.22" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -133,7 +133,7 @@ <Center x="1.485" y="0.0" z="0.745"/> <Dimensions width="2.16" length="5.27" height="1.49"/> </BoundingBox> - <Performance maxSpeed="69.44" maxDeceleration="9.80665"/> + <Performance maxSpeed="69.44" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.5279" wheelDiameter="0.682" trackWidth="1.8" positionX="3.25" positionZ="0.341"/> <RearAxle maxSteering="0.0" wheelDiameter="0.682" trackWidth="1.8" positionX="0.0" positionZ="0.341"/> @@ -168,7 +168,7 @@ <Center x="1.35" y="0.0" z="0.71"/> <Dimensions width="1.89" length="3.8" height="1.42"/> </BoundingBox> - <Performance maxSpeed="58.33" maxDeceleration="9.80665"/> + <Performance maxSpeed="58.33" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.4766" wheelDiameter="0.59" trackWidth="1.8" positionX="2.48" positionZ="0.295"/> <RearAxle maxSteering="0.0" wheelDiameter="0.59" trackWidth="1.8" positionX="0.0" positionZ="0.295"/> @@ -204,7 +204,7 @@ <Center x="2.815" y="0.0" z="1.92"/> <Dimensions width="2.91" length="13.23" height="3.84"/> </BoundingBox> - <Performance maxSpeed="33.33" maxDeceleration="9.80665"/> + <Performance maxSpeed="33.33" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.6972" wheelDiameter="0.808" trackWidth="1.8" positionX="6.64" positionZ="0.404"/> <RearAxle maxSteering="0.0" wheelDiameter="0.808" trackWidth="1.8" positionX="0.0" positionZ="0.404"/> @@ -240,7 +240,7 @@ <Center x="2.685" y="0.0" z="1.74"/> <Dimensions width="3.16" length="8.83" height="3.48"/> </BoundingBox> - <Performance maxSpeed="25.0" maxDeceleration="9.80665"/> + <Performance maxSpeed="25.0" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="0.4352" wheelDiameter="0.808" trackWidth="1.8" positionX="4.36" positionZ="0.404"/> <RearAxle maxSteering="0.0" wheelDiameter="0.808" trackWidth="1.8" positionX="0.0" positionZ="0.404"/> @@ -274,7 +274,7 @@ <Center x="0.175" y="0.0" z="0.9325"/> <Dimensions width="0.5" length="1.89" height="1.865"/> </BoundingBox> - <Performance maxSpeed="10.0" maxDeceleration="9.80665"/> + <Performance maxSpeed="10.0" maxAcceleration="9.80665" maxDeceleration="9.80665"/> <Axles> <FrontAxle maxSteering="1.5708" wheelDiameter="0.636" trackWidth="0.1" positionX="1.04" positionZ="0.318"/> <RearAxle maxSteering="0.0" wheelDiameter="0.636" trackWidth="0.1" positionX="0.0" positionZ="0.318"/> diff --git a/sim/include/agentInterface.h b/sim/include/agentInterface.h index 51b5f1cebfce1dc340f2dccef796b80df2176c84..52922e76a2c83d431e2de7e8221a7c045d358af2 100644 --- a/sim/include/agentInterface.h +++ b/sim/include/agentInterface.h @@ -227,6 +227,13 @@ public: //----------------------------------------------------------------------------- virtual void SetYaw(double value) = 0; + //----------------------------------------------------------------------------- + //! Sets roll angle of agent + //! + //! @param[in] yawAngle agent orientation + //----------------------------------------------------------------------------- + virtual void SetRoll(double value) = 0; + //----------------------------------------------------------------------------- //! Sets the total traveled distance of agent //! diff --git a/sim/include/vehicleModelsInterface.h b/sim/include/vehicleModelsInterface.h index 9543999784096e8505ce7e2f533f5229bdd7a056..3ebd5b012a12644afce5f93f1bcb0b0849cb746f 100644 --- a/sim/include/vehicleModelsInterface.h +++ b/sim/include/vehicleModelsInterface.h @@ -63,83 +63,91 @@ T GetAttribute(openScenario::ParameterizedAttribute<T> attribute, const openScen } } -/*! - * \brief Container for axle parameters in OpenSCENARIO vehicle model - */ -struct VehicleAxle -{ - openScenario::ParameterizedAttribute<double> maxSteering = -999.0; //!< Maximum steering angle - openScenario::ParameterizedAttribute<double> wheelDiameter = -999.0; //!< Diameter of the wheels - openScenario::ParameterizedAttribute<double> trackWidth = -999.0; //!< Trackwidth of the axle - openScenario::ParameterizedAttribute<double> positionX = -999.0; //!< Longitudinal position offset (measured from reference point) - openScenario::ParameterizedAttribute<double> positionZ = -999.0; //!< Vertical position offset (measured from reference point) -}; - //! Contains the VehicleModelParameters as defined in the VehicleModelCatalog. //! Certain values may be parametrized and can be overwriten in the Scenario via ParameterAssignment struct ParametrizedVehicleModelParameters { - AgentVehicleType vehicleType = AgentVehicleType::Undefined; - openScenario::ParameterizedAttribute<double> width = -999.0; - openScenario::ParameterizedAttribute<double> length = -999.0; - openScenario::ParameterizedAttribute<double> height = -999.0; - VehicleAxle frontAxle{}; - VehicleAxle rearAxle{}; - openScenario::ParameterizedAttribute<double> distanceReferencePointToLeadingEdge = -999.0; - openScenario::ParameterizedAttribute<double> maxVelocity = -999.0; - openScenario::ParameterizedAttribute<double> weight = -999.0; - openScenario::ParameterizedAttribute<double> heightCOG = -999.0; - openScenario::ParameterizedAttribute<double> momentInertiaRoll = -999.0; - openScenario::ParameterizedAttribute<double> momentInertiaPitch = -999.0; - openScenario::ParameterizedAttribute<double> momentInertiaYaw = -999.0; - openScenario::ParameterizedAttribute<double> frontSurface = -999.0; - openScenario::ParameterizedAttribute<double> airDragCoefficient = -999.0; - openScenario::ParameterizedAttribute<double> minimumEngineSpeed = -999.0; - openScenario::ParameterizedAttribute<double> maximumEngineSpeed = -999.0; - openScenario::ParameterizedAttribute<double> minimumEngineTorque = -999.0; - openScenario::ParameterizedAttribute<double> maximumEngineTorque = -999.0; - openScenario::ParameterizedAttribute<int> numberOfGears = -999; - std::vector<openScenario::ParameterizedAttribute<double>> gearRatios; - openScenario::ParameterizedAttribute<double> axleRatio = -999.0; - openScenario::ParameterizedAttribute<double> decelerationFromPowertrainDrag = -999.0; - openScenario::ParameterizedAttribute<double> steeringRatio = -999.0; - openScenario::ParameterizedAttribute<double> frictionCoeff = -999.0; + AgentVehicleType vehicleType; - VehicleModelParameters Get(const openScenario::Parameters& assignedParameters) const + struct BoundingBoxCenter { - auto wheelbase = std::abs(frontAxle.positionX.defaultValue - rearAxle.positionX.defaultValue); - std::vector<double> transformedGearRatios; - std::transform(gearRatios.cbegin(), gearRatios.cend(), std::back_inserter(transformedGearRatios), [&](const auto& value){return GetAttribute(value, assignedParameters);}); - return VehicleModelParameters{ - vehicleType, - GetAttribute(width, assignedParameters), + openScenario::ParameterizedAttribute<double> x; + openScenario::ParameterizedAttribute<double> y; + openScenario::ParameterizedAttribute<double> z; + + VehicleModelParameters::BoundingBoxCenter Get(const openScenario::Parameters& assignedParameters) const + { + return {GetAttribute(x, assignedParameters), + GetAttribute(y, assignedParameters), + GetAttribute(z, assignedParameters)}; + } + } boundingBoxCenter; + + struct BoundingBoxDimensions + { + openScenario::ParameterizedAttribute<double> width; + openScenario::ParameterizedAttribute<double> length; + openScenario::ParameterizedAttribute<double> height; + + VehicleModelParameters::BoundingBoxDimensions Get(const openScenario::Parameters& assignedParameters) const + { + return {GetAttribute(width, assignedParameters), GetAttribute(length, assignedParameters), - GetAttribute(height, assignedParameters), - wheelbase, - GetAttribute(rearAxle.trackWidth, assignedParameters), - GetAttribute(distanceReferencePointToLeadingEdge, assignedParameters), - GetAttribute(frontAxle.positionX, assignedParameters), - GetAttribute(maxVelocity, assignedParameters), - GetAttribute(weight, assignedParameters), - GetAttribute(heightCOG, assignedParameters), - GetAttribute(momentInertiaRoll, assignedParameters), - GetAttribute(momentInertiaPitch, assignedParameters), - GetAttribute(momentInertiaYaw, assignedParameters), - GetAttribute(frontSurface, assignedParameters), - GetAttribute(airDragCoefficient, assignedParameters), - GetAttribute(minimumEngineSpeed, assignedParameters), - GetAttribute(maximumEngineSpeed, assignedParameters), - GetAttribute(minimumEngineTorque, assignedParameters), - GetAttribute(maximumEngineTorque, assignedParameters), - GetAttribute(numberOfGears, assignedParameters), - transformedGearRatios, - GetAttribute(axleRatio, assignedParameters), - GetAttribute(decelerationFromPowertrainDrag, assignedParameters), - GetAttribute(steeringRatio, assignedParameters), - GetAttribute(frontAxle.maxSteering, assignedParameters) * GetAttribute(steeringRatio, assignedParameters), - std::sin(GetAttribute(frontAxle.maxSteering, assignedParameters)) / wheelbase, - rearAxle.wheelDiameter.defaultValue / 2.0, - GetAttribute(frictionCoeff, assignedParameters) + GetAttribute(height, assignedParameters)}; + } + } boundingBoxDimensions; + + struct Performance + { + openScenario::ParameterizedAttribute<double> maxSpeed; + openScenario::ParameterizedAttribute<double> maxAcceleration; + openScenario::ParameterizedAttribute<double> maxDeceleration; + + VehicleModelParameters::Performance Get(const openScenario::Parameters& assignedParameters) const + { + return {GetAttribute(maxSpeed, assignedParameters), + GetAttribute(maxAcceleration, assignedParameters), + GetAttribute(maxDeceleration, assignedParameters)}; + } + } performance; + + struct Axle + { + openScenario::ParameterizedAttribute<double> maxSteering; + openScenario::ParameterizedAttribute<double> wheelDiameter; + openScenario::ParameterizedAttribute<double> trackWidth; + openScenario::ParameterizedAttribute<double> positionX; + openScenario::ParameterizedAttribute<double> positionZ; + + VehicleModelParameters::Axle Get(const openScenario::Parameters& assignedParameters) const + { + return {GetAttribute(maxSteering, assignedParameters), + GetAttribute(wheelDiameter, assignedParameters), + GetAttribute(trackWidth, assignedParameters), + GetAttribute(positionX, assignedParameters), + GetAttribute(positionZ, assignedParameters)}; + } + }; + Axle frontAxle; + Axle rearAxle; + + std::map<std::string, openScenario::ParameterizedAttribute<double>> properties; + + VehicleModelParameters Get(const openScenario::Parameters& assignedParameters) const + { + std::map<std::string, double> assignedProperties; + for (const auto[key, value] : properties) + { + assignedProperties.insert({key, GetAttribute(value, assignedParameters)}); + } + + return {vehicleType, + boundingBoxCenter.Get(assignedParameters), + boundingBoxDimensions.Get(assignedParameters), + performance.Get(assignedParameters), + frontAxle.Get(assignedParameters), + rearAxle.Get(assignedParameters), + assignedProperties }; } }; diff --git a/sim/include/worldObjectInterface.h b/sim/include/worldObjectInterface.h index 270d9dde525ea391bdd2a2b05f3ddf7101a38c5f..f350648c1964f3b55ef852ac96e825cc74804ace 100644 --- a/sim/include/worldObjectInterface.h +++ b/sim/include/worldObjectInterface.h @@ -47,6 +47,10 @@ public: /// \return yaw virtual double GetYaw() const = 0; + /// \brief Retrieves roll angle + /// \return roll + virtual double GetRoll() const = 0; + /// \brief Get unique id of an object /// \return id virtual int GetId() const = 0; diff --git a/sim/src/common/commonTools.h b/sim/src/common/commonTools.h index 58f6c9c64da096475ebfe11ca87e1978d88251cd..c81c71cb6f2830d7badcfad4b5ce4cc31d8222ba 100644 --- a/sim/src/common/commonTools.h +++ b/sim/src/common/commonTools.h @@ -408,6 +408,18 @@ public: return WillCrashDuringBrake(sFrontAtTtb - sEgoAtTtb, vEgo, assumedBrakeAccelerationEgo, vFrontAtTtb, aFrontAtTtb); } + + //! Calculate the width left of the reference point of a leaning object + static double GetWidthLeft(double width, double height, double roll) + { + return 0.5 * width * std::cos(roll) + (roll < 0 ? height * std::sin(-roll) : 0); + } + + //! Calculate the width right of the reference point of a leaning object + static double GetWidthRight(double width, double height, double roll) + { + return 0.5 * width * std::cos(roll) + (roll > 0 ? height * std::sin(roll) : 0); + } }; namespace helper::vector { @@ -474,7 +486,8 @@ public: //----------------------------------------------------------------------------- struct TtcParameters{ double length; - double width; + double widthLeft; + double widthRight; double frontLength; // distance from reference point of object to leading edge of object double backLength; // distance from reference point to back edge of object point_t position; @@ -549,7 +562,8 @@ private: // Initial bounding box in local coordinate system parameters.length = object->GetLength() + collisionDetectionLongitudinalBoundary; - parameters.width = object->GetWidth() + collisionDetectionLateralBoundary; + parameters.widthLeft = TrafficHelperFunctions::GetWidthLeft(object->GetWidth(), object->GetHeight(), object->GetRoll()) + 0.5 * collisionDetectionLateralBoundary; + parameters.widthRight = TrafficHelperFunctions::GetWidthRight(object->GetWidth(), object->GetHeight(), object->GetRoll()) + 0.5 * collisionDetectionLateralBoundary; parameters.frontLength = object->GetDistanceReferencePointToLeadingEdge() + 0.5 * collisionDetectionLongitudinalBoundary; //returns the distance from reference point of object to leading edge of object parameters.backLength = parameters.length - parameters.frontLength; // distance from reference point to back edge of object @@ -587,11 +601,11 @@ private: // construct corner points from reference point position and current yaw angle polygon_t box; - bg::append(box, point_t{ parameters.position.get<0>() - std::cos(parameters.yaw) * parameters.backLength + std::sin(parameters.yaw) * 0.5 * parameters.width , parameters.position.get<1>() - std::sin(parameters.yaw) * parameters.backLength - std::cos(parameters.yaw) * 0.5 * parameters.width }); // back right corner - bg::append(box, point_t{ parameters.position.get<0>() - std::cos(parameters.yaw) * parameters.backLength - std::sin(parameters.yaw) * 0.5 * parameters.width , parameters.position.get<1>() - std::sin(parameters.yaw) * parameters.backLength + std::cos(parameters.yaw) * 0.5 * parameters.width }); // back left corner - bg::append(box, point_t{ parameters.position.get<0>() + std::cos(parameters.yaw) * parameters.frontLength - std::sin(parameters.yaw) * 0.5 * parameters.width , parameters.position.get<1>() + std::sin(parameters.yaw) * parameters.frontLength + std::cos(parameters.yaw) * 0.5 * parameters.width }); // front left corner - bg::append(box, point_t{ parameters.position.get<0>() + std::cos(parameters.yaw) * parameters.frontLength + std::sin(parameters.yaw) * 0.5 * parameters.width , parameters.position.get<1>() + std::sin(parameters.yaw) * parameters.frontLength - std::cos(parameters.yaw) * 0.5 * parameters.width }); // front right corner - bg::append(box, point_t{ parameters.position.get<0>() - std::cos(parameters.yaw) * parameters.backLength + std::sin(parameters.yaw) * 0.5 * parameters.width , parameters.position.get<1>() - std::sin(parameters.yaw) * parameters.backLength - std::cos(parameters.yaw) * 0.5 * parameters.width }); // back right corner + bg::append(box, point_t{ parameters.position.get<0>() - std::cos(parameters.yaw) * parameters.backLength + std::sin(parameters.yaw) * parameters.widthRight , parameters.position.get<1>() - std::sin(parameters.yaw) * parameters.backLength - std::cos(parameters.yaw) * parameters.widthRight }); // back right corner + bg::append(box, point_t{ parameters.position.get<0>() - std::cos(parameters.yaw) * parameters.backLength - std::sin(parameters.yaw) * parameters.widthLeft , parameters.position.get<1>() - std::sin(parameters.yaw) * parameters.backLength + std::cos(parameters.yaw) * parameters.widthLeft }); // back left corner + bg::append(box, point_t{ parameters.position.get<0>() + std::cos(parameters.yaw) * parameters.frontLength - std::sin(parameters.yaw) * parameters.widthLeft , parameters.position.get<1>() + std::sin(parameters.yaw) * parameters.frontLength + std::cos(parameters.yaw) * parameters.widthLeft }); // front left corner + bg::append(box, point_t{ parameters.position.get<0>() + std::cos(parameters.yaw) * parameters.frontLength + std::sin(parameters.yaw) * parameters.widthRight , parameters.position.get<1>() + std::sin(parameters.yaw) * parameters.frontLength - std::cos(parameters.yaw) * parameters.widthRight }); // front right corner + bg::append(box, point_t{ parameters.position.get<0>() - std::cos(parameters.yaw) * parameters.backLength + std::sin(parameters.yaw) * parameters.widthRight , parameters.position.get<1>() - std::sin(parameters.yaw) * parameters.backLength - std::cos(parameters.yaw) * parameters.widthRight }); // back right corner return box; } //----------------------------------------------------------------------------- diff --git a/sim/src/common/dynamicsSignal.h b/sim/src/common/dynamicsSignal.h index e8d8d217597c4afd47bdd6f2c1f35a4f27a9f92a..72710581a880acbbdc43a7c0db58270bdbe6de24 100644 --- a/sim/src/common/dynamicsSignal.h +++ b/sim/src/common/dynamicsSignal.h @@ -39,6 +39,7 @@ public: double positionY, double yaw, double yawRate, + double roll, double steeringWheelAngle, double centripetalAcceleration, double travelDistance) : @@ -49,6 +50,7 @@ public: positionY(positionY), yaw(yaw), yawRate(yawRate), + roll(roll), steeringWheelAngle(steeringWheelAngle), centripetalAcceleration(centripetalAcceleration), travelDistance(travelDistance) @@ -76,6 +78,7 @@ public: stream << "positionY: " << positionY << std::endl; stream << "yaw: " << yaw << std::endl; stream << "yawRate: " << yawRate << std::endl; + stream << "roll: " << roll << std::endl; stream << "steeringWheelAngle: " << steeringWheelAngle << std::endl; stream << "centripetalAcceleration: " << centripetalAcceleration << std::endl; stream << "travelDistance: " << travelDistance << std::endl; @@ -88,6 +91,7 @@ public: double positionY = 0.0; double yaw = 0.0; double yawRate = 0.0; + double roll = 0.0; double steeringWheelAngle = 0.0; double centripetalAcceleration = 0.0; double travelDistance = 0.0; diff --git a/sim/src/common/globalDefinitions.h b/sim/src/common/globalDefinitions.h index bdccfa88e4cfc9c9d8c1acb4a2c94fa2e4a3b8e6..d0351298555f537491b3da99473b185b5d008927 100644 --- a/sim/src/common/globalDefinitions.h +++ b/sim/src/common/globalDefinitions.h @@ -289,83 +289,41 @@ enum class Side struct VehicleModelParameters { - // ----------------------------------------- - // full vehicle related parameters - // ----------------------------------------- - - // The type of the vehicle - AgentVehicleType vehicleType = AgentVehicleType::Undefined; - // The maximum width of the vehicle in m - double width = -999.0; - // The maximum length of the vehicle in m - double length = -999.0; - // The maximum height of the vehicle in m - double height = -999.0; - // The wheelbase of the vehicle in m - double wheelbase = -999.0; - // The trackwidth of the vehicle in m - double trackwidth = -999.0; - // The distance between the vehicle coordinate system's reference point (rear axle) and the front bumper in m - double distanceReferencePointToLeadingEdge = -999.0; - // The distance between the vehicle coordinate system's reference point (rear axle) and the front axle in m - double distanceReferencePointToFrontAxle = -999.0; - // The maximum velocity of the vehicle in m/s - double maxVelocity = -999.0; - // The overall mass of the vehicle in kg - double weight = -999.0; - // The height of the center of gravity above ground in m - double heightCOG = -999.0; - // The moment of inertia along the vehicle's longtudinal axes in kgm2 - double momentInertiaRoll = -999.0; - // The moment of inertia along the vehicle's lateral axes in kgm2 - double momentInertiaPitch = -999.0; - // The moment of inertia along the vehicle's vertical axes in kgm2 - double momentInertiaYaw = -999.0; - // The projected front surface of the vehicle in m2 - double frontSurface = -999.0; - // The air drag coefficient of the vehicle - double airDragCoefficient = -999.0; - - // ----------------------------------------- - // power train related parameters - // ----------------------------------------- - - // The idle speed of the engine in 1/min - double minimumEngineSpeed = -999.0; - // The maximum engine speed in 1/min - double maximumEngineSpeed = -999.0; - // The drag torque of the engine in Nm - double minimumEngineTorque = -999.0; - // The maximum torque of the engine in Nm - double maximumEngineTorque = -999.0; - // The number of gears in the gearbox (no reverse gear) - int numberOfGears = -999; - // The ratios of all gears in the gearbox (no reverse gear) - std::vector<double> gearRatios; - // The ratio of the axle gear - double axleRatio = -999.0; - // The deceleration caused by the overall powertrain drag torque in m/s2 - double decelerationFromPowertrainDrag = -999.0; - - // ----------------------------------------- - // steering related parameters - // ----------------------------------------- - - // The ratio of the steering gear - double steeringRatio = -999.0; - // The maximum amplitude of the steering wheel angle in radian - double maximumSteeringWheelAngleAmplitude = -999.0; - // The maximum curavture the vehicle is able to drive in 1/m - double maxCurvature = -999.0; - - // ----------------------------------------- - // wheel related parameters - // ----------------------------------------- - - // The static wheel radius in m - double staticWheelRadius = -999.0; - // The friction coefficient between road and the vehicles tires - double frictionCoeff = -999.0; + AgentVehicleType vehicleType; + + struct BoundingBoxCenter + { + double x; + double y; + double z; + } boundingBoxCenter; + + struct BoundingBoxDimensions + { + double width; + double length; + double height; + } boundingBoxDimensions; + + struct Performance + { + double maxSpeed; + double maxAcceleration; + double maxDeceleration; + } performance; + + struct Axle + { + double maxSteering; + double wheelDiameter; + double trackWidth; + double positionX; + double positionZ; + }; + Axle frontAxle; + Axle rearAxle; + + std::map<std::string, double> properties; }; enum class AdasType diff --git a/sim/src/common/rollSignal.h b/sim/src/common/rollSignal.h new file mode 100644 index 0000000000000000000000000000000000000000..1d6fdbd3acf87ec041e1f8ec9e201beb30680409 --- /dev/null +++ b/sim/src/common/rollSignal.h @@ -0,0 +1,68 @@ +/******************************************************************************* +* Copyright (c) 2021 in-tech GmbH +* +* This program and the accompanying materials are made +* available under the terms of the Eclipse Public License 2.0 +* which is available at https://www.eclipse.org/legal/epl-2.0/ +* +* SPDX-License-Identifier: EPL-2.0 +*******************************************************************************/ + +//----------------------------------------------------------------------------- +//! @file rollSignal.h +//! @brief This file contains all functions for class +//! RollSignal +//! +//! This class contains all functionality of the signal. +//----------------------------------------------------------------------------- +#pragma once + +#include "include/modelInterface.h" + +class RollSignal: public ComponentStateSignalInterface +{ +public: + const std::string COMPONENTNAME = "RollSignal"; + + //----------------------------------------------------------------------------- + //! Constructor + //----------------------------------------------------------------------------- + RollSignal() + { + componentState = ComponentState::Disabled; + } + + //----------------------------------------------------------------------------- + //! Constructor + //----------------------------------------------------------------------------- + RollSignal( + ComponentState componentState, + double rollAngle + ): + rollAngle(rollAngle) + { + this->componentState = componentState; + } + + RollSignal(const RollSignal&) = default; + RollSignal(RollSignal&&) = default; + RollSignal& operator=(const RollSignal&) = default; + RollSignal& operator=(RollSignal&&) = default; + + virtual ~RollSignal() = default; + + //----------------------------------------------------------------------------- + //! Returns the content/payload of the signal as an std::string + //! + //! @return Content/payload of the signal as an std::string + //----------------------------------------------------------------------------- + virtual operator std::string() const + { + std::ostringstream stream; + stream << COMPONENTNAME; + return stream.str(); + } + + double rollAngle {0.}; + +}; diff --git a/sim/src/components/AgentUpdater/src/agentUpdaterImpl.cpp b/sim/src/components/AgentUpdater/src/agentUpdaterImpl.cpp index 533ecf5019401896bdbc9af91208d18e35b40007..41f9ca9723d9194ca5ce8b0c58a2d7e27f035087 100644 --- a/sim/src/components/AgentUpdater/src/agentUpdaterImpl.cpp +++ b/sim/src/components/AgentUpdater/src/agentUpdaterImpl.cpp @@ -36,6 +36,7 @@ void AgentUpdaterImplementation::UpdateInput(int localLinkId, const std::shared_ positionY = signal->positionY; yaw = signal->yaw; yawRate = signal->yawRate; + roll = signal->roll; steeringWheelAngle = signal->steeringWheelAngle; centripetalAcceleration = signal->centripetalAcceleration; travelDistance = signal->travelDistance; @@ -64,6 +65,7 @@ void AgentUpdaterImplementation::Trigger([[maybe_unused]] int time) agent->SetPositionY(positionY); agent->SetYaw(yaw); agent->SetYawRate(yawRate); + agent->SetRoll(roll); agent->SetSteeringWheelAngle(steeringWheelAngle); agent->SetCentripetalAcceleration(centripetalAcceleration); agent->SetDistanceTraveled(agent->GetDistanceTraveled() + travelDistance); diff --git a/sim/src/components/AgentUpdater/src/agentUpdaterImpl.h b/sim/src/components/AgentUpdater/src/agentUpdaterImpl.h index df0d7f6e486f1261f5d8f82437bbad2ee71b3d48..b835231fdf787c8b6082c30d0ce433e5b4687f34 100644 --- a/sim/src/components/AgentUpdater/src/agentUpdaterImpl.h +++ b/sim/src/components/AgentUpdater/src/agentUpdaterImpl.h @@ -123,6 +123,7 @@ private: double positionY {0.0}; double yaw {0.0}; double yawRate {0.0}; + double roll {0.0}; double steeringWheelAngle {0.0}; double centripetalAcceleration {0.0}; double travelDistance {0.0}; diff --git a/sim/src/components/Algorithm_AEB/Algorithm_AEB.pro b/sim/src/components/Algorithm_AEB/Algorithm_AEB.pro index 6dc279bf2feefc7cb1d5925be6fa07fc6944f55a..ed65ddc7279b9bbe92f238443a2c5a10c24d612b 100644 --- a/sim/src/components/Algorithm_AEB/Algorithm_AEB.pro +++ b/sim/src/components/Algorithm_AEB/Algorithm_AEB.pro @@ -29,13 +29,11 @@ INCLUDEPATH += \ SOURCES += \ algorithm_autonomousEmergencyBraking.cpp \ - src/autonomousEmergencyBraking.cpp \ - src/boundingBoxCalculation.cpp + src/autonomousEmergencyBraking.cpp HEADERS += \ algorithm_autonomousEmergencyBraking.h \ - src/autonomousEmergencyBraking.h \ - src/boundingBoxCalculation.h + src/autonomousEmergencyBraking.h LIBS += \ -lopen_simulation_interface \ diff --git a/sim/src/components/Algorithm_AEB/CMakeLists.txt b/sim/src/components/Algorithm_AEB/CMakeLists.txt index 98235822d0a88982406788472bf2c53a2b4e0677..6ea800c0921afc492e45b85eff1e4c0d0345bf3f 100644 --- a/sim/src/components/Algorithm_AEB/CMakeLists.txt +++ b/sim/src/components/Algorithm_AEB/CMakeLists.txt @@ -8,12 +8,10 @@ add_openpass_target( HEADERS algorithm_autonomousEmergencyBraking.h src/autonomousEmergencyBraking.h - src/boundingBoxCalculation.h SOURCES algorithm_autonomousEmergencyBraking.cpp src/autonomousEmergencyBraking.cpp - src/boundingBoxCalculation.cpp INCDIRS ${CMAKE_CURRENT_LIST_DIR}/core/slave/modules/World_OSI diff --git a/sim/src/components/Algorithm_AEB/src/autonomousEmergencyBraking.cpp b/sim/src/components/Algorithm_AEB/src/autonomousEmergencyBraking.cpp index 1d4a42053fd1a37bbfe9d820239e3447564dc655..309b0ad1f0c7a93252fd517d501f76e5a6a41388 100644 --- a/sim/src/components/Algorithm_AEB/src/autonomousEmergencyBraking.cpp +++ b/sim/src/components/Algorithm_AEB/src/autonomousEmergencyBraking.cpp @@ -20,7 +20,6 @@ #include "common/commonTools.h" #include "common/eventTypes.h" #include "common/sensorFusionQuery.h" -#include "boundingBoxCalculation.h" AlgorithmAutonomousEmergencyBrakingImplementation::AlgorithmAutonomousEmergencyBrakingImplementation( std::string componentName, @@ -175,22 +174,30 @@ bool AlgorithmAutonomousEmergencyBrakingImplementation::ShouldBeDeactivated(cons double AlgorithmAutonomousEmergencyBrakingImplementation::CalculateObjectTTC(const osi3::BaseMoving &baseMoving) { - TtcCalculations::TtcParameters own; - own.length = GetAgent()->GetLength() + collisionDetectionLongitudinalBoundary; - own.width = GetAgent()->GetWidth() + collisionDetectionLateralBoundary; - own.frontLength = GetAgent()->GetDistanceReferencePointToLeadingEdge() + 0.5 * collisionDetectionLongitudinalBoundary; - own.backLength = own.length - own.frontLength; - own.position = {0.0, 0.0}; - own.velocityX = 0.0; - own.velocityY = 0.0; - own.accelerationX = 0.0; - own.accelerationY = 0.0; - own.yaw = 0.0; - own.yawRate = GetAgent()->GetYawRate(); - own.yawAcceleration = 0.0; // GetAgent()->GetYawAcceleration() not implemented yet + TtcCalculations::TtcParameters ego; + ego.length = GetAgent()->GetLength() + collisionDetectionLongitudinalBoundary; + double width = GetAgent()->GetWidth(); + double height = GetAgent()->GetHeight(); + double roll = GetAgent()->GetRoll(); + ego.widthLeft = TrafficHelperFunctions::GetWidthLeft(width, height, roll) + 0.5 * collisionDetectionLateralBoundary; + ego.widthRight = TrafficHelperFunctions::GetWidthRight(width, height, roll) + 0.5 * collisionDetectionLateralBoundary; + ego.frontLength = GetAgent()->GetDistanceReferencePointToLeadingEdge() + 0.5 * collisionDetectionLongitudinalBoundary; + ego.backLength = ego.length - ego.frontLength; + ego.position = {0.0, 0.0}; + ego.velocityX = 0.0; + ego.velocityY = 0.0; + ego.accelerationX = 0.0; + ego.accelerationY = 0.0; + ego.yaw = 0.0; + ego.yawRate = GetAgent()->GetYawRate(); + ego.yawAcceleration = 0.0; // GetAgent()->GetYawAcceleration() not implemented yet TtcCalculations::TtcParameters opponent; opponent.length = baseMoving.dimension().length() + collisionDetectionLongitudinalBoundary; - opponent.width = baseMoving.dimension().width() + collisionDetectionLateralBoundary; + width = baseMoving.dimension().width(); + height = baseMoving.dimension().height(); + roll = baseMoving.orientation().roll(); + opponent.widthLeft = TrafficHelperFunctions::GetWidthLeft(width, height, roll) + 0.5 * collisionDetectionLateralBoundary; + opponent.widthRight = TrafficHelperFunctions::GetWidthRight(width, height, roll) + 0.5 * collisionDetectionLateralBoundary; opponent.frontLength = 0.5 * opponent.length; opponent.backLength = 0.5 * opponent.length; opponent.position = {baseMoving.position().x(), baseMoving.position().y()}; @@ -201,28 +208,36 @@ double AlgorithmAutonomousEmergencyBrakingImplementation::CalculateObjectTTC(con opponent.yaw = baseMoving.orientation().yaw(); opponent.yawRate = baseMoving.orientation_rate().yaw(); opponent.yawAcceleration = baseMoving.orientation_acceleration().yaw(); - return TtcCalculations::CalculateObjectTTC(own, opponent, ttcBrake * 1.5, GetCycleTime()); + return TtcCalculations::CalculateObjectTTC(ego, opponent, ttcBrake * 1.5, GetCycleTime()); } double AlgorithmAutonomousEmergencyBrakingImplementation::CalculateObjectTTC(const osi3::BaseStationary &baseStationary) { - TtcCalculations::TtcParameters own; - own.length = GetAgent()->GetLength() + collisionDetectionLongitudinalBoundary; - own.width = GetAgent()->GetWidth() + collisionDetectionLateralBoundary; - own.frontLength = GetAgent()->GetDistanceReferencePointToLeadingEdge() + 0.5 * collisionDetectionLongitudinalBoundary; - own.backLength = own.length - own.frontLength; - own.position = {0.0, 0.0}; - own.velocityX = 0.0; - own.velocityY = 0.0; - own.accelerationX = 0.0; - own.accelerationY = 0.0; - own.yaw = 0.0; - own.yawRate = GetAgent()->GetYawRate(); - own.yawAcceleration = 0.0; // GetAgent()->GetYawAcceleration() not implemented yet + TtcCalculations::TtcParameters ego; + ego.length = GetAgent()->GetLength() + collisionDetectionLongitudinalBoundary; + double width = GetAgent()->GetWidth(); + double height = GetAgent()->GetHeight(); + double roll = GetAgent()->GetRoll(); + ego.widthLeft = TrafficHelperFunctions::GetWidthLeft(width, height, roll) + 0.5 * collisionDetectionLateralBoundary; + ego.widthRight = TrafficHelperFunctions::GetWidthRight(width, height, roll) + 0.5 * collisionDetectionLateralBoundary; + ego.frontLength = GetAgent()->GetDistanceReferencePointToLeadingEdge() + 0.5 * collisionDetectionLongitudinalBoundary; + ego.backLength = ego.length - ego.frontLength; + ego.position = {0.0, 0.0}; + ego.velocityX = 0.0; + ego.velocityY = 0.0; + ego.accelerationX = 0.0; + ego.accelerationY = 0.0; + ego.yaw = 0.0; + ego.yawRate = GetAgent()->GetYawRate(); + ego.yawAcceleration = 0.0; // GetAgent()->GetYawAcceleration() not implemented yet TtcCalculations::TtcParameters opponent; opponent.length = baseStationary.dimension().length() + collisionDetectionLongitudinalBoundary; - opponent.width = baseStationary.dimension().width() + collisionDetectionLateralBoundary; + width = baseStationary.dimension().width(); + height = baseStationary.dimension().height(); + roll = baseStationary.orientation().roll(); + opponent.widthLeft = TrafficHelperFunctions::GetWidthLeft(width, height, roll) + 0.5 * collisionDetectionLateralBoundary; + opponent.widthRight = TrafficHelperFunctions::GetWidthRight(width, height, roll) + 0.5 * collisionDetectionLateralBoundary; opponent.frontLength = 0.5 * opponent.length; opponent.backLength = 0.5 * opponent.length; opponent.position = {baseStationary.position().x(), baseStationary.position().y()}; @@ -234,7 +249,7 @@ double AlgorithmAutonomousEmergencyBrakingImplementation::CalculateObjectTTC(con opponent.yawRate = 0.0; opponent.yawAcceleration = 0.0; - return TtcCalculations::CalculateObjectTTC(own, opponent, ttcBrake * 1.5, GetCycleTime()); + return TtcCalculations::CalculateObjectTTC(ego, opponent, ttcBrake * 1.5, GetCycleTime()); } double AlgorithmAutonomousEmergencyBrakingImplementation::CalculateTTC() diff --git a/sim/src/components/Algorithm_AEB/src/boundingBoxCalculation.cpp b/sim/src/components/Algorithm_AEB/src/boundingBoxCalculation.cpp deleted file mode 100644 index 53c3e520b8daab9dd6223628106783ed15b11b1b..0000000000000000000000000000000000000000 --- a/sim/src/components/Algorithm_AEB/src/boundingBoxCalculation.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2019 in-tech GmbH -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -*******************************************************************************/ - -#include "boundingBoxCalculation.h" - -BoundingBoxCalculation::BoundingBoxCalculation( - AgentInterface* agent, - double collisionDetectionLongitudinalBoundary, - double collisionDetectionLateralBoundary) : - agent(agent), - collisionDetectionLongitudinalBoundary(collisionDetectionLongitudinalBoundary), - collisionDetectionLateralBoundary(collisionDetectionLateralBoundary) -{ -} - -polygon_t BoundingBoxCalculation::CalculateBoundingBox(double timeStepInSeconds, const osi3::BaseMoving &baseMoving) -{ - // Initial bounding box in locale coordinate system - double lengthHalf = (baseMoving.dimension().length() + collisionDetectionLongitudinalBoundary) / 2.0; - double widthHalf = (baseMoving.dimension().width() + collisionDetectionLateralBoundary) / 2.0; - - double boxPoints[][2] - { - { -lengthHalf, -widthHalf }, - { lengthHalf, -widthHalf }, - { lengthHalf, widthHalf }, - { -lengthHalf, widthHalf }, - { -lengthHalf, -widthHalf } - }; - - polygon_t box; - bg::append(box, boxPoints); - - // inital object values at current position - point_t initialPosition = { baseMoving.position().x(), baseMoving.position().y()}; - double initialVelocityX = baseMoving.velocity().x() + agent->GetVelocity(); //Velocity in BaseMoving is relative to own vehicle - double initialVelocityY = baseMoving.velocity().y(); - double initialVelocity = std::hypot(initialVelocityX, initialVelocityY); - double initialYaw = baseMoving.orientation().yaw(); - double yawRate = baseMoving.orientation_rate().yaw() + agent->GetYawRate(); - double accelerationX = baseMoving.acceleration().x() + agent->GetAcceleration(); //Acceleration in BaseMoving is relative to own vehicle - double accelerationY = baseMoving.acceleration().y(); -// double acceleration = std::hypot(accelerationX, accelerationY); - double traveledDistanceX = initialVelocityX * timeStepInSeconds + 0.5 * accelerationX * timeStepInSeconds * timeStepInSeconds; - double traveledDistanceY = initialVelocityY * timeStepInSeconds + 0.5 * accelerationY * timeStepInSeconds * timeStepInSeconds; - double traveledDistance = std::hypot(traveledDistanceX, traveledDistanceY); - - // delta from initial position (object's perspective) - point_t deltaPosition = { 0.0, 0.0 }; - point_t rotatedDeltaPosition; - double deltaYaw = 0.0; - - if (yawRate != 0.0) - { - // Radius of the circle the agent is moving on radius = arc length / angle (or their deriviates) - double radius = initialVelocity / yawRate; - deltaYaw = traveledDistance / radius; - deltaPosition.x(radius * std::sin(deltaYaw)); - deltaPosition.y(radius * (1 - std::cos(deltaYaw))); - } - else - { - // Just driving in a straight line - deltaPosition.x(traveledDistance); - } - - // rotation in mathematical negative orientation (boost) -> invert to match - bt::rotate_transformer<bg::radian, double, 2, 2> totalRotation(-initialYaw - deltaYaw); - bt::rotate_transformer<bg::radian, double, 2, 2> initialRotation(-initialYaw); - bg::transform(deltaPosition, rotatedDeltaPosition, initialRotation); - - bt::translate_transformer<double, 2, 2> totalTranslation(initialPosition.x() + rotatedDeltaPosition.x(), - initialPosition.y() + rotatedDeltaPosition.y()); - - // rotate, then translate - polygon_t boxTemp; - bg::transform(box, boxTemp, totalRotation); - bg::transform(boxTemp, box, totalTranslation); - return box; -} - -polygon_t BoundingBoxCalculation::CalculateBoundingBox(const osi3::BaseStationary &baseStationary) -{ - // Initial bounding box in locale coordinate system - double lengthHalf = (baseStationary.dimension().length() + collisionDetectionLongitudinalBoundary) / 2.0; - double widthHalf = (baseStationary.dimension().width() + collisionDetectionLateralBoundary) / 2.0; - double yaw = baseStationary.orientation().yaw(); - - double boxPoints[][2] - { - { -lengthHalf, -widthHalf }, - { lengthHalf, -widthHalf }, - { lengthHalf, widthHalf }, - { -lengthHalf, widthHalf }, - { -lengthHalf, -widthHalf } - }; - - polygon_t box; - bg::append(box, boxPoints); - - bt::rotate_transformer<bg::radian, double, 2, 2> rotation(-yaw); - bt::translate_transformer<double, 2, 2> translation(baseStationary.position().x(), - baseStationary.position().y()); - - // rotate, then translate - polygon_t boxTemp; - bg::transform(box, boxTemp, rotation); - bg::transform(boxTemp, box, translation); - return box; -} - -polygon_t BoundingBoxCalculation::CalculateOwnBoundingBox(double timeStepInSeconds) -{ - // Initial bounding box in locale coordinate system - double frontLength = agent->GetDistanceReferencePointToLeadingEdge() + collisionDetectionLongitudinalBoundary / 2.0; - double rearLength = agent->GetLength() - agent->GetDistanceReferencePointToLeadingEdge() + collisionDetectionLongitudinalBoundary / 2.0; - double widthHalf = (agent->GetWidth() + collisionDetectionLateralBoundary) / 2.0; - - double boxPoints[][2] - { - { -rearLength, -widthHalf }, - { frontLength, -widthHalf }, - { frontLength, widthHalf }, - { -rearLength, widthHalf }, - { -rearLength, -widthHalf } - }; - - polygon_t box; - bg::append(box, boxPoints); - - double initialVelocity = agent->GetVelocity(); - double yawRate = agent->GetYawRate(); - double acceleration = agent->GetAcceleration(); - double traveledDistance = initialVelocity * timeStepInSeconds + 0.5 * acceleration * timeStepInSeconds * timeStepInSeconds; - - point_t deltaPosition = { 0.0, 0.0 }; - double deltaYaw = 0.0; - - if (yawRate != 0.0) - { - // Radius of the circle the agent is moving on radius = arc length / angle (or their deriviates) - double radius = initialVelocity / yawRate; - deltaYaw = traveledDistance / radius; - deltaPosition.x(radius * std::sin(deltaYaw)); - deltaPosition.y(radius * (1 - std::cos(deltaYaw))); - } - else - { - // Just driving in a straight line - deltaPosition.x(traveledDistance); - } - - // rotation in mathematical negative orientation (boost) -> invert to match - bt::rotate_transformer<bg::radian, double, 2, 2> totalRotation(- deltaYaw); - - bt::translate_transformer<double, 2, 2> totalTranslation(deltaPosition.x(), - deltaPosition.y()); - - // rotate, then translate - polygon_t boxTemp; - bg::transform(box, boxTemp, totalRotation); - bg::transform(boxTemp, box, totalTranslation); - return box; -} diff --git a/sim/src/components/Algorithm_AEB/src/boundingBoxCalculation.h b/sim/src/components/Algorithm_AEB/src/boundingBoxCalculation.h deleted file mode 100644 index bb3d17e5d881ea2272d3988f5569625cbf7784e9..0000000000000000000000000000000000000000 --- a/sim/src/components/Algorithm_AEB/src/boundingBoxCalculation.h +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2019 in-tech GmbH -* Copyright (c) 2020 HLRS, University of Stuttgart. -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -*******************************************************************************/ - -#pragma once -#include <boost/geometry/geometries/adapted/c_array.hpp> -#include "common/boostGeometryCommon.h" -#include "include/agentInterface.h" -#include "osi3/osi_sensordata.pb.h" - -/** \addtogroup Algorithm_AEB - * @{ - * \brief Utility class for AEB to predict the bounding box of objects in future timesteps -* @} */ -class BoundingBoxCalculation -{ -public: - BoundingBoxCalculation(AgentInterface *agent, double collisionDetectionLongitudinalBoundary, double collisionDetectionLateralBoundary); - - /*! - * \brief Predicts the bounding box of a moving object in local coordinates - * \param timeStepInSeconds relative time since current timeStep - * \param baseMoving object to predict - * \return predicted bounding box - */ - polygon_t CalculateBoundingBox(double timeStepInSeconds, const osi3::BaseMoving &baseMoving); - - /*! - * \brief Calculates the bounding box of a stationary object in local coordinates - * \param baseMoving object to calculate - * \return calculated bounding box - */ - polygon_t CalculateBoundingBox(const osi3::BaseStationary &baseStationary); - - /*! - * \brief Predicts the bounding box of the own agent in local coordinates (coordinate system does not move along) - * \param timeStepInSeconds relative time since current timeStep - * \return predicted bounding box - */ - polygon_t CalculateOwnBoundingBox(double timeStepInSeconds); - -private: - AgentInterface* agent; ///!< The agent for which the boundingbox should be calculated - double collisionDetectionLongitudinalBoundary; ///!< Additional length added to the vehicle boundary when checking for collision detection - double collisionDetectionLateralBoundary; ///!< Additional width added to the vehicle boundary when checking for collision detection -}; diff --git a/sim/src/components/Algorithm_FmuWrapper/src/OsmpFmuHandler.cpp b/sim/src/components/Algorithm_FmuWrapper/src/OsmpFmuHandler.cpp index fcff3c5a158391346e16b5cc3e161cb5ccbd3de2..3d78b803d5113ba26c980c805c3671d69c55a5e5 100644 --- a/sim/src/components/Algorithm_FmuWrapper/src/OsmpFmuHandler.cpp +++ b/sim/src/components/Algorithm_FmuWrapper/src/OsmpFmuHandler.cpp @@ -252,6 +252,7 @@ void OsmpFmuHandler::UpdateOutput(int localLinkId, std::shared_ptr<SignalInterfa double positionY{0.0}; double yaw{0.0}; double yawRate{0.0}; + double roll{0.0}; double steeringWheelAngle{0.0}; double centripetalAcceleration{0.0}; double travelDistance{0.0}; @@ -279,6 +280,7 @@ void OsmpFmuHandler::UpdateOutput(int localLinkId, std::shared_ptr<SignalInterfa const auto& baseMoving = trafficUpdate.mutable_update()->mutable_base(); velocity = std::sqrt(baseMoving->velocity().x() * baseMoving->velocity().x() + baseMoving->velocity().y() * baseMoving->velocity().y()); yaw = baseMoving->orientation().yaw(); + roll = baseMoving->orientation().roll(); acceleration = baseMoving->acceleration().x() * std::cos(yaw) + baseMoving->acceleration().y() * std::sin(yaw); centripetalAcceleration = -baseMoving->acceleration().x() * std::sin(yaw) + baseMoving->acceleration().y() * std::cos(yaw); positionX = baseMoving->position().x(); @@ -309,6 +311,7 @@ void OsmpFmuHandler::UpdateOutput(int localLinkId, std::shared_ptr<SignalInterfa positionY, yaw, yawRate, + roll, steeringWheelAngle, centripetalAcceleration, travelDistance); diff --git a/sim/src/components/Algorithm_Lateral/src/lateralImpl.cpp b/sim/src/components/Algorithm_Lateral/src/lateralImpl.cpp index c2eaf73c802cd28070731c7472566c45bd18ac63..e8f5d164536ab598e59118019ea7ab8f25bd6d7d 100644 --- a/sim/src/components/Algorithm_Lateral/src/lateralImpl.cpp +++ b/sim/src/components/Algorithm_Lateral/src/lateralImpl.cpp @@ -22,6 +22,7 @@ #include "common/lateralSignal.h" #include "common/commonTools.h" #include "common/globalDefinitions.h" +#include "components/common/vehicleProperties.h" #include "components/Sensor_Driver/src/Signals/sensorDriverSignal.h" void AlgorithmLateralImplementation::UpdateInput(int localLinkId, const std::shared_ptr<SignalInterface const> &data, int time) @@ -60,10 +61,12 @@ void AlgorithmLateralImplementation::UpdateInput(int localLinkId, const std::sha LOG(CbkLogLevel::Debug, msg); throw std::runtime_error(msg); } + const auto steeringRatio = helper::map::query(signal->vehicleParameters.properties, vehicle::properties::SteeringRatio); + THROWIFFALSE(steeringRatio.has_value(), "SteeringRatio was not defined in VehicleCatalog"); - steeringController.SetVehicleParameter(signal->vehicleParameters.steeringRatio, - signal->vehicleParameters.maximumSteeringWheelAngleAmplitude, - signal->vehicleParameters.wheelbase); + steeringController.SetVehicleParameter(steeringRatio.value(), + signal->vehicleParameters.frontAxle.maxSteering * steeringRatio.value(), + signal->vehicleParameters.frontAxle.positionX - signal->vehicleParameters.rearAxle.positionX); } else if (localLinkId == 101 || localLinkId == 102) { diff --git a/sim/src/components/Algorithm_Longitudinal/src/algo_longImpl.cpp b/sim/src/components/Algorithm_Longitudinal/src/algo_longImpl.cpp index 7a90275b5dd10bc22e6482dca7300d82f3c19985..4d343640cd2f3c96c486b80479a709bd238ff453 100644 --- a/sim/src/components/Algorithm_Longitudinal/src/algo_longImpl.cpp +++ b/sim/src/components/Algorithm_Longitudinal/src/algo_longImpl.cpp @@ -145,7 +145,8 @@ void AlgorithmLongitudinalImplementation::CalculatePedalPositionAndGear() { AlgorithmLongitudinalCalculations calculations{currentVelocity, accelerationWish, - vehicleModelParameters}; + vehicleModelParameters, + [&](auto logLevel, auto line, auto file, auto& message){Log(logLevel, line, file, message);}}; calculations.CalculateGearAndEngineSpeed(); calculations.CalculatePedalPositions(); diff --git a/sim/src/components/Algorithm_Longitudinal/src/longCalcs.cpp b/sim/src/components/Algorithm_Longitudinal/src/longCalcs.cpp index 755ca9d5ac10b87624564a6fc747ddbf86a3b71e..39f52407f1a642bbeeeca68f92723d4ea2b61536 100644 --- a/sim/src/components/Algorithm_Longitudinal/src/longCalcs.cpp +++ b/sim/src/components/Algorithm_Longitudinal/src/longCalcs.cpp @@ -20,10 +20,14 @@ #include <map> #include <iostream> #include "longCalcs.h" +#include "common/commonTools.h" +#include "components/common/vehicleProperties.h" AlgorithmLongitudinalCalculations::AlgorithmLongitudinalCalculations(double xVel, double in_aVehicle, - const VehicleModelParameters &vehicleModelParameters) : + const VehicleModelParameters &vehicleModelParameters, + std::function<void (CbkLogLevel, const char*, int, const std::string&)> Log) : + Log(Log), velocity(xVel), accelerationWish(in_aVehicle), vehicleModelParameters(vehicleModelParameters) @@ -57,20 +61,27 @@ double AlgorithmLongitudinalCalculations::GetEngineTorqueAtGear(int gear, double return 0; } - if (gear > vehicleModelParameters.numberOfGears || gear < 0) + if (gear > GetVehicleProperty(vehicle::properties::NumberOfGears) || gear < 0) { throw std::runtime_error("Gear in AlgorithmLongitudinal is invalid"); } - double wheelSetTorque = vehicleModelParameters.weight * vehicleModelParameters.staticWheelRadius * acceleration; - double engineTorqueAtGear = wheelSetTorque / (vehicleModelParameters.axleRatio * vehicleModelParameters.gearRatios.at(gear)); + double wheelSetTorque = GetVehicleProperty(vehicle::properties::Mass) * 0.5 * vehicleModelParameters.rearAxle.wheelDiameter * acceleration; + double engineTorqueAtGear = wheelSetTorque / (GetVehicleProperty(vehicle::properties::AxleRatio) * GetVehicleProperty(vehicle::properties::GearRatio+std::to_string(gear))); return engineTorqueAtGear; } +double AlgorithmLongitudinalCalculations::GetVehicleProperty(const std::string& propertyName) +{ + const auto property = helper::map::query(vehicleModelParameters.properties, propertyName); + THROWIFFALSE(property.has_value(), "Vehicle property \"" + propertyName + "\" was not set in the VehicleCatalog"); + return property.value(); +} + double AlgorithmLongitudinalCalculations::GetEngineSpeedByVelocity(double xVel, int gear) { - return (xVel * vehicleModelParameters.axleRatio * vehicleModelParameters.gearRatios.at(gear) * 60) / (vehicleModelParameters.staticWheelRadius * 2.0 * M_PI); // an dynamic wheel radius rDyn must actually be used here + return (xVel * GetVehicleProperty(vehicle::properties::AxleRatio) * GetVehicleProperty(vehicle::properties::GearRatio+std::to_string(gear)) * 60) / (vehicleModelParameters.rearAxle.wheelDiameter * M_PI); // an dynamic wheel radius rDyn must actually be used here } void AlgorithmLongitudinalCalculations::CalculateGearAndEngineSpeed() @@ -78,7 +89,8 @@ void AlgorithmLongitudinalCalculations::CalculateGearAndEngineSpeed() std::map<double, int> nEngineSet; std::map<double, std::tuple<int, double, double>> minDeltaAccWheelBased; - for (int gear = 1; gear <= vehicleModelParameters.numberOfGears; ++gear) + const auto numberOfGears = GetVehicleProperty(vehicle::properties::NumberOfGears); + for (int gear = 1; gear <= numberOfGears; ++gear) { double engineSpeed = GetEngineSpeedByVelocity(velocity, gear); double limitWheelAcc; @@ -160,35 +172,39 @@ bool AlgorithmLongitudinalCalculations::isTorqueWithinEngineLimits(double torque inline bool AlgorithmLongitudinalCalculations::isEngineSpeedWithinEngineLimits(double engineSpeed) { - return (engineSpeed >= vehicleModelParameters.minimumEngineSpeed && engineSpeed <= vehicleModelParameters.maximumEngineSpeed); + return (engineSpeed >= GetVehicleProperty(vehicle::properties::MinimumEngineSpeed) && engineSpeed <= GetVehicleProperty(vehicle::properties::MaximumEngineSpeed)); } double AlgorithmLongitudinalCalculations::GetEngineTorqueMax(double engineSpeed) { - double torqueMax = vehicleModelParameters.maximumEngineTorque; // initial value at max + const double maximumEngineTorque = GetVehicleProperty(vehicle::properties::MaximumEngineTorque); + const double maximumEngineSpeed = GetVehicleProperty(vehicle::properties::MaximumEngineSpeed); + const double minimumEngineSpeed = GetVehicleProperty(vehicle::properties::MinimumEngineSpeed); + + double torqueMax = maximumEngineTorque; // initial value at max double speed = engineSpeed; - bool isLowerSection = engineSpeed < vehicleModelParameters.minimumEngineSpeed + 1000; - bool isBeyondLowerSectionBorder = engineSpeed < vehicleModelParameters.minimumEngineSpeed; - bool isUpperSection = engineSpeed > vehicleModelParameters.maximumEngineSpeed - 1000; - bool isBeyondUpperSectionBorder = engineSpeed > vehicleModelParameters.maximumEngineSpeed; + bool isLowerSection = engineSpeed < minimumEngineSpeed + 1000; + bool isBeyondLowerSectionBorder = engineSpeed < minimumEngineSpeed; + bool isUpperSection = engineSpeed > maximumEngineSpeed - 1000; + bool isBeyondUpperSectionBorder = engineSpeed > maximumEngineSpeed; if (isLowerSection) { if (isBeyondLowerSectionBorder) // not within limits { - speed = vehicleModelParameters.minimumEngineSpeed; + speed = minimumEngineSpeed; } - torqueMax = (1000 - (speed - vehicleModelParameters.minimumEngineSpeed)) * -0.1 + vehicleModelParameters.maximumEngineTorque; + torqueMax = (1000 - (speed - minimumEngineSpeed)) * -0.1 + maximumEngineTorque; } else if (isUpperSection) { if (isBeyondUpperSectionBorder) { - speed = vehicleModelParameters.maximumEngineSpeed; + speed = maximumEngineSpeed; } - torqueMax = (speed - vehicleModelParameters.maximumEngineSpeed + 1000) * -0.04 + vehicleModelParameters.maximumEngineTorque; + torqueMax = (speed - maximumEngineSpeed + 1000) * -0.04 + maximumEngineTorque; } return torqueMax; @@ -201,9 +217,9 @@ double AlgorithmLongitudinalCalculations::GetEngineTorqueMin(double engineSpeed) double AlgorithmLongitudinalCalculations::GetAccFromEngineTorque(double engineTorque, int chosenGear) { - double wheelSetTorque = engineTorque * (vehicleModelParameters.axleRatio * vehicleModelParameters.gearRatios.at(chosenGear)); - double wheelSetForce = wheelSetTorque / vehicleModelParameters.staticWheelRadius; - return wheelSetForce / vehicleModelParameters.weight; + double wheelSetTorque = engineTorque * (GetVehicleProperty(vehicle::properties::AxleRatio) * GetVehicleProperty(vehicle::properties::GearRatio+std::to_string(chosenGear))); + double wheelSetForce = wheelSetTorque / (0.5 * vehicleModelParameters.rearAxle.wheelDiameter); + return wheelSetForce / GetVehicleProperty(vehicle::properties::Mass); } void AlgorithmLongitudinalCalculations::CalculatePedalPositions() diff --git a/sim/src/components/Algorithm_Longitudinal/src/longCalcs.h b/sim/src/components/Algorithm_Longitudinal/src/longCalcs.h index 7dae8058aa920598edb26ed411d18535070cf258..af19045232e1437859bc9734a80f81ad8c1dabce 100644 --- a/sim/src/components/Algorithm_Longitudinal/src/longCalcs.h +++ b/sim/src/components/Algorithm_Longitudinal/src/longCalcs.h @@ -22,8 +22,10 @@ #include "common/opMath.h" #include <vector> +#include <functional> #include "common/globalDefinitions.h" +#include "include/callbackInterface.h" //! \brief This class does all the calculations in the Algorithm_Longitudinal module. //! @@ -43,7 +45,7 @@ public: //! \param accelerationWish desired acceleration (can be negative) //! \param vehicleModelParameters parameters of the vehicle model //! - AlgorithmLongitudinalCalculations(double velocity, double accelerationWish, const VehicleModelParameters &vehicleModelParameters); + AlgorithmLongitudinalCalculations(double velocity, double accelerationWish, const VehicleModelParameters &vehicleModelParameters, std::function<void (CbkLogLevel, const char*, int, const std::string &)> Log); //! //! \brief Calculates the necessary gear and engine to achieve the desired acceleration at the current velocity @@ -109,6 +111,10 @@ public: double GetEngineTorqueAtGear(int gear, double acceleration); protected: + double GetVehicleProperty(const std::string& propertyName); + + std::function<void (CbkLogLevel, const char*, int, const std::string &)> Log; + //Input double velocity{0.0}; double accelerationWish{0.0}; diff --git a/sim/src/components/Dynamics_Collision/src/collisionImpl.cpp b/sim/src/components/Dynamics_Collision/src/collisionImpl.cpp index 3d683271cab25f362d91de2c4f6597ca1d4a9639..c9f4d73c392df2ef7dce6e2edc8924d373932eb5 100644 --- a/sim/src/components/Dynamics_Collision/src/collisionImpl.cpp +++ b/sim/src/components/Dynamics_Collision/src/collisionImpl.cpp @@ -19,6 +19,7 @@ #include "collisionImpl.h" #include "include/worldInterface.h" +#include "components/common/vehicleProperties.h" DynamicsCollisionImplementation::DynamicsCollisionImplementation(std::string componentName, bool isInit, @@ -93,10 +94,12 @@ void DynamicsCollisionImplementation::Trigger(int time) bool collisionWithFixedObject = false; //Calculate new velocity by inelastic collision - const double &agentWeight = GetAgent()->GetVehicleModelParameters().weight; - double sumOfWeights = agentWeight; - double sumOfImpulsesX = GetAgent()->GetVelocity() * agentWeight * std::cos(GetAgent()->GetYaw()); - double sumOfImpulsesY = GetAgent()->GetVelocity() * agentWeight * std::sin(GetAgent()->GetYaw()); + auto weight = helper::map::query(GetAgent()->GetVehicleModelParameters().properties, vehicle::properties::Mass); + THROWIFFALSE(weight.has_value(), "Mass was not defined in VehicleCatalog"); + + double sumOfWeights = weight.value(); + double sumOfImpulsesX = GetAgent()->GetVelocity() * weight.value() * std::cos(GetAgent()->GetYaw()); + double sumOfImpulsesY = GetAgent()->GetVelocity() * weight.value() * std::sin(GetAgent()->GetYaw()); auto collisionPartners = GetAgent()->GetCollisionPartners(); for (const auto &partner : collisionPartners) @@ -109,11 +112,12 @@ void DynamicsCollisionImplementation::Trigger(int time) const AgentInterface* partnerAgent = GetWorld()->GetAgent(partner.second); if (partnerAgent != nullptr) { - const double &partnerAgentWeight = partnerAgent->GetVehicleModelParameters().weight; + weight = helper::map::query(partnerAgent->GetVehicleModelParameters().properties, vehicle::properties::Mass); + THROWIFFALSE(weight.has_value(), "Mass was not defined in VehicleCatalog"); - sumOfWeights += partnerAgentWeight; - sumOfImpulsesX += partnerAgent->GetVelocity() * partnerAgentWeight * std::cos(partnerAgent->GetYaw()); - sumOfImpulsesY += partnerAgent->GetVelocity() * partnerAgentWeight * std::sin(partnerAgent->GetYaw()); + sumOfWeights += weight.value(); + sumOfImpulsesX += partnerAgent->GetVelocity() * weight.value() * std::cos(partnerAgent->GetYaw()); + sumOfImpulsesY += partnerAgent->GetVelocity() * weight.value() * std::sin(partnerAgent->GetYaw()); } } diff --git a/sim/src/components/Dynamics_RegularDriving/src/regularDriving.cpp b/sim/src/components/Dynamics_RegularDriving/src/regularDriving.cpp index 2ebd7de8ad54792f4f453a53665fb29356145459..be0feedc96eac7924868a4ffed30f9ded0109ed7 100644 --- a/sim/src/components/Dynamics_RegularDriving/src/regularDriving.cpp +++ b/sim/src/components/Dynamics_RegularDriving/src/regularDriving.cpp @@ -29,6 +29,8 @@ #include "common/opMath.h" #include "common/parametersVehicleSignal.h" #include "common/steeringSignal.h" +#include "common/rollSignal.h" +#include "components/common/vehicleProperties.h" #include "include/worldInterface.h" void DynamicsRegularDrivingImplementation::UpdateInput(int localLinkId, const std::shared_ptr<SignalInterface const> &data, int time) @@ -69,6 +71,21 @@ void DynamicsRegularDrivingImplementation::UpdateInput(int localLinkId, const st in_steeringWheelAngle = signal->steeringWheelAngle; } } + else if (localLinkId == 2) + { + const std::shared_ptr<ComponentStateSignalInterface const> stateSignal = std::dynamic_pointer_cast<ComponentStateSignalInterface const>(data); + if(stateSignal->componentState == ComponentState::Acting) + { + const std::shared_ptr<RollSignal const> signal = std::dynamic_pointer_cast<RollSignal const>(data); + if (!signal) + { + const std::string msg = COMPONENTNAME + " invalid signaltype"; + LOG(CbkLogLevel::Debug, msg); + throw std::runtime_error(msg); + } + dynamicsSignal.roll = signal->rollAngle; + } + } else if (localLinkId == 100) { // from ParametersAgent @@ -116,7 +133,7 @@ void DynamicsRegularDrivingImplementation::UpdateOutput(int localLinkId, std::sh void DynamicsRegularDrivingImplementation::ApplyGearLimit() { - in_gear = std::min(std::max(in_gear, 0), static_cast<int>(vehicleModelParameters.numberOfGears)); + in_gear = std::min(std::max(in_gear, 1), static_cast<int>(GetVehicleProperty(vehicle::properties::NumberOfGears))); } void DynamicsRegularDrivingImplementation::ApplyPedalPositionLimits() @@ -127,37 +144,41 @@ void DynamicsRegularDrivingImplementation::ApplyPedalPositionLimits() double DynamicsRegularDrivingImplementation::GetEngineSpeedByVelocity(double xVel, int gear) { - return (xVel * vehicleModelParameters.axleRatio * vehicleModelParameters.gearRatios.at(gear) * 60.) / - (vehicleModelParameters.staticWheelRadius * _twoPi); // an dynamic wheel radius rDyn must actually be used here + return (xVel * GetVehicleProperty(vehicle::properties::AxleRatio) * GetVehicleProperty(vehicle::properties::GearRatio+std::to_string(gear)) * 60.) / + (vehicleModelParameters.rearAxle.wheelDiameter * M_PI); // an dynamic wheel radius rDyn must actually be used here } double DynamicsRegularDrivingImplementation::GetEngineMomentMax(double engineSpeed) { - double torqueMax = vehicleModelParameters.maximumEngineTorque; // initial value at max + const double maximumEngineTorque = GetVehicleProperty(vehicle::properties::MaximumEngineTorque); + const double maximumEngineSpeed = GetVehicleProperty(vehicle::properties::MaximumEngineSpeed); + const double minimumEngineSpeed = GetVehicleProperty(vehicle::properties::MinimumEngineSpeed); + + double torqueMax = maximumEngineTorque; // initial value at max double speed = engineSpeed; - bool isLowerSection = engineSpeed < vehicleModelParameters.minimumEngineSpeed + 1000.; - bool isBeyondLowerSectionBorder = engineSpeed<vehicleModelParameters.minimumEngineSpeed; - bool isUpperSection = engineSpeed>vehicleModelParameters.maximumEngineSpeed - 1000.; - bool isBeyondUpperSectionBorder = engineSpeed>vehicleModelParameters.maximumEngineSpeed; + bool isLowerSection = engineSpeed < minimumEngineSpeed + 1000.; + bool isBeyondLowerSectionBorder = engineSpeed < minimumEngineSpeed; + bool isUpperSection = engineSpeed > maximumEngineSpeed - 1000.; + bool isBeyondUpperSectionBorder = engineSpeed > maximumEngineSpeed; if (isLowerSection) { if (isBeyondLowerSectionBorder) // not within limits { - speed = vehicleModelParameters.minimumEngineSpeed; + speed = minimumEngineSpeed; } - torqueMax = (1000 - (speed - vehicleModelParameters.minimumEngineSpeed)) * -0.1 + vehicleModelParameters.maximumEngineTorque; + torqueMax = (1000 - (speed - minimumEngineSpeed)) * -0.1 + maximumEngineTorque; } else if (isUpperSection) { if (isBeyondUpperSectionBorder) { - speed = vehicleModelParameters.maximumEngineSpeed; + speed = maximumEngineSpeed; } - torqueMax = (speed - vehicleModelParameters.maximumEngineSpeed + 1000) * -0.04 + vehicleModelParameters.maximumEngineTorque; + torqueMax = (speed - maximumEngineSpeed + 1000) * -0.04 + maximumEngineTorque; } return torqueMax; } @@ -171,9 +192,9 @@ double DynamicsRegularDrivingImplementation::GetAccelerationFromRollingResistanc double DynamicsRegularDrivingImplementation::GetAccelerationFromAirResistance(double velocity) { - double forceAirResistance = -.5 * _rho * vehicleModelParameters.airDragCoefficient * - vehicleModelParameters.frontSurface * velocity * velocity; - double accDueToAirResistance = forceAirResistance / vehicleModelParameters.weight; + double forceAirResistance = -.5 * _rho * GetVehicleProperty(vehicle::properties::AirDragCoefficient) * + GetVehicleProperty(vehicle::properties::FrontSurface) * velocity * velocity; + double accDueToAirResistance = forceAirResistance / GetVehicleProperty(vehicle::properties::Mass); return accDueToAirResistance; } @@ -184,7 +205,14 @@ double DynamicsRegularDrivingImplementation::GetEngineMomentMin(double engineSpe double DynamicsRegularDrivingImplementation::GetFrictionCoefficient() { - return GetWorld()->GetFriction() * vehicleModelParameters.frictionCoeff; + return GetWorld()->GetFriction() * GetVehicleProperty(vehicle::properties::FrictionCoefficient); +} + +double DynamicsRegularDrivingImplementation::GetVehicleProperty(const std::string& propertyName) +{ + const auto property = helper::map::query(vehicleModelParameters.properties, propertyName); + THROWIFFALSE(property.has_value(), "Vehicle property \"" + propertyName + "\" was not set in the VehicleCatalog"); + return property.value(); } double DynamicsRegularDrivingImplementation::GetEngineMoment(double gasPedalPos, int gear) @@ -210,11 +238,11 @@ double DynamicsRegularDrivingImplementation::GetAccFromEngineMoment(double xVel, Q_UNUSED(xVel); Q_UNUSED(cycleTime); - double wheelSetMoment = engineMoment * (vehicleModelParameters.axleRatio * vehicleModelParameters.gearRatios.at(chosenGear)); - double wheelSetForce = wheelSetMoment / vehicleModelParameters.staticWheelRadius; + double wheelSetMoment = engineMoment * (GetVehicleProperty(vehicle::properties::AxleRatio) * GetVehicleProperty(vehicle::properties::GearRatio+std::to_string(chosenGear))); + double wheelSetForce = wheelSetMoment / (0.5 * vehicleModelParameters.rearAxle.wheelDiameter); double vehicleSetForce = wheelSetForce; - double acc = vehicleSetForce / (vehicleModelParameters.weight); + double acc = vehicleSetForce / GetVehicleProperty(vehicle::properties::Mass); return acc; } @@ -295,15 +323,12 @@ void DynamicsRegularDrivingImplementation::Trigger(int time) dynamicsSignal.travelDistance = ds; // convert steering wheel angle to steering angle of front wheels [radian] - const auto steeringWheelAngle = std::clamp(in_steeringWheelAngle, - -vehicleModelParameters.maximumSteeringWheelAngleAmplitude, - vehicleModelParameters.maximumSteeringWheelAngleAmplitude); - dynamicsSignal.steeringWheelAngle = steeringWheelAngle; - - const auto steering_angle = steeringWheelAngle / vehicleModelParameters.steeringRatio; + const auto steering_angle = std::clamp(-vehicleModelParameters.frontAxle.maxSteering, in_steeringWheelAngle / GetVehicleProperty(vehicle::properties::SteeringRatio), vehicleModelParameters.frontAxle.maxSteering); + dynamicsSignal.steeringWheelAngle = steering_angle * GetVehicleProperty(vehicle::properties::SteeringRatio) ; GetPublisher()->Publish("SteeringAngle", steering_angle); + const double wheelbase = vehicleModelParameters.frontAxle.positionX - vehicleModelParameters.rearAxle.positionX; // calculate curvature (Ackermann model; reference point of yawing = rear axle!) [radian] - double steeringCurvature = std::tan(steering_angle) / vehicleModelParameters.wheelbase; + double steeringCurvature = std::tan(steering_angle) / wheelbase; // change of yaw angle due to ds and curvature [radian] double dpsi = std::atan(steeringCurvature*ds); dynamicsSignal.yawRate = dpsi / (GetCycleTime() * 0.001); diff --git a/sim/src/components/Dynamics_RegularDriving/src/regularDriving.h b/sim/src/components/Dynamics_RegularDriving/src/regularDriving.h index 728613bf42cea776f35c233b5f341f96c87dedf5..63f7e3ed88dfbe156f0baf0faefcc1fdd65ddf11 100644 --- a/sim/src/components/Dynamics_RegularDriving/src/regularDriving.h +++ b/sim/src/components/Dynamics_RegularDriving/src/regularDriving.h @@ -256,7 +256,9 @@ private: //! @return friction coefficient (currently ALWAYS 1) double GetFrictionCoefficient(); - + //! Returns the property with given name in the VehicleModelParameters + //! or throws an error if the property is missing + double GetVehicleProperty(const std::string& propertyName); /** @name Private Variables * @{ diff --git a/sim/src/components/Dynamics_RegularTwoTrack/src/dynamics_regularTwoTrackImpl.cpp b/sim/src/components/Dynamics_RegularTwoTrack/src/dynamics_regularTwoTrackImpl.cpp index 6105881e0457e06e8771cfde8041a6bf339ea83f..aee24c6cd6358d3ce368bced8696a9da13c0ce92 100644 --- a/sim/src/components/Dynamics_RegularTwoTrack/src/dynamics_regularTwoTrackImpl.cpp +++ b/sim/src/components/Dynamics_RegularTwoTrack/src/dynamics_regularTwoTrackImpl.cpp @@ -51,6 +51,8 @@ #include "common/steeringSignal.h" #include "common/parametersVehicleSignal.h" #include "common/globalDefinitions.h" +#include "common/commonTools.h" +#include "components/common/vehicleProperties.h" DynamicsRegularTwoTrackImplementation::~DynamicsRegularTwoTrackImplementation() { @@ -227,6 +229,18 @@ void DynamicsRegularTwoTrackImplementation::Trigger(int time) NextStateSet(); } +double DynamicsRegularTwoTrackImplementation::GetWheelbase() const +{ + return GetAgent()->GetVehicleModelParameters().frontAxle.positionX - GetAgent()->GetVehicleModelParameters().rearAxle.positionX; +} + +double DynamicsRegularTwoTrackImplementation::GetWeight() const +{ + const auto weight = helper::map::query(GetAgent()->GetVehicleModelParameters().properties, vehicle::properties::Mass); + THROWIFFALSE(weight.has_value(), "Mass was not defined in VehicleCatalog"); + return weight.value(); +} + void DynamicsRegularTwoTrackImplementation::Init() { std::map<std::string, double> parameterMapDoubleExternal = GetParameters()->GetParametersDouble(); @@ -248,7 +262,7 @@ void DynamicsRegularTwoTrackImplementation::Init() * - power * - maximum brake torque */ - vehicle->InitSetEngine(GetAgent()->GetVehicleModelParameters().weight, powerEngineMax.GetValue(), torqueBrakeMin.GetValue()); + vehicle->InitSetEngine(GetWeight(), powerEngineMax.GetValue(), torqueBrakeMin.GetValue()); /** @addtogroup init_tt * Define vehicle's geometry: @@ -257,8 +271,8 @@ void DynamicsRegularTwoTrackImplementation::Init() * - set the wheelbase * - set the track width */ - vehicle->InitSetGeometry(GetAgent()->GetVehicleModelParameters().wheelbase, 0.0, - GetAgent()->GetVehicleModelParameters().trackwidth, 0.0); + vehicle->InitSetGeometry(GetWheelbase(), 0.0, + GetAgent()->GetVehicleModelParameters().rearAxle.trackWidth, 0.0); /** @addtogroup init_tt * Define vehicle's tire properties: @@ -269,9 +283,13 @@ void DynamicsRegularTwoTrackImplementation::Init() * - set the radius of the tire * - set the road/tire friction coefficient */ + + const auto frictionCoeff = helper::map::query(GetAgent()->GetVehicleModelParameters().properties, vehicle::properties::FrictionCoefficient); + THROWIFFALSE(frictionCoeff.has_value(), "FrictionCoefficient was not defined in VehicleCatalog"); + vehicle->InitSetTire(GetAgent()->GetVelocity(VelocityScope::Longitudinal), muTireMax.GetValue(), muTireSlide.GetValue(), - slipTireMax.GetValue(), radiusTire.GetValue(), GetAgent()->GetVehicleModelParameters().frictionCoeff); + slipTireMax.GetValue(), radiusTire.GetValue(), frictionCoeff.value()); forceWheelVertical = { vehicle->forceTireVerticalStatic[0], @@ -292,8 +310,9 @@ void DynamicsRegularTwoTrackImplementation::ReadPreviousState() double midRearAxleY = GetAgent()->GetPositionY(); // reference point (rear axle) in global CS yawAngle = GetAgent()->GetYaw(); // global CS - positionCar.x = midRearAxleX + std::cos(yawAngle) * GetAgent()->GetVehicleModelParameters().wheelbase / 2.0; // geometrical center of vehicle in global CS - positionCar.y = midRearAxleY + std::sin(yawAngle) * GetAgent()->GetVehicleModelParameters().wheelbase / 2.0; // geometrical center of vehicle in global CS + const double wheelbase = GetWheelbase(); + positionCar.x = midRearAxleX + std::cos(yawAngle) * wheelbase / 2.0; // geometrical center of vehicle in global CS + positionCar.y = midRearAxleY + std::sin(yawAngle) * wheelbase / 2.0; // geometrical center of vehicle in global CS velocityCar.x = GetAgent()->GetVelocity(VelocityScope::Longitudinal); // car's CS velocityCar.y = GetAgent()->GetVelocity(VelocityScope::Lateral); // car's CS @@ -315,8 +334,9 @@ void DynamicsRegularTwoTrackImplementation::NextStateTranslation() Common::Vector2d velocityCarNew = velocityCar + accelerationCar*timeStep; // update acceleration - if (GetAgent()->GetVehicleModelParameters().weight >= 1.0) { - accelerationCar = vehicle->forceTotalXY * (1 / GetAgent()->GetVehicleModelParameters().weight); + const double weight = GetWeight(); + if (weight >= 1.0) { + accelerationCar = vehicle->forceTotalXY * (1 / weight); } // correct velocity and acceleration for zero-crossing @@ -355,7 +375,7 @@ void DynamicsRegularTwoTrackImplementation::NextStateRotation() double yawVelocityNew = yawVelocity + yawAcceleration * timeStep; // update acceleration - double momentInertiaYaw = CommonHelper::CalculateMomentInertiaYaw(GetAgent()->GetVehicleModelParameters().weight, + double momentInertiaYaw = CommonHelper::CalculateMomentInertiaYaw(GetWeight(), GetAgent()->GetLength(), GetAgent()->GetWidth()); if (momentInertiaYaw >= 1.0) { @@ -380,8 +400,9 @@ void DynamicsRegularTwoTrackImplementation::NextStateRotation() void DynamicsRegularTwoTrackImplementation::NextStateSet() { - double midRearAxleX = positionCar.x - std::cos(yawAngle) * GetAgent()->GetVehicleModelParameters().wheelbase / 2.0; // reference point (rear axle) in global CS - double midRearAxleY = positionCar.y - std::sin(yawAngle) * GetAgent()->GetVehicleModelParameters().wheelbase / 2.0; // reference point (rear axle) in global CS + const double wheelbase = GetWheelbase(); + double midRearAxleX = positionCar.x - std::cos(yawAngle) * wheelbase / 2.0; // reference point (rear axle) in global CS + double midRearAxleY = positionCar.y - std::sin(yawAngle) * wheelbase / 2.0; // reference point (rear axle) in global CS // update position (constant acceleration step) dynamicsSignal.acceleration = accelerationCar.x; diff --git a/sim/src/components/Dynamics_RegularTwoTrack/src/dynamics_regularTwoTrackImpl.h b/sim/src/components/Dynamics_RegularTwoTrack/src/dynamics_regularTwoTrackImpl.h index 710e7ded1693ebb46ac704d71baa090c6941ac20..2afcb79e517a8f8fb4553802bfcf5fdc58881d7d 100644 --- a/sim/src/components/Dynamics_RegularTwoTrack/src/dynamics_regularTwoTrackImpl.h +++ b/sim/src/components/Dynamics_RegularTwoTrack/src/dynamics_regularTwoTrackImpl.h @@ -213,6 +213,12 @@ private: /** * @} */ + //! Returns the wheelbase from the VehicleModelParameter + double GetWheelbase() const; + + //! Returns the weight from the VehicleModelParameter + double GetWeight() const; + //! Update data on agent's actual position, velocity and acceleration void ReadPreviousState(); diff --git a/sim/src/components/LimiterAccVehComp/src/limiterAccVehCompImpl.cpp b/sim/src/components/LimiterAccVehComp/src/limiterAccVehCompImpl.cpp index 1d8926f038105e8499bdbd972f7d4659a081dc2f..13f55a09e93fc65cc024821b2782fc9418fee127 100644 --- a/sim/src/components/LimiterAccVehComp/src/limiterAccVehCompImpl.cpp +++ b/sim/src/components/LimiterAccVehComp/src/limiterAccVehCompImpl.cpp @@ -18,6 +18,7 @@ #include <qglobal.h> #include "include/worldInterface.h" +#include "components/common/vehicleProperties.h" #include "limiterAccVehCompImpl.h" @@ -99,6 +100,13 @@ void LimiterAccelerationVehicleComponentsImplementation::Trigger(int time) outgoingAcceleration = std::max(std::min(incomingAcceleration, accelerationLimit), decelerationLimit); } +double LimiterAccelerationVehicleComponentsImplementation::GetVehicleProperty(const std::string& propertyName) +{ + const auto property = helper::map::query(vehicleModelParameters.properties, propertyName); + THROWIFFALSE(property.has_value(), "Vehicle property \"" + propertyName + "\" was not set in the VehicleCatalog"); + return property.value(); +} + double LimiterAccelerationVehicleComponentsImplementation::InterpolateEngineTorqueBasedOnSpeed(const double &engineSpeed) { if(engineSpeedReferences.size() != engineTorqueReferences.size() || engineSpeedReferences.empty()) @@ -138,23 +146,23 @@ std::vector<double> LimiterAccelerationVehicleComponentsImplementation::PrepareE { std::vector<double> engineTorquesBasedOnGearRatios {}; - if(vehicleModelParameters.gearRatios.size() < 2) + if(GetVehicleProperty(vehicle::properties::NumberOfGears) < 1) { throw std::runtime_error("At least on gear is required!"); } - for(size_t i = 1; i < vehicleModelParameters.gearRatios.size(); i++) + for(size_t i = 1; i <= GetVehicleProperty(vehicle::properties::NumberOfGears); i++) { const double engineSpeedBasedOnGear = CalculateEngineSpeedBasedOnGear(GetAgent()->GetVelocity(), i); - if(engineSpeedBasedOnGear > vehicleModelParameters.maximumEngineSpeed || engineSpeedBasedOnGear < vehicleModelParameters.minimumEngineSpeed) + if(engineSpeedBasedOnGear > GetVehicleProperty(vehicle::properties::MaximumEngineSpeed) || engineSpeedBasedOnGear < GetVehicleProperty(vehicle::properties::MinimumEngineSpeed)) { continue; } const double interpolatedEngineTorque = InterpolateEngineTorqueBasedOnSpeed(engineSpeedBasedOnGear); - double engineTorqueBasedOnGearRatio = interpolatedEngineTorque * vehicleModelParameters.gearRatios.at(i); + double engineTorqueBasedOnGearRatio = interpolatedEngineTorque * GetVehicleProperty(vehicle::properties::GearRatio+std::to_string(i)); engineTorquesBasedOnGearRatios.push_back(engineTorqueBasedOnGearRatio); } @@ -163,15 +171,15 @@ std::vector<double> LimiterAccelerationVehicleComponentsImplementation::PrepareE double LimiterAccelerationVehicleComponentsImplementation::CalculateEngineSpeedBasedOnGear(const double ¤tVelocity, const size_t &gear) { - const double engineSpeed = currentVelocity * vehicleModelParameters.axleRatio * vehicleModelParameters.gearRatios.at(gear) / (twoPI * vehicleModelParameters.staticWheelRadius) * 60.0; + const double engineSpeed = currentVelocity * GetVehicleProperty(vehicle::properties::AxleRatio) * GetVehicleProperty(vehicle::properties::GearRatio+std::to_string(gear)) / (M_PI * vehicleModelParameters.rearAxle.wheelDiameter) * 60.0; return engineSpeed; } void LimiterAccelerationVehicleComponentsImplementation::PrepareReferences() { - const double& maxEngineTorque = vehicleModelParameters.maximumEngineTorque; - const double& maxEngineSpeed = vehicleModelParameters.maximumEngineSpeed; - const double& minEngineSpeed = vehicleModelParameters.minimumEngineSpeed; + const double& maxEngineTorque = GetVehicleProperty(vehicle::properties::MaximumEngineTorque); + const double& maxEngineSpeed = GetVehicleProperty(vehicle::properties::MaximumEngineSpeed); + const double& minEngineSpeed = GetVehicleProperty(vehicle::properties::MinimumEngineSpeed); engineTorqueReferences = {0.5 * maxEngineTorque, 1.0 * maxEngineTorque, @@ -199,18 +207,18 @@ double LimiterAccelerationVehicleComponentsImplementation::CalculateAcceleration const double &engineTorqueBasedOnVelocity = *(std::max_element(engineTorquesBasedOnGearRatios.begin(), engineTorquesBasedOnGearRatios.end())); - const double forceAtWheel = engineTorqueBasedOnVelocity * vehicleModelParameters.axleRatio / vehicleModelParameters.staticWheelRadius; - const double forceRoll = vehicleModelParameters.weight * oneG * rollFrictionCoefficient; - const double forceAir = (airResistance / 2) * vehicleModelParameters.frontSurface * vehicleModelParameters.airDragCoefficient * std::pow(currentVelocity, 2); + const double forceAtWheel = engineTorqueBasedOnVelocity * GetVehicleProperty(vehicle::properties::AxleRatio) / (0.5 * vehicleModelParameters.rearAxle.wheelDiameter); + const double forceRoll = GetVehicleProperty(vehicle::properties::Mass) * oneG * rollFrictionCoefficient; + const double forceAir = (airResistance / 2) * GetVehicleProperty(vehicle::properties::FrontSurface) * GetVehicleProperty(vehicle::properties::AirDragCoefficient) * std::pow(currentVelocity, 2); - const double accelerationLimit = (forceAtWheel - forceRoll - forceAir) / vehicleModelParameters.weight; + const double accelerationLimit = (forceAtWheel - forceRoll - forceAir) / GetVehicleProperty(vehicle::properties::Mass); return accelerationLimit; } double LimiterAccelerationVehicleComponentsImplementation::CalculateDecelerationLimit() { - const double decelerationLimit = GetWorld()->GetFriction() * vehicleModelParameters.frictionCoeff * (-oneG); + const double decelerationLimit = GetWorld()->GetFriction() * GetVehicleProperty(vehicle::properties::FrictionCoefficient) * (-oneG); return decelerationLimit; } diff --git a/sim/src/components/LimiterAccVehComp/src/limiterAccVehCompImpl.h b/sim/src/components/LimiterAccVehComp/src/limiterAccVehCompImpl.h index 84ca1eef89b7d26c8ae6d10b918533814b6c3d86..54130f6cf1d8d48e6ff144ecd97a0b01785bd061 100644 --- a/sim/src/components/LimiterAccVehComp/src/limiterAccVehCompImpl.h +++ b/sim/src/components/LimiterAccVehComp/src/limiterAccVehCompImpl.h @@ -104,6 +104,8 @@ public: virtual void Trigger(int time); private: + double GetVehicleProperty(const std::string& propertyName); + double InterpolateEngineTorqueBasedOnSpeed(const double &engineSpeed); std::vector<double> PrepareEngineTorqueVectorBasedOnGearRatios(); diff --git a/sim/src/components/common/vehicleProperties.h b/sim/src/components/common/vehicleProperties.h new file mode 100644 index 0000000000000000000000000000000000000000..9424670d23d6712a2496edaf4b05cb28a0151435 --- /dev/null +++ b/sim/src/components/common/vehicleProperties.h @@ -0,0 +1,27 @@ +/******************************************************************************* +* Copyright (c) 2021 in-tech GmbH +* +* This program and the accompanying materials are made +* available under the terms of the Eclipse Public License 2.0 +* which is available at https://www.eclipse.org/legal/epl-2.0/ +* +* SPDX-License-Identifier: EPL-2.0 +*******************************************************************************/ + +#pragma once + +namespace vehicle::properties +{ +constexpr char AirDragCoefficient[] {"AirDragCoefficient"}; +constexpr char AxleRatio[] {"AxleRatio"}; +constexpr char DecelerationFromPowertrainDrag[] {"DecelerationFromPowertrainDrag"}; +constexpr char FrictionCoefficient[] {"FrictionCoefficient"}; +constexpr char FrontSurface[] {"FrontSurface"}; +constexpr char GearRatio[] {"GearRatio"}; +constexpr char NumberOfGears[] {"NumberOfGears"}; +constexpr char Mass[] {"Mass"}; +constexpr char MaximumEngineSpeed[] {"MaximumEngineSpeed"}; +constexpr char MaximumEngineTorque[] {"MaximumEngineTorque"}; +constexpr char MinimumEngineSpeed[] {"MinimumEngineSpeed"}; +constexpr char SteeringRatio[] {"SteeringRatio"}; +} diff --git a/sim/src/core/slave/framework/agentFactory.cpp b/sim/src/core/slave/framework/agentFactory.cpp index 1cf49c9d746ef935c9d447e567912e975e924bf4..13ea600358e530ed31699dbbba25d26cb4945de4 100644 --- a/sim/src/core/slave/framework/agentFactory.cpp +++ b/sim/src/core/slave/framework/agentFactory.cpp @@ -170,10 +170,10 @@ void AgentFactory::PublishProperties(const Agent& agent) dataStore->PutStatic(keyPrefix + "AgentType", std::string(openpass::utils::to_cstr(adapter->GetVehicleModelParameters().vehicleType))); // std::string for compatibility with gcc-9 std::ariant const auto& vehicleModelParameters = adapter->GetVehicleModelParameters(); - const double longitudinalPivotOffset = (vehicleModelParameters.length / 2.0) - vehicleModelParameters.distanceReferencePointToLeadingEdge; - dataStore->PutStatic(keyPrefix + "Vehicle/Width", vehicleModelParameters.width); - dataStore->PutStatic(keyPrefix + "Vehicle/Length", vehicleModelParameters.length); - dataStore->PutStatic(keyPrefix + "Vehicle/Height", vehicleModelParameters.height); + const double longitudinalPivotOffset = vehicleModelParameters.boundingBoxCenter.x; + dataStore->PutStatic(keyPrefix + "Vehicle/Width", vehicleModelParameters.boundingBoxDimensions.width); + dataStore->PutStatic(keyPrefix + "Vehicle/Length", vehicleModelParameters.boundingBoxDimensions.length); + dataStore->PutStatic(keyPrefix + "Vehicle/Height", vehicleModelParameters.boundingBoxDimensions.height); dataStore->PutStatic(keyPrefix + "Vehicle/LongitudinalPivotOffset", longitudinalPivotOffset); for (const auto& sensor : adapter->GetSensorParameters()) diff --git a/sim/src/core/slave/importer/importerLoggingHelper.h b/sim/src/core/slave/importer/importerLoggingHelper.h index 885fd0006cb6e36b1375ae7f399f21bf3db08e0e..4e2ad597583b08f110acab3609ec7ea3fdc9b3e5 100644 --- a/sim/src/core/slave/importer/importerLoggingHelper.h +++ b/sim/src/core/slave/importer/importerLoggingHelper.h @@ -494,11 +494,14 @@ namespace openpass::importer::xml::vehicleModelsImporter::attribute constexpr char height[] {"height"}; constexpr char length[] {"length"}; constexpr char mass[] {"mass"}; + constexpr char maxAcceleration[] {"maxAcceleration"}; + constexpr char maxDeceleration[] {"maxDeceleration"}; constexpr char maxSpeed[] {"maxSpeed"}; constexpr char maxSteering[] {"maxSteering"}; constexpr char name[] {"name"}; constexpr char pedestrianCategory[] {"pedestrianCategory"}; constexpr char positionX[] {"positionX"}; + constexpr char positionZ[] {"positionZ"}; constexpr char trackWidth[] {"trackWidth"}; constexpr char value[] {"value"}; constexpr char wheelDiameter[] {"wheelDiameter"}; diff --git a/sim/src/core/slave/importer/vehicleModelsImporter.cpp b/sim/src/core/slave/importer/vehicleModelsImporter.cpp index a4e39927d9341d38506934f94e06094701fd78be..823e195a1fbf4d0b08f0d6661b461449c0330bd2 100644 --- a/sim/src/core/slave/importer/vehicleModelsImporter.cpp +++ b/sim/src/core/slave/importer/vehicleModelsImporter.cpp @@ -104,15 +104,11 @@ void VehicleModelsImporter::ImportCatalog(const std::string& catalogPath, QDomEl void VehicleModelsImporter::CheckModelParameters(const ParametrizedVehicleModelParameters& model) { - //TODO Replace assert with ErrorMessage - assert(model.length.defaultValue > 0); - assert(model.width.defaultValue > 0); - assert(model.height.defaultValue > 0); - assert(model.rearAxle.trackWidth.defaultValue > 0); -// assert(model.wheelbase.defaultValue > 0); - assert(model.maxVelocity.defaultValue > 0); -// assert(model.maxCurvature.defaultValue > 0); - assert(model.vehicleType != AgentVehicleType::Undefined); + ThrowIfFalse(model.boundingBoxDimensions.length.defaultValue > 0, "Length must be positive"); + ThrowIfFalse(model.boundingBoxDimensions.width.defaultValue > 0, "Width must be positive"); + ThrowIfFalse(model.boundingBoxDimensions.height.defaultValue > 0, "Height must be positive"); + ThrowIfFalse(model.performance.maxSpeed.defaultValue > 0, "MaxSpeed must be positive"); + ThrowIfFalse(model.vehicleType != AgentVehicleType::Undefined, "Unknown vehicle type"); } void VehicleModelsImporter::ImportVehicleModelAxles(QDomElement& vehicleElement, @@ -136,22 +132,17 @@ void VehicleModelsImporter::ImportVehicleModelAxles(QDomElement& vehicleElement, ValidateAxles(modelParameters.frontAxle, modelParameters.rearAxle); } -void VehicleModelsImporter::ImportVehicleModelAxle(QDomElement& axleElement, VehicleAxle& axleParameters, openScenario::Parameters& parameters) +void VehicleModelsImporter::ImportVehicleModelAxle(QDomElement& axleElement, ParametrizedVehicleModelParameters::Axle& axleParameters, openScenario::Parameters& parameters) { axleParameters.wheelDiameter = ParseParametrizedAttribute<double>(axleElement, ATTRIBUTE::wheelDiameter, parameters); axleParameters.positionX = ParseParametrizedAttribute<double>(axleElement, ATTRIBUTE::positionX, parameters); + axleParameters.positionZ = ParseParametrizedAttribute<double>(axleElement, ATTRIBUTE::positionZ, parameters); axleParameters.trackWidth = ParseParametrizedAttribute<double>(axleElement, ATTRIBUTE::trackWidth, parameters); axleParameters.maxSteering = ParseParametrizedAttribute<double>(axleElement, ATTRIBUTE::maxSteering, parameters); } -void VehicleModelsImporter::ValidateAxles(const VehicleAxle& frontAxle, const VehicleAxle& rearAxle) +void VehicleModelsImporter::ValidateAxles(const ParametrizedVehicleModelParameters::Axle& frontAxle, const ParametrizedVehicleModelParameters::Axle& rearAxle) { - if (std::abs(frontAxle.wheelDiameter.defaultValue - rearAxle.wheelDiameter.defaultValue) > 1e-6) - { - LOG_INTERN(LogLevel::Warning) << - "Different wheel diameters for front and rear axle not supported. Using rear axle value."; - } - ThrowIfFalse(rearAxle.positionX.defaultValue == 0.0, "Reference point not on rear axle."); if (rearAxle.positionX.defaultValue > frontAxle.positionX.defaultValue) @@ -181,24 +172,22 @@ void VehicleModelsImporter::ImportModelBoundingBox(QDomElement& modelElement, Pa ThrowIfFalse(SimulationCommon::GetFirstChildElement(boundingBoxElement, TAG::dimensions, boundingBoxDimensionElement), boundingBoxElement, "Tag " + std::string(TAG::dimensions) + " is missing."); - auto bbCenterX = ParseParametrizedAttribute<double>(boundingBoxCenterElement, ATTRIBUTE::x, parameters); - auto bbCenterY = ParseParametrizedAttribute<double>(boundingBoxCenterElement, ATTRIBUTE::y, parameters); - auto bbCenterZ = ParseParametrizedAttribute<double>(boundingBoxCenterElement, ATTRIBUTE::z, parameters); - modelParameters.width = ParseParametrizedAttribute<double>(boundingBoxDimensionElement, ATTRIBUTE::width, parameters); - modelParameters.length = ParseParametrizedAttribute<double>(boundingBoxDimensionElement, ATTRIBUTE::length, parameters); - modelParameters.height = ParseParametrizedAttribute<double>(boundingBoxDimensionElement, ATTRIBUTE::height, parameters); + modelParameters.boundingBoxCenter.x = ParseParametrizedAttribute<double>(boundingBoxCenterElement, ATTRIBUTE::x, parameters); + modelParameters.boundingBoxCenter.y = ParseParametrizedAttribute<double>(boundingBoxCenterElement, ATTRIBUTE::y, parameters); + modelParameters.boundingBoxCenter.z = ParseParametrizedAttribute<double>(boundingBoxCenterElement, ATTRIBUTE::z, parameters); + modelParameters.boundingBoxDimensions.width = ParseParametrizedAttribute<double>(boundingBoxDimensionElement, ATTRIBUTE::width, parameters); + modelParameters.boundingBoxDimensions.length = ParseParametrizedAttribute<double>(boundingBoxDimensionElement, ATTRIBUTE::length, parameters); + modelParameters.boundingBoxDimensions.height = ParseParametrizedAttribute<double>(boundingBoxDimensionElement, ATTRIBUTE::height, parameters); - if (bbCenterY.defaultValue != 0.0) + if (modelParameters.boundingBoxCenter.y.defaultValue != 0.0) { LOG_INTERN(LogLevel::Warning) << "Model bounding box center y-coordinate != 0.0"; } - if (std::abs(bbCenterZ.defaultValue - modelParameters.height.defaultValue / 2.0) > 1e-6) + if (std::abs(modelParameters.boundingBoxCenter.z.defaultValue - modelParameters.boundingBoxDimensions.height.defaultValue / 2.0) > 1e-6) { LOG_INTERN(LogLevel::Warning) << "Model bounding box center z-coordinate is not half height"; } - - modelParameters.distanceReferencePointToLeadingEdge = bbCenterX.defaultValue + modelParameters.length.defaultValue / 2.0; } void VehicleModelsImporter::ImportVehicleModelPerformance(QDomElement& vehicleElement, @@ -209,23 +198,9 @@ void VehicleModelsImporter::ImportVehicleModelPerformance(QDomElement& vehicleEl ThrowIfFalse(SimulationCommon::GetFirstChildElement(vehicleElement, TAG::performance, performanceElement), vehicleElement, "Tag " + std::string(TAG::performance) + " is missing."); - modelParameters.maxVelocity = ParseParametrizedAttribute<double>(performanceElement, ATTRIBUTE::maxSpeed, parameters); -} - -void VehicleModelsImporter::ImportVehicleModelGears(ParametrizedVehicleModelParameters& modelParameters, - const Properties& properties) -{ - openScenario::ParameterizedAttribute<double> gearRatio; - - modelParameters.gearRatios.push_back(0.0); - - AssignProperty("NumberOfGears", modelParameters.numberOfGears, properties); - - for (int currentGear = 1; currentGear <= modelParameters.numberOfGears.defaultValue; ++currentGear) - { - AssignProperty("GearRatio" + std::to_string(currentGear), gearRatio, properties); - modelParameters.gearRatios.push_back(gearRatio); - } + modelParameters.performance.maxSpeed = ParseParametrizedAttribute<double>(performanceElement, ATTRIBUTE::maxSpeed, parameters); + modelParameters.performance.maxAcceleration = ParseParametrizedAttribute<double>(performanceElement, ATTRIBUTE::maxAcceleration, parameters); + modelParameters.performance.maxDeceleration = ParseParametrizedAttribute<double>(performanceElement, ATTRIBUTE::maxDeceleration, parameters); } void VehicleModelsImporter::ImportVehicleModel(QDomElement& vehicleElement, VehicleModelMap& vehicleModelsMap) @@ -255,32 +230,11 @@ void VehicleModelsImporter::ImportVehicleModel(QDomElement& vehicleElement, Vehi modelParameters.vehicleType == AgentVehicleType::Bicycle), vehicleElement, "VehicleModelCatagory '" + vehicleModelCategory.defaultValue + "' currently not supported"); - const auto &properties = ImportProperties(vehicleElement); - - AssignProperty("SteeringRatio", modelParameters.steeringRatio, properties, 1.0); - - AssignProperty("MomentInertiaRoll", modelParameters.momentInertiaRoll, properties, 0.0); - AssignProperty("MomentInertiaPitch", modelParameters.momentInertiaPitch, properties, 0.0); - AssignProperty("MomentInertiaYaw", modelParameters.momentInertiaYaw, properties, 0.0); - - AssignProperty("MinimumEngineSpeed", modelParameters.minimumEngineSpeed, properties, 0.0); - AssignProperty("MaximumEngineSpeed", modelParameters.maximumEngineSpeed, properties, 0.0); - AssignProperty("MaximumEngineTorque", modelParameters.maximumEngineTorque, properties, 0.0); - AssignProperty("MinimumEngineTorque", modelParameters.minimumEngineTorque, properties, 0.0); - - AssignProperty("AirDragCoefficient", modelParameters.airDragCoefficient, properties, 0.0); - AssignProperty("AxleRatio", modelParameters.axleRatio, properties, 1.0); - AssignProperty("DecelerationFromPowertrainDrag", modelParameters.decelerationFromPowertrainDrag, properties, 0.0); - AssignProperty("FrictionCoefficient", modelParameters.frictionCoeff, properties, 1.0); - AssignProperty("FrontSurface", modelParameters.frontSurface, properties, 0.0); - AssignProperty("Mass", modelParameters.weight, properties, 1000.0); + modelParameters.properties = ImportProperties(vehicleElement); ImportModelBoundingBox(vehicleElement, modelParameters, parameters); ImportVehicleModelAxles(vehicleElement, modelParameters, parameters); ImportVehicleModelPerformance(vehicleElement, modelParameters, parameters); - ImportVehicleModelGears(modelParameters, properties); - - modelParameters.heightCOG = 0.0; // currently not supported CheckModelParameters(modelParameters); @@ -301,24 +255,15 @@ void VehicleModelsImporter::ImportPedestrianModel(QDomElement& pedestrianElement ThrowIfFalse(vehicleModelsMap.find(pedestrianModelName.defaultValue) == vehicleModelsMap.end(), pedestrianElement, "pedestrian model '" + pedestrianModelName.defaultValue + "' already exists"); - + modelParameters.properties = ImportProperties(pedestrianElement); ImportModelBoundingBox(pedestrianElement, modelParameters, parameters); // Currently, AgentAdapter and Dynamics cannot handle pedestrians properly // setting some required defaults here for now for compatibility with cars modelParameters.vehicleType = AgentVehicleType::Car; - modelParameters.gearRatios.push_back(0.0); - modelParameters.gearRatios.push_back(1.0); - modelParameters.numberOfGears = 1; - modelParameters.maximumEngineTorque = 200; - modelParameters.maximumEngineSpeed = 1e5; - modelParameters.minimumEngineSpeed = 1; modelParameters.rearAxle.wheelDiameter = 1; modelParameters.rearAxle.positionX = 0; modelParameters.frontAxle.positionX = 1; - modelParameters.axleRatio = 1; - modelParameters.airDragCoefficient = 0; - modelParameters.weight = ParseParametrizedAttribute<double>(pedestrianElement, ATTRIBUTE::mass, parameters); vehicleModelsMap[pedestrianModelName.defaultValue] = modelParameters; } @@ -343,7 +288,7 @@ Properties VehicleModelsImporter::ImportProperties(QDomElement& root) ThrowIfFalse(SimulationCommon::ParseAttribute(propertyElement, ATTRIBUTE::value, value), propertyElement, "Attribute " + std::string(ATTRIBUTE::value) + " is missing."); - properties[name] = value; + properties[name] = std::stod(value); propertyElement = propertyElement.nextSiblingElement(TAG::property); } diff --git a/sim/src/core/slave/importer/vehicleModelsImporter.h b/sim/src/core/slave/importer/vehicleModelsImporter.h index c32a3625c273a713ff562c0c4ef9e0b6b9743dc7..0976899ed1fffc73efec8c51f03ca2667c5a8605 100644 --- a/sim/src/core/slave/importer/vehicleModelsImporter.h +++ b/sim/src/core/slave/importer/vehicleModelsImporter.h @@ -30,7 +30,7 @@ const std::unordered_map<std::string, AgentVehicleType> vehicleTypeConversionMap {"motorbike", AgentVehicleType::Motorbike}, {"bicycle", AgentVehicleType::Bicycle}}; -using Properties = std::map<std::string, std::string>; +using Properties = std::map<std::string, openScenario::ParameterizedAttribute<double>>; /*! * \brief Provides methods for importing vehicle models from OpenSCENARIO catalog files @@ -178,7 +178,7 @@ private: * \throw std::runtime_error On missing `Axles`, `Front` or `Rear` tag, reference point not being on rear axle or * steering defined for rear axle */ - static void ImportVehicleModelAxle(QDomElement& axleElement, VehicleAxle& axleParameters, openScenario::Parameters& parameters); + static void ImportVehicleModelAxle(QDomElement& axleElement, ParametrizedVehicleModelParameters::Axle& axleParameters, openScenario::Parameters& parameters); /*! * \brief Validates the axle parameters @@ -188,7 +188,7 @@ private: * * \throw std::runtime_error When reference point not on rear axle or rear axle steering != 0.0 */ - static void ValidateAxles(const VehicleAxle& frontAxle, const VehicleAxle& rearAxle); + static void ValidateAxles(const ParametrizedVehicleModelParameters::Axle& frontAxle, const ParametrizedVehicleModelParameters::Axle& rearAxle); /*! * \brief Imports the models' performance tag from OpenSCENARIO DOM @@ -205,18 +205,6 @@ private: */ static void ImportVehicleModelPerformance(QDomElement& vehicleElement, ParametrizedVehicleModelParameters& modelParameters, openScenario::Parameters& parameters); - /*! - * \brief Imports the models' gears from its `ParameterDeclaration` in OpenSCENARIO DOM - * - * The paramters `NumberOfGears` has to specifiy the number of gears in a model. The first entry in ParametrizedVehicleModelParameters - * `gearRatios` will always be 0.0. For every gear, a `Parameter` tag `GearRatioN` has to exist, where N represents the - * number of a gear. Ratios are imported in ascending order of the gear number. - * - * \param[out] modelParameters Storage for the imported values - * \param[in] properties openScenario properties - */ - static void ImportVehicleModelGears(ParametrizedVehicleModelParameters& modelParameters, const Properties& properties); - /*! * \brief Helper for template type deduction with std::optional parameters * @@ -228,48 +216,6 @@ private: template<typename T> struct TypeHelper { typedef T type; }; - /*! - * \brief Assigns the value of a property to a attribute - * - * \param[in] propertyName Name of the parameter to import - * \param[out] attribtue Reference to the attribute - * \param[in] properties Properties - * \param[in] defaultValue An optional default value to use if it cannot be imported - * - * \throw std::runtime_error On missing model `Parameter` tag or invalid `name` or `value` attribute. - */ - template<typename T> - static void AssignProperty(const std::string& propertyName, - openScenario::ParameterizedAttribute<T>& attribute, - const Properties& properties, - std::optional<typename TypeHelper<T>::type> defaultValue = std::nullopt) - { - auto propertyIt = properties.find(propertyName); - if (propertyIt != properties.cend()) - { - if(std::is_same<T, double>::value) - { - attribute = {propertyName, std::stod(properties.at(propertyName))}; - } - else if (std::is_same<T, int>::value) - { - attribute = {propertyName, std::stoi(properties.at(propertyName))}; - } - else - { - throw std::runtime_error("Property data type not supported."); - } - } - else if (defaultValue) - { - attribute = {propertyName, defaultValue.value()}; - } - else - { - LogErrorAndThrow("Missing parameter " + propertyName); - } - } - /*! * \brief Imports the properties of an element * diff --git a/sim/src/core/slave/modules/Manipulator/srcCollisionPostCrash/collisionDetection_Impact_implementation.cpp b/sim/src/core/slave/modules/Manipulator/srcCollisionPostCrash/collisionDetection_Impact_implementation.cpp index 27020684b01c07e64072d659c55ecaf0768ba660..31c850c38f505c2b4a5034c7a3bb2891b7a33316 100644 --- a/sim/src/core/slave/modules/Manipulator/srcCollisionPostCrash/collisionDetection_Impact_implementation.cpp +++ b/sim/src/core/slave/modules/Manipulator/srcCollisionPostCrash/collisionDetection_Impact_implementation.cpp @@ -13,6 +13,7 @@ #include <array> #include "collisionDetection_Impact_implementation.h" +#include "components/common/vehicleProperties.h" namespace { @@ -36,8 +37,9 @@ std::vector<Common::Vector2d> CollisionDetectionPostCrash::GetAgentCorners( { Common::Vector2d agentPosition(agent->GetPositionX(), agent->GetPositionY()); // reference point (rear axle) in glabal CS double agentAngle = agent->GetYaw(); - agentPosition.x = agentPosition.x + std::cos(agentAngle) * agent->GetVehicleModelParameters().wheelbase / 2.0; // geometrical center of vehicle in global CS - agentPosition.y = agentPosition.y + std::sin(agentAngle) * agent->GetVehicleModelParameters().wheelbase / 2.0; // geometrical center of vehicle in global CS + const double wheelbase = agent->GetVehicleModelParameters().frontAxle.positionX - agent->GetVehicleModelParameters().rearAxle.positionX; + agentPosition.x = agentPosition.x + std::cos(agentAngle) * wheelbase / 2.0; // geometrical center of vehicle in global CS + agentPosition.y = agentPosition.y + std::sin(agentAngle) * wheelbase / 2.0; // geometrical center of vehicle in global CS double agentLength = agent->GetLength(); double agentWidthHalf = agent->GetWidth() / 2; @@ -206,10 +208,12 @@ bool CollisionDetectionPostCrash::CalculatePostCrashDynamic(Common::Vector2d cog double velY1 = agent1->GetVelocity(VelocityScope::Lateral); // y-velocity in the local coordinate system of the agent double vel1 = sqrt( velX1 * velX1 + velY1 * velY1 ); // absolute velocity of first vehicle [m/s] double velDir1 = yaw1; // velocity direction of first vehicle [rad] - double mass1 = agent1->GetVehicleModelParameters().weight; // mass of first vehicle [kg] + const auto mass1 = helper::map::query(agent1->GetVehicleModelParameters().properties, vehicle::properties::Mass); // mass of first vehicle [kg] + THROWIFFALSE(mass1.has_value(), "Mass was not defined in VehicleCatalog"); + double length1 = agent1->GetLength(); double width1 = agent1->GetWidth(); - double momentIntertiaYaw1 = CommonHelper::CalculateMomentInertiaYaw(mass1, length1, width1); // moment of inertia 1st vehicle [kg*m^2] + double momentIntertiaYaw1 = CommonHelper::CalculateMomentInertiaYaw(mass1.value(), length1, width1); // moment of inertia 1st vehicle [kg*m^2] // input parameters of agent 2 double yaw2 = agent2->GetYaw(); // yaw angle [rad] @@ -218,10 +222,11 @@ bool CollisionDetectionPostCrash::CalculatePostCrashDynamic(Common::Vector2d cog double velY2 = agent2->GetVelocity(VelocityScope::Lateral); // y-velocity in the local coordinate system of the agent double vel2 = sqrt( velX2 * velX2 + velY2 * velY2 ); // absolute velocity of 2nd vehicle [m/s] double velDir2 = yaw2; // velocity direction of 2nd vehicle [rad] - double mass2 = agent2->GetVehicleModelParameters().weight; // mass of 2nd vehicle [kg] + const auto mass2 = helper::map::query(agent2->GetVehicleModelParameters().properties, vehicle::properties::Mass); // mass of 2nd vehicle [kg] + THROWIFFALSE(mass2.has_value(), "Mass was not defined in VehicleCatalog"); double length2 = agent2->GetLength(); double width2 = agent2->GetWidth(); - double momentIntertiaYaw2 = CommonHelper::CalculateMomentInertiaYaw(mass2, length2, width2); // moment of inertia 2nd vehicle [kg*m^2] + double momentIntertiaYaw2 = CommonHelper::CalculateMomentInertiaYaw(mass2.value(), length2, width2); // moment of inertia 2nd vehicle [kg*m^2] // new coordinate system axis: tangent and normal to contact plane Common::Vector2d tang = Common::Vector2d( cos(phi), sin(phi) ); @@ -255,8 +260,8 @@ bool CollisionDetectionPostCrash::CalculatePostCrashDynamic(Common::Vector2d cog double vrel_pre_tang = v1tang - v2tang; // auxiliary parameters - double c1 = 1 / mass1 + 1 / mass2 + n1 * n1 / momentIntertiaYaw1 + n2 * n2 / momentIntertiaYaw2; - double c2 = 1 / mass1 + 1 / mass2 + t1 * t1 / momentIntertiaYaw1 + t2 * t2 / momentIntertiaYaw2; + double c1 = 1 / mass1.value() + 1 / mass2.value() + n1 * n1 / momentIntertiaYaw1 + n2 * n2 / momentIntertiaYaw2; + double c2 = 1 / mass1.value() + 1 / mass2.value() + t1 * t1 / momentIntertiaYaw1 + t2 * t2 / momentIntertiaYaw2; double c3 = t1 * n1 / momentIntertiaYaw1 + t2 * n2 / momentIntertiaYaw2; // compute pulse vector in compression phase double Tc = ( c3 * vrel_pre_norm + c2 * vrel_pre_tang ) / ( c3 * c3 - c1 * c2 ); @@ -290,10 +295,10 @@ bool CollisionDetectionPostCrash::CalculatePostCrashDynamic(Common::Vector2d cog } // compute post crash velocities in COG with momentum balance equations - double v1tang_post_cog = T / mass1 + v1tang_cog; - double v1norm_post_cog = N / mass1 + v1norm_cog; - double v2tang_post_cog = -T / mass2 + v2tang_cog; - double v2norm_post_cog = -N / mass2 + v2norm_cog; + double v1tang_post_cog = T / mass1.value() + v1tang_cog; + double v1norm_post_cog = N / mass1.value() + v1norm_cog; + double v2tang_post_cog = -T / mass2.value() + v2tang_cog; + double v2norm_post_cog = -N / mass2.value() + v2norm_cog; // matrix for coordinate transformation between global and local // POI-coordinates diff --git a/sim/src/core/slave/modules/Spawners/PreRunCommon/SpawnPointPreRunCommon.cpp b/sim/src/core/slave/modules/Spawners/PreRunCommon/SpawnPointPreRunCommon.cpp index b7b44cc1495b50cf5964afa7eaea3d3411311f2a..887847fba7620ea0e8582898ffcb8055189dda61 100644 --- a/sim/src/core/slave/modules/Spawners/PreRunCommon/SpawnPointPreRunCommon.cpp +++ b/sim/src/core/slave/modules/Spawners/PreRunCommon/SpawnPointPreRunCommon.cpp @@ -78,8 +78,8 @@ SpawnPointInterface::Agents SpawnPointPreRunCommon::GenerateAgentsForRange(const agentBlueprint.SetAgentProfileName(agentProfile.name); agentBlueprint.SetAgentCategory(AgentCategory::Common); - const auto agentLength = agentBlueprint.GetVehicleModelParameters().length; - const auto agentFrontLength = agentBlueprint.GetVehicleModelParameters().distanceReferencePointToLeadingEdge; + const auto agentLength = agentBlueprint.GetVehicleModelParameters().boundingBoxDimensions.length; + const auto agentFrontLength = agentLength * 0.5 + agentBlueprint.GetVehicleModelParameters().boundingBoxCenter.x; const auto agentRearLength = agentLength - agentFrontLength; auto velocity = Sampler::RollForStochasticAttribute(agentProfile.velocity, dependencies.stochastics); diff --git a/sim/src/core/slave/modules/Spawners/RuntimeCommon/SpawnPointRuntimeCommon.cpp b/sim/src/core/slave/modules/Spawners/RuntimeCommon/SpawnPointRuntimeCommon.cpp index 8e4a087f518d6cbaa2d86e41004180caea47d7e8..526f9afd83181308b103d67450551864bc29c31a 100644 --- a/sim/src/core/slave/modules/Spawners/RuntimeCommon/SpawnPointRuntimeCommon.cpp +++ b/sim/src/core/slave/modules/Spawners/RuntimeCommon/SpawnPointRuntimeCommon.cpp @@ -88,8 +88,8 @@ SpawnDetails SpawnPointRuntimeCommon::GenerateSpawnDetailsForLane(const SpawnPos void SpawnPointRuntimeCommon::AdjustVelocityForCrash(SpawnDetails& spawnDetails, const SpawnPosition& sceneryInformation) const { - const auto agentFrontLength = spawnDetails.agentBlueprint.GetVehicleModelParameters().distanceReferencePointToLeadingEdge; - const auto agentRearLength = spawnDetails.agentBlueprint.GetVehicleModelParameters().length - spawnDetails.agentBlueprint.GetVehicleModelParameters().distanceReferencePointToLeadingEdge; + const double agentFrontLength = spawnDetails.agentBlueprint.GetVehicleModelParameters().boundingBoxDimensions.length * 0.5 + spawnDetails.agentBlueprint.GetVehicleModelParameters().boundingBoxCenter.x; + const double agentRearLength = spawnDetails.agentBlueprint.GetVehicleModelParameters().boundingBoxDimensions.length * 0.5 - spawnDetails.agentBlueprint.GetVehicleModelParameters().boundingBoxCenter.x; const auto intendedVelocity = spawnDetails.agentBlueprint.GetSpawnParameter().velocity; spawnDetails.agentBlueprint.GetSpawnParameter().velocity = worldAnalyzer.CalculateSpawnVelocityToPreventCrashing(sceneryInformation.roadId, diff --git a/sim/src/core/slave/modules/Spawners/Scenario/SpawnPointScenario.cpp b/sim/src/core/slave/modules/Spawners/Scenario/SpawnPointScenario.cpp index e2701f6828c3c75865eb32c069fd1a4a37484a20..f14c7e6b14f0d0720ea953163ba965752d7d9c96 100644 --- a/sim/src/core/slave/modules/Spawners/Scenario/SpawnPointScenario.cpp +++ b/sim/src/core/slave/modules/Spawners/Scenario/SpawnPointScenario.cpp @@ -84,9 +84,9 @@ bool SpawnPointScenario::ValidateOverlappingAgents(const STCoordinates &stCoordi if (GetWorld()->IntersectsWithAgent(position.xPos, position.yPos, position.yawAngle, - vehicleModelParameters.length, - vehicleModelParameters.width, - vehicleModelParameters.distanceReferencePointToLeadingEdge)) + vehicleModelParameters.boundingBoxDimensions.length, + vehicleModelParameters.boundingBoxDimensions.width, + vehicleModelParameters.boundingBoxDimensions.length * 0.5 + vehicleModelParameters.boundingBoxCenter.x)) { return false; } @@ -180,7 +180,7 @@ STCoordinates SpawnPointScenario::GetSTCoordinates(const openScenario::LanePosit vehicleModelParameters) && ValidateSTCoordinatesOnLane(stCoordinates, lanePosition, - vehicleModelParameters.width)) + vehicleModelParameters.boundingBoxDimensions.width)) { return stCoordinates; } diff --git a/sim/src/core/slave/modules/Spawners/common/WorldAnalyzer.cpp b/sim/src/core/slave/modules/Spawners/common/WorldAnalyzer.cpp index 683fce31bd520d6830b9cf5b8f0b4d2f6a67640f..e39d127a4c085b5fcbe38a1c81978d2e99d0a8ff 100644 --- a/sim/src/core/slave/modules/Spawners/common/WorldAnalyzer.cpp +++ b/sim/src/core/slave/modules/Spawners/common/WorldAnalyzer.cpp @@ -260,14 +260,15 @@ bool WorldAnalyzer::ValidMinimumSpawningDistanceToObjectInFront(const LaneId lan const Route &route, const VehicleModelParameters& vehicleModelParameters) const { - const double rearLength = vehicleModelParameters.length - vehicleModelParameters.distanceReferencePointToFrontAxle; + const double distanceReferencePointToFrontAxle = vehicleModelParameters.boundingBoxDimensions.length * 0.5 + vehicleModelParameters.boundingBoxCenter.x; + const double rearLength = vehicleModelParameters.boundingBoxDimensions.length * 0.5 - vehicleModelParameters.boundingBoxCenter.x; const auto agentsInRangeResult = world->GetAgentsInRange(route.roadGraph, route.root, laneId, sPosition, rearLength, - vehicleModelParameters.distanceReferencePointToFrontAxle + MINIMUM_SEPARATION_BUFFER); + distanceReferencePointToFrontAxle + MINIMUM_SEPARATION_BUFFER); if(!agentsInRangeResult.at(route.target).empty()) { @@ -297,7 +298,7 @@ bool WorldAnalyzer::AreSpawningCoordinatesValid(const RoadId& roadId, return false; } - if (!IsOffsetValidForLane(roadId, laneId, sPosition, offset, vehicleModelParameters.width)) + if (!IsOffsetValidForLane(roadId, laneId, sPosition, offset, vehicleModelParameters.boundingBoxDimensions.width)) { loggingCallback("Offset is not valid for vehicle on lane: " + std::to_string(laneId) + ". Invalid offset: " + std::to_string( offset)); @@ -415,12 +416,13 @@ bool WorldAnalyzer::NewAgentIntersectsWithExistingAgent(const RoadId& roadId, { Position pos = world->LaneCoord2WorldCoord(sPosition, offset, roadId, laneId); + const double distanceReferencePointToLeadingEdge = vehicleModelParameters.boundingBoxDimensions.length * 0.5 + vehicleModelParameters.boundingBoxCenter.x; return world->IntersectsWithAgent(pos.xPos, pos.yPos, pos.yawAngle, - vehicleModelParameters.length, - vehicleModelParameters.width, - vehicleModelParameters.distanceReferencePointToLeadingEdge); + vehicleModelParameters.boundingBoxDimensions.length, + vehicleModelParameters.boundingBoxDimensions.width, + distanceReferencePointToLeadingEdge); } bool WorldAnalyzer::SpawnWillCauseCrash(const RoadId& roadId, diff --git a/sim/src/core/slave/modules/World_OSI/AgentAdapter.h b/sim/src/core/slave/modules/World_OSI/AgentAdapter.h index 15ce9ba5c200047225237d136b5de2bcf2da3625..8e91aeeff5bc359b72b58f1ba9de6062ecaecc7d 100644 --- a/sim/src/core/slave/modules/World_OSI/AgentAdapter.h +++ b/sim/src/core/slave/modules/World_OSI/AgentAdapter.h @@ -218,6 +218,14 @@ public: }); } + void SetRoll(double value) override + { + world->QueueAgentUpdate([this, value]() + { + UpdateRoll(value); + }); + } + void SetYawRate(double value) override { world->QueueAgentUpdate([this, value]() @@ -901,15 +909,15 @@ private: void UpdateVehicleModelParameter(const VehicleModelParameters& parameter) { - OWL::Primitive::Dimension dimension = baseTrafficObject.GetDimension(); - dimension.width = parameter.width; - dimension.length = parameter.length; - dimension.height = parameter.height; + OWL::Primitive::Dimension dimension; + dimension.width = parameter.boundingBoxDimensions.width; + dimension.length = parameter.boundingBoxDimensions.length; + dimension.height = parameter.boundingBoxDimensions.height; GetBaseTrafficObject().SetDimension(dimension); - GetBaseTrafficObject().SetDistanceReferencPointToLeadingEdge(parameter.distanceReferencePointToLeadingEdge); + GetBaseTrafficObject().SetBoundingBoxCenterToRear(-parameter.boundingBoxCenter.x); GetBaseTrafficObject().SetType(parameter.vehicleType); - + vehicleModelParameters = parameter; } @@ -920,6 +928,13 @@ private: GetBaseTrafficObject().SetAbsOrientation(orientation); } + void UpdateRoll(double rollAngle) + { + OWL::Primitive::AbsOrientation orientation = baseTrafficObject.GetAbsOrientation(); + orientation.roll = rollAngle; + GetBaseTrafficObject().SetAbsOrientation(orientation); + } + //----------------------------------------------------------------------------- //! Initialize the ego vehicle object inside the drivingView. //----------------------------------------------------------------------------- diff --git a/sim/src/core/slave/modules/World_OSI/AgentNetwork.cpp b/sim/src/core/slave/modules/World_OSI/AgentNetwork.cpp index c3b3a17c1b01597caf5ea2f0cb7dfd554cbb8070..cc5613827dba73c41fb3a4b9c52c20019812f224 100644 --- a/sim/src/core/slave/modules/World_OSI/AgentNetwork.cpp +++ b/sim/src/core/slave/modules/World_OSI/AgentNetwork.cpp @@ -118,6 +118,7 @@ void AgentNetwork::PublishGlobalData(Publisher publish) publish(agentId, "VelocityEgo", agent->GetVelocity()); publish(agentId, "AccelerationEgo", agent->GetAcceleration()); publish(agentId, "YawAngle", agent->GetYaw()); + publish(agentId, "RollAngle", agent->GetRoll()); publish(agentId, "YawRate", agent->GetYawRate()); publish(agentId, "SteeringAngle", agent->GetSteeringWheelAngle()); publish(agentId, "TotalDistanceTraveled", agent->GetDistanceTraveled()); diff --git a/sim/src/core/slave/modules/World_OSI/OWL/DataTypes.cpp b/sim/src/core/slave/modules/World_OSI/OWL/DataTypes.cpp index a933d62c42a17cb30cc41b426e21ae52fa10f1fc..c53b7df48255b059ced522d5d0d7d5ca1f21331e 100644 --- a/sim/src/core/slave/modules/World_OSI/OWL/DataTypes.cpp +++ b/sim/src/core/slave/modules/World_OSI/OWL/DataTypes.cpp @@ -873,9 +873,9 @@ void MovingObject::SetHeight(const double newHeight) osiDimension->set_height(newHeight); } -void MovingObject::SetDistanceReferencPointToLeadingEdge(const double distance) +void MovingObject::SetBoundingBoxCenterToRear(const double distance) { - osiObject->mutable_vehicle_attributes()->mutable_bbcenter_to_rear()->set_x(osiObject->base().dimension().length() * 0.5 - distance); + osiObject->mutable_vehicle_attributes()->mutable_bbcenter_to_rear()->set_x(distance); } Primitive::AbsPosition MovingObject::GetReferencePointPosition() const diff --git a/sim/src/core/slave/modules/World_OSI/OWL/DataTypes.h b/sim/src/core/slave/modules/World_OSI/OWL/DataTypes.h index 36792d704347f6912f9631b6207a0293e99e2cd1..d3652f45a1c6a290692c6ac43d534b96f003c7c4 100644 --- a/sim/src/core/slave/modules/World_OSI/OWL/DataTypes.h +++ b/sim/src/core/slave/modules/World_OSI/OWL/DataTypes.h @@ -600,7 +600,7 @@ public: virtual void SetLength(const double newLength) = 0; virtual void SetWidth(const double newWidth) = 0; virtual void SetHeight(const double newHeight) = 0; - virtual void SetDistanceReferencPointToLeadingEdge(const double distance) = 0; + virtual void SetBoundingBoxCenterToRear(const double distance) = 0; virtual double GetDistanceReferencePointToLeadingEdge() const = 0; virtual void SetReferencePointPosition(const Primitive::AbsPosition& newPosition) = 0; @@ -1164,7 +1164,7 @@ public: virtual void SetLength(const double newLength) override; virtual void SetWidth(const double newWidth) override; virtual void SetHeight(const double newHeight) override; - virtual void SetDistanceReferencPointToLeadingEdge(const double distance) override; + virtual void SetBoundingBoxCenterToRear(const double distance) override; virtual void SetReferencePointPosition(const Primitive::AbsPosition& newPosition) override; virtual void SetX(const double newX) override; diff --git a/sim/src/core/slave/modules/World_OSI/OWL/fakes/fakeMovingObject.h b/sim/src/core/slave/modules/World_OSI/OWL/fakes/fakeMovingObject.h index df8a30d108031822513d17863064d64bf2271862..39490414fb620e51fba0e6b88e1de4fe3cee00e2 100644 --- a/sim/src/core/slave/modules/World_OSI/OWL/fakes/fakeMovingObject.h +++ b/sim/src/core/slave/modules/World_OSI/OWL/fakes/fakeMovingObject.h @@ -84,7 +84,7 @@ public: MOCK_METHOD1(SetLength, void(const double newLength)); MOCK_METHOD1(SetWidth, void(const double newWidth)); MOCK_METHOD1(SetHeight, void(const double newHeight)); - MOCK_METHOD1(SetDistanceReferencPointToLeadingEdge, void(const double distance)); + MOCK_METHOD1(SetBoundingBoxCenterToRear, void(const double distance)); MOCK_METHOD1(SetReferencePointPosition, void(const OWL::Primitive::AbsPosition& newPosition)); MOCK_METHOD1(SetX, void(const double newX)); diff --git a/sim/src/core/slave/modules/World_OSI/WorldObjectAdapter.cpp b/sim/src/core/slave/modules/World_OSI/WorldObjectAdapter.cpp index 818edf53dd9ddf3a373976c05ff7fc04a895a435..5368b30d626d6b4bf1f364e93c7c018be862d3b4 100644 --- a/sim/src/core/slave/modules/World_OSI/WorldObjectAdapter.cpp +++ b/sim/src/core/slave/modules/World_OSI/WorldObjectAdapter.cpp @@ -66,6 +66,11 @@ double WorldObjectAdapter::GetYaw() const { return baseTrafficObject.GetAbsOrientation().yaw; } + +double WorldObjectAdapter::GetRoll() const +{ + return baseTrafficObject.GetAbsOrientation().roll; +} double WorldObjectAdapter::GetAcceleration() const { @@ -79,24 +84,28 @@ const OWL::Interfaces::WorldObject& WorldObjectAdapter::GetBaseTrafficObject() c const polygon_t WorldObjectAdapter::CalculateBoundingBox() const { - double length = GetLength(); - double width = GetWidth(); - double rotation = GetYaw(); + const double length = GetLength(); + const double width = GetWidth(); + const double height = GetHeight(); + const double rotation = GetYaw(); + const double roll = GetRoll(); - double x = GetPositionX(); - double y = GetPositionY(); + const double x = GetPositionX(); + const double y = GetPositionY(); - double center = GetDistanceReferencePointToLeadingEdge(); + const double center = GetDistanceReferencePointToLeadingEdge(); - double halfWidth = width / 2.0; + const double halfWidth = width / 2.0; + const double widthLeft = halfWidth * std::cos(roll) + (roll < 0 ? height * std::sin(-roll) : 0); + const double widthRight = halfWidth * std::cos(roll) + (roll > 0 ? height * std::sin(roll) : 0); point_t boxPoints[] { - {center - length, -halfWidth}, - {center - length, halfWidth}, - {center, halfWidth}, - {center, -halfWidth}, - {center - length, -halfWidth} + {center - length, -widthRight}, + {center - length, widthLeft}, + {center, widthLeft}, + {center, -widthRight}, + {center - length, -widthRight} }; polygon_t box; diff --git a/sim/src/core/slave/modules/World_OSI/WorldObjectAdapter.h b/sim/src/core/slave/modules/World_OSI/WorldObjectAdapter.h index 942f78ebb6022a1ad14b34b1c93190d8fdbd5702..77d4f9f8ef88854f2634e9771141bfb7c59f8b22 100644 --- a/sim/src/core/slave/modules/World_OSI/WorldObjectAdapter.h +++ b/sim/src/core/slave/modules/World_OSI/WorldObjectAdapter.h @@ -25,6 +25,7 @@ public: double GetPositionLateral() const; double GetWidth() const; double GetYaw() const; + double GetRoll() const; double GetDistanceReferencePointToLeadingEdge() const; double GetAcceleration() const; const OWL::Interfaces::WorldObject& GetBaseTrafficObject() const; diff --git a/sim/tests/endToEndTests/end_to_end.json b/sim/tests/endToEndTests/end_to_end.json index 08b3a6a27c5bff2a3041cc40135a816292794883..15062ee9b8e802bed743b1e394687c3b04628c58 100644 --- a/sim/tests/endToEndTests/end_to_end.json +++ b/sim/tests/endToEndTests/end_to_end.json @@ -26,7 +26,6 @@ "OSCAction_DoubleSinusoidalLaneChangeRight_Absolute", "OSCAction_DoubleSinusoidalLaneChangeLeft_Relative", "OSCAction_DoubleSinusoidalLaneChangeRight_Relative", - "Pedestrian_AFDM", "Pedestrian_Trajectory", "Sensor_Latency", "StaticAgentProfiles", diff --git a/sim/tests/fakes/gmock/fakeAgent.h b/sim/tests/fakes/gmock/fakeAgent.h index e233b928e4860e9acecac0a1e3fb7c3edcd871fd..7e09c0c8cad6c0b4d02e2eb3cb5f54e355d447f1 100644 --- a/sim/tests/fakes/gmock/fakeAgent.h +++ b/sim/tests/fakes/gmock/fakeAgent.h @@ -47,6 +47,7 @@ class FakeAgent : public FakeWorldObject, public AgentInterface MOCK_METHOD1(SetVelocity, void(double value)); MOCK_METHOD1(SetAcceleration, void(double value)); MOCK_METHOD1(SetYaw, void(double value)); + MOCK_METHOD1(SetRoll, void(double value)); MOCK_METHOD1(SetDistanceTraveled, void(double distanceTraveled)); MOCK_CONST_METHOD0(GetDistanceTraveled, double()); MOCK_METHOD1(SetGear, void(int gear)); diff --git a/sim/tests/fakes/gmock/fakeWorldObject.h b/sim/tests/fakes/gmock/fakeWorldObject.h index ae91b1423b43c32f0a9669e65cfaa54bc6b82697..ba4d13ed9233a29cb94d74fc03f850f922e5c79c 100644 --- a/sim/tests/fakes/gmock/fakeWorldObject.h +++ b/sim/tests/fakes/gmock/fakeWorldObject.h @@ -23,6 +23,7 @@ public: MOCK_CONST_METHOD0(GetLength, double()); MOCK_CONST_METHOD0(GetHeight, double()); MOCK_CONST_METHOD0(GetYaw, double()); + MOCK_CONST_METHOD0(GetRoll, double()); MOCK_CONST_METHOD0(GetId, int()); MOCK_CONST_METHOD0(GetBoundingBox2D, const polygon_t& ()); MOCK_CONST_METHOD2(GetDistanceToStartOfRoad, double(MeasurementPoint, std::string)); diff --git a/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/VehicleModelsCatalog.xosc b/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/VehicleModelsCatalog.xosc index 0b5ca5dd3e273cd910b5c20950f25c35e29ce0a7..05da35c2c227d54f0e984f6abf9192f02d2ce956 100644 --- a/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/VehicleModelsCatalog.xosc +++ b/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/Resources/ImporterTest/VehicleModelsCatalog.xosc @@ -25,7 +25,7 @@ <Center x="1.0" y="0.0" z="1.1"/> <Dimensions width="1.0" length="4.0" height="2.2"/> </BoundingBox> - <Performance maxSpeed="10.0" maxDeceleration="9.80665"/> + <Performance maxSpeed="10.0" maxAcceleration="10.0" maxDeceleration="9.8"/> <Axles> <FrontAxle maxSteering="0.707" wheelDiameter="0.5" trackWidth="1.0" positionX="2.0" positionZ="0.25"/> <RearAxle maxSteering="0.0" wheelDiameter="0.5" trackWidth="1.0" positionX="0.0" positionZ="0.25"/> @@ -55,7 +55,7 @@ <Center x="2.0" y="0.0" z="2.2"/> <Dimensions width="1.5" length="3.0" height="4.4"/> </BoundingBox> - <Performance maxSpeed="11.0" maxDeceleration="4.5"/> + <Performance maxSpeed="11.0" maxAcceleration="10.0" maxDeceleration="4.5"/> <Axles> <FrontAxle maxSteering="0.5" wheelDiameter="0.4" trackWidth="1.1" positionX="2.5" positionZ="0.2"/> <RearAxle maxSteering="0.0" wheelDiameter="0.4" trackWidth="1.1" positionX="0.0" positionZ="0.2"/> diff --git a/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/SceneryImporter_IntegrationTests.cpp b/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/SceneryImporter_IntegrationTests.cpp index a3ab9c380e86d5edf3d5cb20a9376b67b8557e41..8264a5b9be65896422515b87a6d761d4ea81957f 100644 --- a/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/SceneryImporter_IntegrationTests.cpp +++ b/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/SceneryImporter_IntegrationTests.cpp @@ -971,9 +971,9 @@ TEST(SceneryImporter_IntegrationTests, MultipleRoadsWithIntersectingJunctions_Ju { VehicleModelParameters vehicleParameter; vehicleParameter.vehicleType = AgentVehicleType::Car; - vehicleParameter.width = width; - vehicleParameter.length = length; - vehicleParameter.distanceReferencePointToLeadingEdge = length / 2.0; + vehicleParameter.boundingBoxDimensions.width = width; + vehicleParameter.boundingBoxDimensions.length = length; + vehicleParameter.boundingBoxCenter.x = 0.0; SpawnParameter spawnParameter; spawnParameter.positionX = x; diff --git a/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/VehicleModelsImporter_IntegrationTests.cpp b/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/VehicleModelsImporter_IntegrationTests.cpp index d7b513f1236537e7a0a96652aff0b91d54757287..6a541baecb1cf3b37e074ca90b28dab0b2f5b05d 100644 --- a/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/VehicleModelsImporter_IntegrationTests.cpp +++ b/sim/tests/integrationTests/OpenPassSlave_IntegrationTests/VehicleModelsImporter_IntegrationTests.cpp @@ -33,82 +33,97 @@ TEST(VehicleModelImporter, GivenVehicleAndPedestrianCatalogs_ImportsAllModels) auto vehicleModel1 = vehicleModels.GetVehicleModel("car_one"); EXPECT_THAT(vehicleModel1.vehicleType, Eq(AgentVehicleType::Car)); - EXPECT_THAT(vehicleModel1.airDragCoefficient, DoubleEq(1.1)); - EXPECT_THAT(vehicleModel1.axleRatio, DoubleEq(2.2)); - EXPECT_THAT(vehicleModel1.decelerationFromPowertrainDrag, DoubleEq(3.3)); - EXPECT_THAT(vehicleModel1.distanceReferencePointToFrontAxle, DoubleEq(2.0)); - EXPECT_THAT(vehicleModel1.distanceReferencePointToLeadingEdge, DoubleEq(3.0)); - EXPECT_THAT(vehicleModel1.frictionCoeff, DoubleEq(4.4)); - EXPECT_THAT(vehicleModel1.frontSurface, DoubleEq(5.5)); - EXPECT_THAT(vehicleModel1.gearRatios, ElementsAre(0.0, 6.6)); - EXPECT_THAT(vehicleModel1.height, DoubleEq(2.2)); - EXPECT_THAT(vehicleModel1.heightCOG, DoubleEq(0.0)); // unsupported parameter, fixed to 0.0 - EXPECT_THAT(vehicleModel1.length, DoubleEq(4.0)); - EXPECT_THAT(vehicleModel1.maxCurvature, DoubleEq(std::sin(0.707) / 2.0)); // sin(maxSteering fron wheel) / wheelbase - EXPECT_THAT(vehicleModel1.maxVelocity, DoubleEq(10.0)); - EXPECT_THAT(vehicleModel1.maximumEngineSpeed, DoubleEq(6000.0)); - EXPECT_THAT(vehicleModel1.maximumEngineTorque, DoubleEq(250.0)); - EXPECT_THAT(vehicleModel1.maximumSteeringWheelAngleAmplitude, DoubleEq(0.707 * 7.7)); // maxSteering front wheel * SteeringRatio - EXPECT_THAT(vehicleModel1.minimumEngineSpeed, DoubleEq(900.0)); - EXPECT_THAT(vehicleModel1.minimumEngineTorque, DoubleEq(-54.0)); - EXPECT_THAT(vehicleModel1.momentInertiaPitch, DoubleEq(0.0)); - EXPECT_THAT(vehicleModel1.momentInertiaRoll, DoubleEq(0.0)); - EXPECT_THAT(vehicleModel1.momentInertiaYaw, DoubleEq(0.0)); - EXPECT_THAT(vehicleModel1.numberOfGears, 1); - EXPECT_THAT(vehicleModel1.staticWheelRadius, DoubleEq(0.25)); - EXPECT_THAT(vehicleModel1.steeringRatio, DoubleEq(7.7)); - EXPECT_THAT(vehicleModel1.trackwidth, DoubleEq(1.0)); - EXPECT_THAT(vehicleModel1.weight, DoubleEq(1000.0)); - EXPECT_THAT(vehicleModel1.wheelbase, DoubleEq(2.0)); - EXPECT_THAT(vehicleModel1.width, DoubleEq(1.0)); + EXPECT_THAT(vehicleModel1.boundingBoxCenter.x, DoubleEq(1.0)); + EXPECT_THAT(vehicleModel1.boundingBoxCenter.y, DoubleEq(0)); + EXPECT_THAT(vehicleModel1.boundingBoxCenter.z, DoubleEq(1.1)); + EXPECT_THAT(vehicleModel1.boundingBoxDimensions.width, DoubleEq(1.0)); + EXPECT_THAT(vehicleModel1.boundingBoxDimensions.length, DoubleEq(4.0)); + EXPECT_THAT(vehicleModel1.boundingBoxDimensions.height, DoubleEq(2.2)); + EXPECT_THAT(vehicleModel1.performance.maxSpeed, DoubleEq(10.0)); + EXPECT_THAT(vehicleModel1.performance.maxAcceleration, DoubleEq(10.0)); + EXPECT_THAT(vehicleModel1.performance.maxDeceleration, DoubleEq(9.8)); + EXPECT_THAT(vehicleModel1.frontAxle.maxSteering, DoubleEq(0.707)); + EXPECT_THAT(vehicleModel1.frontAxle.wheelDiameter, DoubleEq(0.5)); + EXPECT_THAT(vehicleModel1.frontAxle.trackWidth, DoubleEq(1.0)); + EXPECT_THAT(vehicleModel1.frontAxle.positionX, DoubleEq(2.0)); + EXPECT_THAT(vehicleModel1.frontAxle.positionZ, DoubleEq(0.25)); + EXPECT_THAT(vehicleModel1.rearAxle.maxSteering, DoubleEq(0.0)); + EXPECT_THAT(vehicleModel1.rearAxle.wheelDiameter, DoubleEq(0.5)); + EXPECT_THAT(vehicleModel1.rearAxle.trackWidth, DoubleEq(1.0)); + EXPECT_THAT(vehicleModel1.rearAxle.positionX, DoubleEq(0.0)); + EXPECT_THAT(vehicleModel1.rearAxle.positionZ, DoubleEq(0.25)); + EXPECT_THAT(vehicleModel1.properties, ElementsAre( + std::make_pair("AirDragCoefficient", 1.1), + std::make_pair("AxleRatio", 2.2), + std::make_pair("DecelerationFromPowertrainDrag", 3.3), + std::make_pair("FrictionCoefficient", 4.4), + std::make_pair("FrontSurface", 5.5), + std::make_pair("GearRatio1", 6.6), + std::make_pair("Mass", 1000.0), + std::make_pair("MaximumEngineSpeed", 6000.), + std::make_pair("MaximumEngineTorque", 250.), + std::make_pair("MinimumEngineSpeed", 900.), + std::make_pair("MinimumEngineTorque", -54.), + std::make_pair("MomentInertiaPitch", 0.0), + std::make_pair("MomentInertiaRoll", 0.0), + std::make_pair("MomentInertiaYaw", 0.0), + std::make_pair("NumberOfGears", 1.), + std::make_pair("SteeringRatio", 7.7))); auto vehicleModel2 = vehicleModels.GetVehicleModel("car_two"); EXPECT_THAT(vehicleModel2.vehicleType, Eq(AgentVehicleType::Car)); - EXPECT_THAT(vehicleModel2.airDragCoefficient, DoubleEq(2.2)); - EXPECT_THAT(vehicleModel2.axleRatio, DoubleEq(3.3)); - EXPECT_THAT(vehicleModel2.decelerationFromPowertrainDrag, DoubleEq(4.4)); - EXPECT_THAT(vehicleModel2.distanceReferencePointToFrontAxle, DoubleEq(2.5)); - EXPECT_THAT(vehicleModel2.distanceReferencePointToLeadingEdge, DoubleEq(3.5)); - EXPECT_THAT(vehicleModel2.frictionCoeff, DoubleEq(5.5)); - EXPECT_THAT(vehicleModel2.frontSurface, DoubleEq(6.6)); - EXPECT_THAT(vehicleModel2.gearRatios, ElementsAre(0.0, 7.7, 8.8)); - EXPECT_THAT(vehicleModel2.height, DoubleEq(4.4)); - EXPECT_THAT(vehicleModel2.heightCOG, DoubleEq(0.0)); // unsupported parameter, fixed to 0.0 - EXPECT_THAT(vehicleModel2.length, DoubleEq(3.0)); - EXPECT_THAT(vehicleModel2.maxCurvature, DoubleEq(std::sin(0.5) / 2.5)); // sin(maxSteering fron wheel) / wheelbase - EXPECT_THAT(vehicleModel2.maxVelocity, DoubleEq(11.0)); - EXPECT_THAT(vehicleModel2.maximumEngineSpeed, DoubleEq(6000.0)); - EXPECT_THAT(vehicleModel2.maximumEngineTorque, DoubleEq(250.0)); - EXPECT_THAT(vehicleModel2.maximumSteeringWheelAngleAmplitude, DoubleEq(0.5 * 9.9)); // maxSteering front wheel * SteeringRatio - EXPECT_THAT(vehicleModel2.minimumEngineSpeed, DoubleEq(900.0)); - EXPECT_THAT(vehicleModel2.minimumEngineTorque, DoubleEq(-54.0)); - EXPECT_THAT(vehicleModel2.momentInertiaPitch, DoubleEq(0.0)); - EXPECT_THAT(vehicleModel2.momentInertiaRoll, DoubleEq(0.0)); - EXPECT_THAT(vehicleModel2.momentInertiaYaw, DoubleEq(0.0)); - EXPECT_THAT(vehicleModel2.numberOfGears, 2); - EXPECT_THAT(vehicleModel2.staticWheelRadius, DoubleEq(0.2)); - EXPECT_THAT(vehicleModel2.steeringRatio, DoubleEq(9.9)); - EXPECT_THAT(vehicleModel2.trackwidth, DoubleEq(1.1)); - EXPECT_THAT(vehicleModel2.weight, DoubleEq(999.9)); - EXPECT_THAT(vehicleModel2.wheelbase, DoubleEq(2.5)); - EXPECT_THAT(vehicleModel2.width, DoubleEq(1.5)); + EXPECT_THAT(vehicleModel2.boundingBoxCenter.x, DoubleEq(2.0)); + EXPECT_THAT(vehicleModel2.boundingBoxCenter.y, DoubleEq(0)); + EXPECT_THAT(vehicleModel2.boundingBoxCenter.z, DoubleEq(2.2)); + EXPECT_THAT(vehicleModel2.boundingBoxDimensions.width, DoubleEq(1.5)); + EXPECT_THAT(vehicleModel2.boundingBoxDimensions.length, DoubleEq(3.0)); + EXPECT_THAT(vehicleModel2.boundingBoxDimensions.height, DoubleEq(4.4)); + EXPECT_THAT(vehicleModel2.performance.maxSpeed, DoubleEq(11.0)); + EXPECT_THAT(vehicleModel2.performance.maxAcceleration, DoubleEq(10.0)); + EXPECT_THAT(vehicleModel2.performance.maxDeceleration, DoubleEq(4.5)); + EXPECT_THAT(vehicleModel2.frontAxle.maxSteering, DoubleEq(0.5)); + EXPECT_THAT(vehicleModel2.frontAxle.wheelDiameter, DoubleEq(0.4)); + EXPECT_THAT(vehicleModel2.frontAxle.trackWidth, DoubleEq(1.1)); + EXPECT_THAT(vehicleModel2.frontAxle.positionX, DoubleEq(2.5)); + EXPECT_THAT(vehicleModel2.frontAxle.positionZ, DoubleEq(0.2)); + EXPECT_THAT(vehicleModel2.rearAxle.maxSteering, DoubleEq(0.0)); + EXPECT_THAT(vehicleModel2.rearAxle.wheelDiameter, DoubleEq(0.4)); + EXPECT_THAT(vehicleModel2.rearAxle.trackWidth, DoubleEq(1.1)); + EXPECT_THAT(vehicleModel2.rearAxle.positionX, DoubleEq(0.0)); + EXPECT_THAT(vehicleModel2.rearAxle.positionZ, DoubleEq(0.2)); + EXPECT_THAT(vehicleModel2.properties, ElementsAre( + std::make_pair("AirDragCoefficient", 2.2), + std::make_pair("AxleRatio", 3.3), + std::make_pair("DecelerationFromPowertrainDrag", 4.4), + std::make_pair("FrictionCoefficient", 5.5), + std::make_pair("FrontSurface", 6.6), + std::make_pair("GearRatio1", 7.7), + std::make_pair("GearRatio2", 8.8), + std::make_pair("Mass", 999.9), + std::make_pair("MaximumEngineSpeed", 6000.), + std::make_pair("MaximumEngineTorque", 250.), + std::make_pair("MinimumEngineSpeed", 900.), + std::make_pair("MinimumEngineTorque", -54.), + std::make_pair("MomentInertiaPitch", 0.0), + std::make_pair("MomentInertiaRoll", 0.0), + std::make_pair("MomentInertiaYaw", 0.0), + std::make_pair("NumberOfGears", 2.), + std::make_pair("SteeringRatio", 9.9))); auto pedestrianModel1 = vehicleModels.GetVehicleModel("pedestrian_one"); // workaround for ground truth not being able to handle pedestrians //EXPECT_THAT(pedestrianModel1.vehicleType, Eq(AgentVehicleType::Pedestrian)); EXPECT_THAT(pedestrianModel1.vehicleType, Eq(AgentVehicleType::Car)); - EXPECT_THAT(pedestrianModel1.length, DoubleEq(5.5)); - EXPECT_THAT(pedestrianModel1.width, DoubleEq(4.4)); - EXPECT_THAT(pedestrianModel1.height, DoubleEq(6.6)); - EXPECT_THAT(pedestrianModel1.weight, DoubleEq(100.0)); + EXPECT_THAT(pedestrianModel1.boundingBoxDimensions.length, DoubleEq(5.5)); + EXPECT_THAT(pedestrianModel1.boundingBoxDimensions.width, DoubleEq(4.4)); + EXPECT_THAT(pedestrianModel1.boundingBoxDimensions.height, DoubleEq(6.6)); auto pedestrianModel2 = vehicleModels.GetVehicleModel("pedestrian_two"); // workaround for ground truth not being able to handle pedestrians //EXPECT_THAT(pedestrianModel1.vehicleType, Eq(AgentVehicleType::Pedestrian)); EXPECT_THAT(pedestrianModel1.vehicleType, Eq(AgentVehicleType::Car)); - EXPECT_THAT(pedestrianModel2.length, DoubleEq(2.2)); - EXPECT_THAT(pedestrianModel2.width, DoubleEq(3.3)); - EXPECT_THAT(pedestrianModel2.height, DoubleEq(1.1)); - EXPECT_THAT(pedestrianModel2.weight, DoubleEq(111.1)); + EXPECT_THAT(pedestrianModel2.boundingBoxDimensions.length, DoubleEq(2.2)); + EXPECT_THAT(pedestrianModel2.boundingBoxDimensions.width, DoubleEq(3.3)); + EXPECT_THAT(pedestrianModel2.boundingBoxDimensions.height, DoubleEq(1.1)); } diff --git a/sim/tests/integrationTests/Spawner_IntegrationTests/Spawner_IntegrationTests.cpp b/sim/tests/integrationTests/Spawner_IntegrationTests/Spawner_IntegrationTests.cpp index eab2411fd73932f58ab44bc7e2ad3147a3e8a98b..fdd4557499817669fc25b85a3ce6b2197e5a4a15 100644 --- a/sim/tests/integrationTests/Spawner_IntegrationTests/Spawner_IntegrationTests.cpp +++ b/sim/tests/integrationTests/Spawner_IntegrationTests/Spawner_IntegrationTests.cpp @@ -112,8 +112,9 @@ public: AgentBlueprint agentBlueprint; VehicleModelParameters vehicleModelParameters; - vehicleModelParameters.length = 5.0; - vehicleModelParameters.distanceReferencePointToLeadingEdge = 3.0; + vehicleModelParameters.vehicleType = AgentVehicleType::Car; + vehicleModelParameters.boundingBoxDimensions.length = 5.0; + vehicleModelParameters.boundingBoxCenter.x = 0.5; agentBlueprint.SetVehicleModelParameters(vehicleModelParameters); ON_CALL(agentBlueprintProvider, SampleAgent(_,_)).WillByDefault(Return(agentBlueprint)); } diff --git a/sim/tests/unitTests/common/ttcCalculation_Tests.cpp b/sim/tests/unitTests/common/ttcCalculation_Tests.cpp index ed54544a9d91edb36ed53b9fad83401ffd731a04..dfb5096d369e2b80190d8d57f4bcda3407a719e9 100644 --- a/sim/tests/unitTests/common/ttcCalculation_Tests.cpp +++ b/sim/tests/unitTests/common/ttcCalculation_Tests.cpp @@ -66,6 +66,7 @@ TEST_P(TtcCalcualtionTest, CalculateObjectTTC_ReturnsCorrectTtc) ON_CALL(ego, GetPositionX()).WillByDefault(Return(data.egoX)); ON_CALL(ego, GetPositionY()).WillByDefault(Return(data.egoY)); ON_CALL(ego, GetYaw()).WillByDefault(Return(data.egoYaw)); + ON_CALL(ego, GetRoll()).WillByDefault(Return(0.0)); ON_CALL(ego, GetYawRate()).WillByDefault(Return(data.egoYawRate)); ON_CALL(ego, GetYawAcceleration()).WillByDefault(Return(data.egoYawAcceleration)); ON_CALL(ego, GetVelocity(VelocityScope::DirectionX)).WillByDefault(Return(data.egoVelocityX)); @@ -79,6 +80,7 @@ TEST_P(TtcCalcualtionTest, CalculateObjectTTC_ReturnsCorrectTtc) ON_CALL(opponent, GetPositionX()).WillByDefault(Return(data.opponentX)); ON_CALL(opponent, GetPositionY()).WillByDefault(Return(data.opponentY)); ON_CALL(opponent, GetYaw()).WillByDefault(Return(data.opponentYaw)); + ON_CALL(opponent, GetRoll()).WillByDefault(Return(0.0)); ON_CALL(opponent, GetYawRate()).WillByDefault(Return(data.opponentYawRate)); ON_CALL(opponent, GetYawAcceleration()).WillByDefault(Return(data.opponentYawAcceleration)); ON_CALL(opponent, GetVelocity(VelocityScope::DirectionX)).WillByDefault(Return(data.opponentVelocityX)); diff --git a/sim/tests/unitTests/components/AlgorithmAEB/BoundingBoxCalculation_Tests.cpp b/sim/tests/unitTests/components/AlgorithmAEB/BoundingBoxCalculation_Tests.cpp deleted file mode 100644 index eddd4cefbe33606f7f552d74c88ae1959b09d6b1..0000000000000000000000000000000000000000 --- a/sim/tests/unitTests/components/AlgorithmAEB/BoundingBoxCalculation_Tests.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2019 in-tech GmbH -* -* This program and the accompanying materials are made -* available under the terms of the Eclipse Public License 2.0 -* which is available at https://www.eclipse.org/legal/epl-2.0/ -* -* SPDX-License-Identifier: EPL-2.0 -*******************************************************************************/ - -#include "osi3/osi_detectedobject.pb.h" - -#include "gtest/gtest.h" -#include "gmock/gmock.h" - -#include "fakeAgent.h" - -#include "boundingBoxCalculation.h" - - -using ::testing::Return; -using ::testing::Lt; -using ::testing::NiceMock; - -class BoundingBoxCalculation_Tests : public ::testing::Test -{ -public: - BoundingBoxCalculation_Tests() - { - ON_CALL(fakeEgoAgent, GetLength()).WillByDefault(Return(2.0)); - ON_CALL(fakeEgoAgent, GetWidth()).WillByDefault(Return(1.0)); - ON_CALL(fakeEgoAgent, GetDistanceReferencePointToLeadingEdge()).WillByDefault(Return(1.0)); - } - - void SetEgoValues (double velocity, double acceleration, double yawRate) - { - ON_CALL(fakeEgoAgent, GetVelocity()).WillByDefault(Return(velocity)); - ON_CALL(fakeEgoAgent, GetAcceleration()).WillByDefault(Return(acceleration)); - ON_CALL(fakeEgoAgent, GetYawRate()).WillByDefault(Return(yawRate)); - } - - NiceMock<FakeAgent> fakeEgoAgent; -}; - -TEST_F(BoundingBoxCalculation_Tests, MovingObjectAtTimestampZero) -{ - SetEgoValues(0.0, 0.0, 0.0); - osi3::BaseMoving baseMoving; - baseMoving.mutable_dimension()->set_length(3.0); - baseMoving.mutable_dimension()->set_width(3.5); - baseMoving.mutable_position()->set_x(-20.0); - baseMoving.mutable_position()->set_y(35.0); - baseMoving.mutable_orientation()->set_yaw(M_PI * 0.5); - BoundingBoxCalculation bbCalculation(&fakeEgoAgent, 1.0, 1.5); - - double boxPoints[][2] - { - { -22.5, 33 }, - { -22.5, 37 }, - { -17.5, 37 }, - { -17.5, 33 }, - { -22.5, 33 } - }; - - polygon_t expectedBox; - bg::append(expectedBox, boxPoints); - bg::correct(expectedBox); - - polygon_t result = bbCalculation.CalculateBoundingBox(0.0, baseMoving); - bg::correct(result); - - multi_polygon_t differenceMissing; - bg::difference(expectedBox, result, differenceMissing); - multi_polygon_t differenceOverhanging; - bg::difference(result, expectedBox, differenceOverhanging); - - EXPECT_THAT(bg::area(differenceMissing), Lt(0.1)); - EXPECT_THAT(bg::area(differenceOverhanging), Lt(0.1)); -} - -TEST_F(BoundingBoxCalculation_Tests, MovingObjectMovingInStraightLine) -{ - SetEgoValues(0.0, 0.0, 0.0); - osi3::BaseMoving baseMoving; - baseMoving.mutable_dimension()->set_length(3.0); - baseMoving.mutable_dimension()->set_width(3.5); - baseMoving.mutable_position()->set_x(-20.0); - baseMoving.mutable_position()->set_y(35.0); - baseMoving.mutable_orientation()->set_yaw(M_PI * 0.5); - baseMoving.mutable_velocity()->set_y(10.0); - baseMoving.mutable_acceleration()->set_y(-2.0); - BoundingBoxCalculation bbCalculation(&fakeEgoAgent, 1.0, 1.5); - - double boxPoints[][2] - { - { -22.5, 49 }, - { -22.5, 53 }, - { -17.5, 53 }, - { -17.5, 49 }, - { -22.5, 49 } - }; - - polygon_t expectedBox; - bg::append(expectedBox, boxPoints); - bg::correct(expectedBox); - - polygon_t result = bbCalculation.CalculateBoundingBox(2.0, baseMoving); - bg::correct(result); - - multi_polygon_t differenceMissing; - bg::difference(expectedBox, result, differenceMissing); - multi_polygon_t differenceOverhanging; - bg::difference(result, expectedBox, differenceOverhanging); - - EXPECT_THAT(bg::area(differenceMissing), Lt(0.1)); - EXPECT_THAT(bg::area(differenceOverhanging), Lt(0.1)); -} - -TEST_F(BoundingBoxCalculation_Tests, MovingObjectMovingInCircleLeft) -{ - SetEgoValues(0.0, 0.0, 0.0); - osi3::BaseMoving baseMoving; - baseMoving.mutable_dimension()->set_length(3.0); - baseMoving.mutable_dimension()->set_width(3.5); - baseMoving.mutable_position()->set_x(-20.0); - baseMoving.mutable_position()->set_y(35.0); - baseMoving.mutable_orientation()->set_yaw(M_PI * 0.5); - baseMoving.mutable_orientation_rate()->set_yaw(M_PI * 0.25); - baseMoving.mutable_velocity()->set_y(M_PI * 2.5); - baseMoving.mutable_acceleration()->set_y(0.0); - BoundingBoxCalculation bbCalculation(&fakeEgoAgent, 1.0, 1.5); - - double boxPoints[][2] - { - { -32, 42.5 }, - { -32, 47.5 }, - { -28, 47.5 }, - { -28, 42.5 }, - { -32, 42.5 } - }; - - polygon_t expectedBox; - bg::append(expectedBox, boxPoints); - bg::correct(expectedBox); - - polygon_t result = bbCalculation.CalculateBoundingBox(2.0, baseMoving); - bg::correct(result); - - multi_polygon_t differenceMissing; - bg::difference(expectedBox, result, differenceMissing); - multi_polygon_t differenceOverhanging; - bg::difference(result, expectedBox, differenceOverhanging); - - EXPECT_THAT(bg::area(differenceMissing), Lt(0.1)); - EXPECT_THAT(bg::area(differenceOverhanging), Lt(0.1)); -} - -TEST_F(BoundingBoxCalculation_Tests, MovingObjectMovingInCircleRight) -{ - SetEgoValues(0.0, 0.0, 0.0); - osi3::BaseMoving baseMoving; - baseMoving.mutable_dimension()->set_length(3.0); - baseMoving.mutable_dimension()->set_width(3.5); - baseMoving.mutable_position()->set_x(-20.0); - baseMoving.mutable_position()->set_y(35.0); - baseMoving.mutable_orientation()->set_yaw(M_PI * 0.5); - baseMoving.mutable_orientation_rate()->set_yaw(-M_PI * 0.25); - baseMoving.mutable_velocity()->set_y(M_PI * 2.5); - baseMoving.mutable_acceleration()->set_y(0.0); - BoundingBoxCalculation bbCalculation(&fakeEgoAgent, 1.0, 1.5); - - double boxPoints[][2] - { - { -12, 42.5 }, - { -12, 47.5 }, - { -8, 47.5 }, - { -8, 42.5 }, - { -12, 42.5 } - }; - - polygon_t expectedBox; - bg::append(expectedBox, boxPoints); - bg::correct(expectedBox); - - polygon_t result = bbCalculation.CalculateBoundingBox(2.0, baseMoving); - bg::correct(result); - - multi_polygon_t differenceMissing; - bg::difference(expectedBox, result, differenceMissing); - multi_polygon_t differenceOverhanging; - bg::difference(result, expectedBox, differenceOverhanging); - - EXPECT_THAT(bg::area(differenceMissing), Lt(0.1)); - EXPECT_THAT(bg::area(differenceOverhanging), Lt(0.1)); -} - -TEST_F(BoundingBoxCalculation_Tests, MovingObjectOwnAgentMovesInStraightLine) -{ - SetEgoValues(10.0, 2.0, 0.0); - osi3::BaseMoving baseMoving; - baseMoving.mutable_dimension()->set_length(3.0); - baseMoving.mutable_dimension()->set_width(3.5); - baseMoving.mutable_position()->set_x(-20.0); - baseMoving.mutable_position()->set_y(35.0); - baseMoving.mutable_orientation()->set_yaw(-M_PI * 0.5); - baseMoving.mutable_velocity()->set_x(-10.0); - baseMoving.mutable_velocity()->set_y(-10.0); - baseMoving.mutable_acceleration()->set_y(1.0); - baseMoving.mutable_acceleration()->set_x(-2.0); - BoundingBoxCalculation bbCalculation(&fakeEgoAgent, 1.0, 1.5); - - double boxPoints[][2] - { - { -22.5, 15 }, - { -22.5, 19 }, - { -17.5, 19 }, - { -17.5, 15 }, - { -22.5, 15 } - }; - - polygon_t expectedBox; - bg::append(expectedBox, boxPoints); - bg::correct(expectedBox); - - polygon_t result = bbCalculation.CalculateBoundingBox(2.0, baseMoving); - bg::correct(result); - - multi_polygon_t differenceMissing; - bg::difference(expectedBox, result, differenceMissing); - multi_polygon_t differenceOverhanging; - bg::difference(result, expectedBox, differenceOverhanging); - - EXPECT_THAT(bg::area(differenceMissing), Lt(0.1)); - EXPECT_THAT(bg::area(differenceOverhanging), Lt(0.1)); -} - -TEST_F(BoundingBoxCalculation_Tests, MovingObjectBothAgentsMovingInCircle) -{ - SetEgoValues(M_PI * 2.5, 0.0, M_PI * 0.25); - osi3::BaseMoving baseMoving; - baseMoving.mutable_dimension()->set_length(3.0); - baseMoving.mutable_dimension()->set_width(3.5); - baseMoving.mutable_position()->set_x(-20.0); - baseMoving.mutable_position()->set_y(35.0); - baseMoving.mutable_orientation()->set_yaw(0.0); - baseMoving.mutable_orientation_rate()->set_yaw(-M_PI * 0.5); - BoundingBoxCalculation bbCalculation(&fakeEgoAgent, 1.0, 1.5); - - double boxPoints[][2] - { - { -12.5, 23 }, - { -12.5, 27 }, - { -7.5, 27 }, - { -7.5, 23 }, - { -12.5, 23 } - }; - - polygon_t expectedBox; - bg::append(expectedBox, boxPoints); - bg::correct(expectedBox); - - polygon_t result = bbCalculation.CalculateBoundingBox(2.0, baseMoving); - bg::correct(result); - - multi_polygon_t differenceMissing; - bg::difference(expectedBox, result, differenceMissing); - multi_polygon_t differenceOverhanging; - bg::difference(result, expectedBox, differenceOverhanging); - - EXPECT_THAT(bg::area(differenceMissing), Lt(0.1)); - EXPECT_THAT(bg::area(differenceOverhanging), Lt(0.1)); -} - -TEST_F(BoundingBoxCalculation_Tests, OwnAgentMovingInStraightLine) -{ - SetEgoValues(10.0, 2.0, 0.0); - BoundingBoxCalculation bbCalculation(&fakeEgoAgent, 1.0, 1.0); - - double boxPoints[][2] - { - { 22.5, -1 }, - { 22.5, 1 }, - { 25.5, 1 }, - { 25.5, -1 }, - { 22.5, -1 } - }; - - polygon_t expectedBox; - bg::append(expectedBox, boxPoints); - bg::correct(expectedBox); - - polygon_t result = bbCalculation.CalculateOwnBoundingBox(2.0); - bg::correct(result); - - multi_polygon_t differenceMissing; - bg::difference(expectedBox, result, differenceMissing); - multi_polygon_t differenceOverhanging; - bg::difference(result, expectedBox, differenceOverhanging); - - EXPECT_THAT(bg::area(differenceMissing), Lt(0.1)); - EXPECT_THAT(bg::area(differenceOverhanging), Lt(0.1)); -} - -TEST_F(BoundingBoxCalculation_Tests, OwnAgentMovingInCircle) -{ - SetEgoValues(M_PI * 2.5, 0.0, M_PI * 0.25); - BoundingBoxCalculation bbCalculation(&fakeEgoAgent, 1.0, 1.0); - - double boxPoints[][2] - { - { 9, 8.5 }, - { 9, 11.5 }, - { 11, 11.5 }, - { 11, 8.5 }, - { 9, 8.5 } - }; - - polygon_t expectedBox; - bg::append(expectedBox, boxPoints); - bg::correct(expectedBox); - - polygon_t result = bbCalculation.CalculateOwnBoundingBox(2.0); - bg::correct(result); - - multi_polygon_t differenceMissing; - bg::difference(expectedBox, result, differenceMissing); - multi_polygon_t differenceOverhanging; - bg::difference(result, expectedBox, differenceOverhanging); - - EXPECT_THAT(bg::area(differenceMissing), Lt(0.1)); - EXPECT_THAT(bg::area(differenceOverhanging), Lt(0.1)); -} - -TEST_F(BoundingBoxCalculation_Tests, StationaryObject) -{ - osi3::BaseStationary baseStationary; - baseStationary.mutable_dimension()->set_length(3.0); - baseStationary.mutable_dimension()->set_width(4.0); - baseStationary.mutable_position()->set_x(20.0); - baseStationary.mutable_position()->set_y(-10.0); - baseStationary.mutable_orientation()->set_yaw(-M_PI * 0.5); - - BoundingBoxCalculation bbCalculation(&fakeEgoAgent, 1.0, 2.0); - - double boxPoints[][2] - { - { 17, -12 }, - { 17, -8 }, - { 23, -8 }, - { 23, -12 }, - { 17, -12 } - }; - - polygon_t expectedBox; - bg::append(expectedBox, boxPoints); - bg::correct(expectedBox); - - polygon_t result = bbCalculation.CalculateBoundingBox(baseStationary); - bg::correct(result); - - multi_polygon_t differenceMissing; - bg::difference(expectedBox, result, differenceMissing); - multi_polygon_t differenceOverhanging; - bg::difference(result, expectedBox, differenceOverhanging); - - EXPECT_THAT(bg::area(differenceMissing), Lt(0.1)); - EXPECT_THAT(bg::area(differenceOverhanging), Lt(0.1)); -} diff --git a/sim/tests/unitTests/components/AlgorithmAEB/CMakeLists.txt b/sim/tests/unitTests/components/AlgorithmAEB/CMakeLists.txt index 404eb5cf0f73096db10e4ce1ee0c84f582549866..d83a5294d8600dc1ecc2baf23c4c2f06be50be2a 100644 --- a/sim/tests/unitTests/components/AlgorithmAEB/CMakeLists.txt +++ b/sim/tests/unitTests/components/AlgorithmAEB/CMakeLists.txt @@ -8,14 +8,11 @@ add_openpass_target( SOURCES AlgorithmAeb_Tests.cpp - BoundingBoxCalculation_Tests.cpp ${COMPONENT_SOURCE_DIR}/autonomousEmergencyBraking.cpp - ${COMPONENT_SOURCE_DIR}/boundingBoxCalculation.cpp HEADERS AlgorithmAebOSIUnitTests.h ${COMPONENT_SOURCE_DIR}/autonomousEmergencyBraking.h - ${COMPONENT_SOURCE_DIR}/boundingBoxCalculation.h INCDIRS ${COMPONENT_SOURCE_DIR} diff --git a/sim/tests/unitTests/components/AlgorithmAEB/algorithmAEB_Tests.pro b/sim/tests/unitTests/components/AlgorithmAEB/algorithmAEB_Tests.pro index cd181d8c56bd20e153e74cbabfdea2ca76de569c..9b120f80215b0f4c2f9e88d774c0c2de8450efc4 100644 --- a/sim/tests/unitTests/components/AlgorithmAEB/algorithmAEB_Tests.pro +++ b/sim/tests/unitTests/components/AlgorithmAEB/algorithmAEB_Tests.pro @@ -24,14 +24,11 @@ HEADERS += \ AlgorithmAebOSIUnitTests.h \ $$relative_path($$OPEN_SRC)/common/boostGeometryCommon.h \ $$relative_path($$OPEN_SRC)/common/vector2d.h \ - $$relative_path($$OPEN_SRC)/components/Algorithm_AEB/src/autonomousEmergencyBraking.h \ - $$relative_path($$OPEN_SRC)/components/Algorithm_AEB/src/boundingBoxCalculation.h + $$relative_path($$OPEN_SRC)/components/Algorithm_AEB/src/autonomousEmergencyBraking.h SOURCES += \ AlgorithmAeb_Tests.cpp \ - BoundingBoxCalculation_Tests.cpp \ - $$relative_path($$OPEN_SRC)/components/Algorithm_AEB/src/autonomousEmergencyBraking.cpp \ - $$relative_path($$OPEN_SRC)/components/Algorithm_AEB/src/boundingBoxCalculation.cpp + $$relative_path($$OPEN_SRC)/components/Algorithm_AEB/src/autonomousEmergencyBraking.cpp LIBS += \ -lopen_simulation_interface \ diff --git a/sim/tests/unitTests/components/Algorithm_Longitudinal/algorithmLongitudinal_Tests.cpp b/sim/tests/unitTests/components/Algorithm_Longitudinal/algorithmLongitudinal_Tests.cpp index b4d64943cdb6f0f79ddff7e717c156b1add381e3..81e203b3153c9a0555d7885becfa2a95d1a53b53 100644 --- a/sim/tests/unitTests/components/Algorithm_Longitudinal/algorithmLongitudinal_Tests.cpp +++ b/sim/tests/unitTests/components/Algorithm_Longitudinal/algorithmLongitudinal_Tests.cpp @@ -52,11 +52,12 @@ TEST_P(AlgorithmLongitudinalCalculationsGetEngineTorqueMax, AlgorithmLongitudina // Set up test VehicleModelParameters vehicleParameters; - vehicleParameters.maximumEngineTorque = 270.; - vehicleParameters.minimumEngineSpeed = 800.; - vehicleParameters.maximumEngineSpeed = 4000.; + vehicleParameters.properties = {{"MaximumEngineTorque", 270.}, + {"MinimumEngineSpeed", 800.}, + {"MaximumEngineSpeed", 4000.}}; - AlgorithmLongitudinalCalculations calculation{0.0, 0.0, vehicleParameters}; + std::function<void (CbkLogLevel, const char*, int, const std::string&)> Log; + AlgorithmLongitudinalCalculations calculation{0.0, 0.0, vehicleParameters, Log}; // Call test double result = calculation.GetEngineTorqueMax(data.input_EngineSpeed); @@ -114,12 +115,13 @@ TEST_P(AlgorithmLongitudinalCalculationsGetEngineTorqueMin, AlgorithmLongitudina // Set up test VehicleModelParameters vehicleParameters; - vehicleParameters.maximumEngineTorque = 270.; - vehicleParameters.minimumEngineTorque = 30.; - vehicleParameters.minimumEngineSpeed = 800.; - vehicleParameters.maximumEngineSpeed = 4000.; + vehicleParameters.properties = {{"MaximumEngineTorque", 270.}, + {"MinimumEngineTorque", 30.}, + {"MinimumEngineSpeed", 800.}, + {"MaximumEngineSpeed", 4000.}}; - AlgorithmLongitudinalCalculations calculation{0.0, 0.0, vehicleParameters}; + std::function<void (CbkLogLevel, const char*, int, const std::string&)> Log; + AlgorithmLongitudinalCalculations calculation{0.0, 0.0, vehicleParameters, Log}; // Call test double result = calculation.GetEngineTorqueMin(data.input_EngineSpeed); @@ -177,13 +179,19 @@ TEST_P(AlgorithmLongitudinalCalculationsGetAccFromEngineTorque, AlgorithmLongitu // Set up test VehicleModelParameters vehicleParameters; - vehicleParameters.axleRatio = 2.8; - std::vector<double> gRatios = {0., 4.1, 2.5, 1.4, 1., .9, .7}; - vehicleParameters.gearRatios = gRatios; - vehicleParameters.staticWheelRadius = .35; - vehicleParameters.weight = 800.; - - AlgorithmLongitudinalCalculations calculation{0.0, 0.0, vehicleParameters}; + vehicleParameters.properties = {{"AxleRatio", 2.8}, + {"GearRatio0", 0}, + {"GearRatio1", 4.1}, + {"GearRatio2", 2.5}, + {"GearRatio3", 1.4}, + {"GearRatio4", 1.}, + {"GearRatio5", .9}, + {"GearRatio6", .7}, + {"Mass", 800}}; + vehicleParameters.rearAxle.wheelDiameter = 0.7; + + std::function<void (CbkLogLevel, const char*, int, const std::string&)> Log; + AlgorithmLongitudinalCalculations calculation{0.0, 0.0, vehicleParameters, Log}; // Call test double result = calculation.GetAccFromEngineTorque(data.input_EngineTorque, data.input_ChosenGear); @@ -240,12 +248,18 @@ TEST_P(AlgorithmLongitudinalCalculationsGetEngineSpeedByVelocity, AlgorithmLongi // Set up tests VehicleModelParameters vehicleParameters; - vehicleParameters.axleRatio = 1.; - std::vector<double> gRatios = {0., 4.1, 2.5, 1.4, 1., .9, .7}; - vehicleParameters.gearRatios = gRatios; - vehicleParameters.staticWheelRadius = .25; - - AlgorithmLongitudinalCalculations calculation{0.0, 0.0, vehicleParameters}; + vehicleParameters.properties = {{"AxleRatio", 1}, + {"GearRatio1", 4.1}, + {"GearRatio2", 2.5}, + {"GearRatio3", 1.4}, + {"GearRatio4", 1.}, + {"GearRatio5", .9}, + {"GearRatio6", .7}, + {"Mass", 800}}; + vehicleParameters.rearAxle.wheelDiameter = 0.5; + + std::function<void (CbkLogLevel, const char*, int, const std::string&)> Log; + AlgorithmLongitudinalCalculations calculation{0.0, 0.0, vehicleParameters, Log}; // Call test double result = calculation.GetEngineSpeedByVelocity(data.input_Velocity, 4) * 2 * M_PI; @@ -302,14 +316,19 @@ TEST_P(AlgorithmLongitudinalCalculationsGetEngineTorqueAtGear, AlgorithmLongitud // Set up tests VehicleModelParameters vehicleParameters; - vehicleParameters.weight = 500.; - vehicleParameters.staticWheelRadius = .25; - vehicleParameters.numberOfGears = 6; - vehicleParameters.axleRatio = 1.; - std::vector<double> gRatios = {0., 4.1, 2.5, 1.4, 1., .9, .7}; - vehicleParameters.gearRatios = gRatios; - - AlgorithmLongitudinalCalculations calculation{0.0, 0.0, vehicleParameters}; + vehicleParameters.properties = {{"AxleRatio", 1.}, + {"GearRatio1", 4.1}, + {"GearRatio2", 2.5}, + {"GearRatio3", 1.4}, + {"GearRatio4", 1.}, + {"GearRatio5", .9}, + {"GearRatio6", .7}, + {"NumberOfGears", 6}, + {"Mass", 500}}; + vehicleParameters.rearAxle.wheelDiameter = 0.5; + + std::function<void (CbkLogLevel, const char*, int, const std::string&)> Log; + AlgorithmLongitudinalCalculations calculation{0.0, 0.0, vehicleParameters, Log}; // Call test double result = calculation.GetEngineTorqueAtGear(data.input_Gear, data.input_Acceleration); @@ -370,16 +389,17 @@ TEST_P(AlgorithmLongitudinalCalculationsPedalPosition, AlgorithmLongitudinalCalc // Set up test VehicleModelParameters vehicleParameters; - vehicleParameters.maximumEngineTorque = data.engineTorqueMax; - vehicleParameters.numberOfGears = 1; - vehicleParameters.gearRatios = {1.0, 1.0}; - vehicleParameters.axleRatio = 1.0; - vehicleParameters.staticWheelRadius = 1.0; - vehicleParameters.weight = 1000.0; - vehicleParameters.minimumEngineSpeed = -10000; - vehicleParameters.maximumEngineSpeed = 10000; - - AlgorithmLongitudinalCalculations calculation{0.0, data.input_Acceleration, vehicleParameters}; + vehicleParameters.properties = {{"AxleRatio", 1}, + {"GearRatio1", 1}, + {"NumberOfGears", 1}, + {"MaximumEngineTorque", data.engineTorqueMax}, + {"MinimumEngineSpeed", -10000}, + {"MaximumEngineSpeed", 10000}, + {"Mass", 1000}}; + vehicleParameters.rearAxle.wheelDiameter = 2.; + + std::function<void (CbkLogLevel, const char*, int, const std::string&)> Log; + AlgorithmLongitudinalCalculations calculation{0.0, data.input_Acceleration, vehicleParameters, Log}; // Call test calculation.CalculatePedalPositions(); diff --git a/sim/tests/unitTests/components/Dynamics_Collision/dynamicsCollision_Tests.cpp b/sim/tests/unitTests/components/Dynamics_Collision/dynamicsCollision_Tests.cpp index 444834b2820179ac80a257f3d08b72b450c7f5bf..05a530fbe618a2436ce2cefc1ca0881034a117bb 100644 --- a/sim/tests/unitTests/components/Dynamics_Collision/dynamicsCollision_Tests.cpp +++ b/sim/tests/unitTests/components/Dynamics_Collision/dynamicsCollision_Tests.cpp @@ -19,14 +19,15 @@ using ::testing::Return; using ::testing::ReturnPointee; using ::testing::NiceMock; +using ::testing::DoubleNear; class DynamicsCollision_Test : public ::testing::Test { public: DynamicsCollision_Test() { - heavyVehicle.weight = 2000.0; - lightVehicle.weight = 1000.0; + heavyVehicle.properties = {{"Mass", 2000.0}}; + lightVehicle.properties = {{"Mass", 1000.0}}; } protected: @@ -73,8 +74,8 @@ TEST_F(DynamicsCollision_Test, CollisionOfTwoAgentsOnlyInXDirection) dynamicsCollision.Trigger(0); - ASSERT_DOUBLE_EQ(dynamicsCollision.GetVelocity(), 30.0); - ASSERT_DOUBLE_EQ(dynamicsCollision.GetMovingDirection(), 0.0); + ASSERT_THAT(dynamicsCollision.GetVelocity(), DoubleNear(30.0, 1e-3)); + ASSERT_THAT(dynamicsCollision.GetMovingDirection(), DoubleNear(0.0, 1e-3)); } TEST_F(DynamicsCollision_Test, CollisionOfTwoAgentsOrthogonal) @@ -117,8 +118,8 @@ TEST_F(DynamicsCollision_Test, CollisionOfTwoAgentsOrthogonal) dynamicsCollision.Trigger(0); double expectedVelocity = 20.0 * std::sqrt(2); - ASSERT_DOUBLE_EQ(dynamicsCollision.GetVelocity(), expectedVelocity); - ASSERT_DOUBLE_EQ(dynamicsCollision.GetMovingDirection(), 0.25 * M_PI); + ASSERT_THAT(dynamicsCollision.GetVelocity(), DoubleNear(expectedVelocity, 1e-3)); + ASSERT_THAT(dynamicsCollision.GetMovingDirection(), DoubleNear(0.25 * M_PI, 1e-3)); } TEST_F(DynamicsCollision_Test, CollisionOfTwoAgentsOpposingDirections) @@ -211,8 +212,8 @@ TEST_F(DynamicsCollision_Test, CollisionOfThreeAgentsOnlyInXDirection) dynamicsCollision.Trigger(0); - ASSERT_DOUBLE_EQ(dynamicsCollision.GetVelocity(), 25.0); - ASSERT_DOUBLE_EQ(dynamicsCollision.GetMovingDirection(), 0.0); + ASSERT_THAT(dynamicsCollision.GetVelocity(), DoubleNear(25.0, 1e-3)); + ASSERT_THAT(dynamicsCollision.GetMovingDirection(), DoubleNear(0.0, 1e-3)); } TEST_F(DynamicsCollision_Test, CollisionOfThreeAgentsInDifferentDirections) @@ -264,8 +265,8 @@ TEST_F(DynamicsCollision_Test, CollisionOfThreeAgentsInDifferentDirections) dynamicsCollision.Trigger(0); double expectedVelocity = 20.0 * std::sqrt(2); - ASSERT_DOUBLE_EQ(dynamicsCollision.GetVelocity(), expectedVelocity); - ASSERT_DOUBLE_EQ(dynamicsCollision.GetMovingDirection(), -0.25 * M_PI); + ASSERT_THAT(dynamicsCollision.GetVelocity(), DoubleNear(expectedVelocity, 1e-3)); + ASSERT_THAT(dynamicsCollision.GetMovingDirection(), DoubleNear(-0.25 * M_PI, 1e-3)); } TEST_F(DynamicsCollision_Test, CollisionOfAgentWithFixedObject) @@ -298,7 +299,7 @@ TEST_F(DynamicsCollision_Test, CollisionOfAgentWithFixedObject) dynamicsCollision.Trigger(0); - ASSERT_DOUBLE_EQ(dynamicsCollision.GetVelocity(), 0.0); + ASSERT_THAT(dynamicsCollision.GetVelocity(), DoubleNear(0.0, 1e-3)); } diff --git a/sim/tests/unitTests/components/LimiterAccVehComp/limiterAccVehComp_Tests.cpp b/sim/tests/unitTests/components/LimiterAccVehComp/limiterAccVehComp_Tests.cpp index cfc4c0428bea4885a77320e765f061217c96d9cf..a44ed28d3888ac3ebb02738a5a4631a782411add 100644 --- a/sim/tests/unitTests/components/LimiterAccVehComp/limiterAccVehComp_Tests.cpp +++ b/sim/tests/unitTests/components/LimiterAccVehComp/limiterAccVehComp_Tests.cpp @@ -95,16 +95,20 @@ TEST_P(MaximumLimit, const auto accelerationInputSignal = std::make_shared<AccelerationSignal const>(ComponentState::Acting, INFINITY); VehicleModelParameters fakeVehicleParameters; - fakeVehicleParameters.weight = testInput.weight; - fakeVehicleParameters.frontSurface = testInput.frontSurface; - fakeVehicleParameters.airDragCoefficient = testInput.airDragCoefficient; - fakeVehicleParameters.maximumEngineTorque = testInput.maximumEngineTorque; - fakeVehicleParameters.maximumEngineSpeed = testInput.maximumEngineSpeed; - fakeVehicleParameters.minimumEngineSpeed = testInput.minimumEngineSpeed; - fakeVehicleParameters.gearRatios = testInput.gearRatios; - fakeVehicleParameters.axleRatio = testInput.axleRatio; - fakeVehicleParameters.staticWheelRadius = testInput.staticWheelRadius; - fakeVehicleParameters.frictionCoeff = 1.0; + fakeVehicleParameters.properties = {{"Mass", testInput.weight}, + {"FrontSurface", testInput.frontSurface}, + {"AirDragCoefficient", testInput.airDragCoefficient}, + {"MaximumEngineTorque", testInput.maximumEngineTorque}, + {"MinimumEngineSpeed", testInput.minimumEngineSpeed}, + {"MaximumEngineSpeed", testInput.maximumEngineSpeed}, + {"AxleRatio", testInput.axleRatio}, + {"FrictionCoefficient", 1.0}, + {"NumberOfGears", testInput.gearRatios.size()}}; + for (size_t i = 0; i < testInput.gearRatios.size(); i++) + { + fakeVehicleParameters.properties.insert({"GearRatio"+std::to_string(i+1), testInput.gearRatios[i]}); + } + fakeVehicleParameters.rearAxle.wheelDiameter = 2 * testInput.staticWheelRadius; const auto vehicleParameterInputSignal = std::make_shared<ParametersVehicleSignal const>(fakeVehicleParameters); diff --git a/sim/tests/unitTests/core/slave/agentSampler_Tests.cpp b/sim/tests/unitTests/core/slave/agentSampler_Tests.cpp index caa4ca982094eae1ed1f60de1c3597c5648eff47..e20aac8150d9ce354ace1ca6fa2783b029d900e3 100644 --- a/sim/tests/unitTests/core/slave/agentSampler_Tests.cpp +++ b/sim/tests/unitTests/core/slave/agentSampler_Tests.cpp @@ -350,8 +350,8 @@ TEST(DynamicAgentTypeGenerator, SetVehicleModelParameters) ON_CALL(profiles, GetVehicleProfiles()).WillByDefault(ReturnRef(vehicleProfiles)); VehicleModelParameters vehicleModelParameters; - vehicleModelParameters.length = 5.0; - vehicleModelParameters.width = 2.0; + vehicleModelParameters.boundingBoxDimensions.length = 5.0; + vehicleModelParameters.boundingBoxDimensions.width = 2.0; ON_CALL(vehicleModels, GetVehicleModel("SomeVehicleModel", _)).WillByDefault(Return(vehicleModelParameters)); openScenario::Parameters assignedParameters; @@ -360,8 +360,8 @@ TEST(DynamicAgentTypeGenerator, SetVehicleModelParameters) .SetVehicleModelParameters(assignedParameters); ASSERT_THAT(agentBuildInformation.vehicleModelName, Eq("SomeVehicleModel")); - ASSERT_THAT(agentBuildInformation.vehicleModelParameters.length, Eq(5.0)); - ASSERT_THAT(agentBuildInformation.vehicleModelParameters.width, Eq(2.0)); + ASSERT_THAT(agentBuildInformation.vehicleModelParameters.boundingBoxDimensions.length, Eq(5.0)); + ASSERT_THAT(agentBuildInformation.vehicleModelParameters.boundingBoxDimensions.width, Eq(2.0)); } TEST(DynamicParametersSampler, SampleSensorLatencies) diff --git a/sim/tests/unitTests/core/slave/modules/SpawnPointScenario/spawnPointScenario_Tests.cpp b/sim/tests/unitTests/core/slave/modules/SpawnPointScenario/spawnPointScenario_Tests.cpp index 29a3b10b7696bf139a5742a3d718fc874ff150cb..f882d6b856548c63f19e845b1ed42cb04129593d 100644 --- a/sim/tests/unitTests/core/slave/modules/SpawnPointScenario/spawnPointScenario_Tests.cpp +++ b/sim/tests/unitTests/core/slave/modules/SpawnPointScenario/spawnPointScenario_Tests.cpp @@ -41,7 +41,9 @@ MATCHER_P(MatchesAgentBlueprint, referenceAgentBlueprint, "matches blueprint") } const auto actualVehicleModelParameters = arg->GetVehicleModelParameters(); const auto expectedVehicleModelParameters = referenceAgentBlueprint.GetVehicleModelParameters(); - if (!(actualVehicleModelParameters.length == expectedVehicleModelParameters.length && actualVehicleModelParameters.width == expectedVehicleModelParameters.width && actualVehicleModelParameters.distanceReferencePointToLeadingEdge == expectedVehicleModelParameters.distanceReferencePointToLeadingEdge)) + if (!(actualVehicleModelParameters.boundingBoxDimensions.length == expectedVehicleModelParameters.boundingBoxDimensions.length + && actualVehicleModelParameters.boundingBoxDimensions.width == expectedVehicleModelParameters.boundingBoxDimensions.width + && actualVehicleModelParameters.boundingBoxCenter.x == expectedVehicleModelParameters.boundingBoxCenter.x)) { return false; } @@ -80,9 +82,9 @@ TEST(SpawnPointScenario, Trigger_SpawnsEgoAgentAccordingToScenarioWorldPosition) std::optional<AgentBlueprint> actualAgentBlueprintOptional; AgentBlueprint actualAgentBlueprint; VehicleModelParameters vehicleModelParameters; - vehicleModelParameters.length = 1; - vehicleModelParameters.width = 0.5; - vehicleModelParameters.distanceReferencePointToLeadingEdge = 0.5; + vehicleModelParameters.boundingBoxDimensions.length = 1; + vehicleModelParameters.boundingBoxDimensions.width = 0.5; + vehicleModelParameters.boundingBoxCenter.x = 0.; actualAgentBlueprint.SetVehicleModelParameters(vehicleModelParameters); actualAgentBlueprintOptional = actualAgentBlueprint; @@ -159,9 +161,9 @@ TEST(SpawnPointScenario, Trigger_SpawnsEgoAgentAccordingToScenarioLanePosition) std::optional<AgentBlueprint> actualAgentBlueprintOptional; AgentBlueprint actualAgentBlueprint; VehicleModelParameters vehicleModelParameters; - vehicleModelParameters.length = 1; - vehicleModelParameters.width = 0.5; - vehicleModelParameters.distanceReferencePointToLeadingEdge = 0.5; + vehicleModelParameters.boundingBoxDimensions.length = 1; + vehicleModelParameters.boundingBoxDimensions.width = 0.5; + vehicleModelParameters.boundingBoxCenter.x = 0.; actualAgentBlueprint.SetVehicleModelParameters(vehicleModelParameters); actualAgentBlueprintOptional = actualAgentBlueprint; @@ -245,9 +247,9 @@ TEST(SpawnPointScenario, Trigger_SpawnsScenarioAgentAccordingToScenarioWorldPosi std::optional<AgentBlueprint> actualAgentBlueprintOptional; AgentBlueprint actualAgentBlueprint; VehicleModelParameters vehicleModelParameters; - vehicleModelParameters.length = 1; - vehicleModelParameters.width = 0.5; - vehicleModelParameters.distanceReferencePointToLeadingEdge = 0.5; + vehicleModelParameters.boundingBoxDimensions.length = 1; + vehicleModelParameters.boundingBoxDimensions.width = 0.5; + vehicleModelParameters.boundingBoxCenter.x = 0.; actualAgentBlueprint.SetVehicleModelParameters(vehicleModelParameters); actualAgentBlueprintOptional = actualAgentBlueprint; @@ -324,9 +326,9 @@ TEST(SpawnPointScenario, Trigger_SpawnsScenarioAgentAccordingToScenarioLanePosit std::optional<AgentBlueprint> actualAgentBlueprintOptional; AgentBlueprint actualAgentBlueprint; VehicleModelParameters vehicleModelParameters; - vehicleModelParameters.length = 1; - vehicleModelParameters.width = 0.5; - vehicleModelParameters.distanceReferencePointToLeadingEdge = 0.5; + vehicleModelParameters.boundingBoxDimensions.length = 1; + vehicleModelParameters.boundingBoxDimensions.width = 0.5; + vehicleModelParameters.boundingBoxCenter.x = 0.; actualAgentBlueprint.SetVehicleModelParameters(vehicleModelParameters); actualAgentBlueprintOptional = actualAgentBlueprint; diff --git a/sim/tests/unitTests/core/slave/modules/World_OSI/agentAdapter_Tests.cpp b/sim/tests/unitTests/core/slave/modules/World_OSI/agentAdapter_Tests.cpp index 3770bd4c0576a15c368df819787a2bd51d4e9859..a6686b30fee566d88aeb144a3f426cff9f84d1b4 100644 --- a/sim/tests/unitTests/core/slave/modules/World_OSI/agentAdapter_Tests.cpp +++ b/sim/tests/unitTests/core/slave/modules/World_OSI/agentAdapter_Tests.cpp @@ -12,6 +12,7 @@ #include "gmock/gmock.h" #include "AgentAdapter.h" +#include "fakeMovingObject.h" using ::testing::Return; using ::testing::ReturnRef; @@ -23,6 +24,7 @@ using ::testing::Le; using ::testing::Lt; using ::testing::AllOf; using ::testing::DoubleEq; +using ::testing::ElementsAreArray; TEST(MovingObject_Tests, SetAndGetReferencePointPosition_ReturnsCorrectPosition) { @@ -33,7 +35,7 @@ TEST(MovingObject_Tests, SetAndGetReferencePointPosition_ReturnsCorrectPosition) osi3::MovingObject osiObject; OWL::Implementation::MovingObject movingObject(&osiObject, nullptr); movingObject.SetLength(8.0); - movingObject.SetDistanceReferencPointToLeadingEdge(7.0); + movingObject.SetBoundingBoxCenterToRear(7.0); movingObject.SetYaw(0.5); movingObject.SetReferencePointPosition(position); OWL::Primitive::AbsPosition resultPosition = movingObject.GetReferencePointPosition(); @@ -51,7 +53,7 @@ TEST(MovingObject_Tests, SetAndGetReferencePointPositionWithYawChangeInBetween_R osi3::MovingObject osiObject; OWL::Implementation::MovingObject movingObject(&osiObject, nullptr); movingObject.SetLength(8.0); - movingObject.SetDistanceReferencPointToLeadingEdge(7.0); + movingObject.SetBoundingBoxCenterToRear(7.0); movingObject.SetYaw(0.5); movingObject.SetReferencePointPosition(position); movingObject.SetYaw(0.7); @@ -70,7 +72,7 @@ TEST(MovingObject_Tests, SetReferencePointPosition_SetsCorrectPositionOnOSIObjec osi3::MovingObject osiObject; OWL::Implementation::MovingObject movingObject(&osiObject, nullptr); movingObject.SetLength(8.0); - movingObject.SetDistanceReferencPointToLeadingEdge(6.0); + movingObject.SetBoundingBoxCenterToRear(-2.0); movingObject.SetYaw(M_PI * 0.25); movingObject.SetReferencePointPosition(position); auto resultPosition = osiObject.base().position(); @@ -100,4 +102,66 @@ TEST(MovingObject_Tests, SetAgentType_MapsCorrectOSIType) movingObject.SetType(AgentVehicleType::Pedestrian); ASSERT_THAT(osiObject.type(), osi3::MovingObject_Type::MovingObject_Type_TYPE_PEDESTRIAN); -} \ No newline at end of file +} + +struct CalculateBoundingBoxData +{ + double yaw; + double roll; + std::vector<std::pair<double,double>> expectedResult; +}; + +class CalculateBoundingBox_Tests : public testing::Test, + public ::testing::WithParamInterface<CalculateBoundingBoxData> +{ +}; + +class TestWorldObject : public WorldObjectAdapter +{ +public: + TestWorldObject (OWL::Interfaces::WorldObject& baseTrafficObject) : + WorldObjectAdapter(baseTrafficObject) + {} + + virtual double GetLaneRemainder(const std::string& roadId, Side) const{}; + virtual ObjectTypeOSI GetType() const {} + virtual const ObjectPosition& GetObjectPosition() const {} + virtual double GetDistanceToStartOfRoad(MeasurementPoint mp, std::string roadId) const {return 0;} + virtual double GetVelocity(VelocityScope velocityScope) const {return 0;} + virtual bool Locate() {return false;} + virtual void Unlocate() {}; +}; + +TEST_P(CalculateBoundingBox_Tests, CalculateBoundingBox_ReturnCorrectPoints) +{ + const auto& data = GetParam(); + OWL::Fakes::MovingObject movingObject; + OWL::Primitive::AbsPosition position{10, 20, 0}; + ON_CALL(movingObject, GetReferencePointPosition()).WillByDefault(Return(position)); + OWL::Primitive::Dimension dimension{6.0, 2.0, 1.6}; + ON_CALL(movingObject, GetDimension()).WillByDefault(Return(dimension)); + OWL::Primitive::AbsOrientation orientation{data.yaw, 0, data.roll}; + ON_CALL(movingObject, GetAbsOrientation()).WillByDefault(Return(orientation)); + + TestWorldObject object(movingObject); + + auto result = object.GetBoundingBox2D(); + + std::vector<std::pair<double,double>> resultPoints; + for (const point_t point : result.outer()) + { + resultPoints.emplace_back(bg::get<0>(point), bg::get<1>(point)); + } + resultPoints.pop_back(); //in boost the last point is equal to the first + + ASSERT_THAT(resultPoints, ElementsAreArray(data.expectedResult)); +} + +INSTANTIATE_TEST_SUITE_P(BoundingBoxTest, CalculateBoundingBox_Tests, + testing::Values( +//! yaw roll expectedResult +CalculateBoundingBoxData{0.0, 0.0, {{7.0, 19.0},{7.0, 21.0}, {13.0, 21.0}, {13.0, 19.0}}}, +CalculateBoundingBoxData{M_PI_2, 0.0, {{11.0, 17.0},{9.0, 17.0}, {9.0, 23.0}, {11.0, 23.0}}}, +CalculateBoundingBoxData{0.0, M_PI_4, {{7.0, 20 - 2.6*M_SQRT1_2},{7.0, 20.0 + M_SQRT1_2}, {13.0, 20.0 + M_SQRT1_2}, {13.0, 20.0 - 2.6*M_SQRT1_2}}}, +CalculateBoundingBoxData{0.0, -M_PI_4, {{7.0, 20 - M_SQRT1_2},{7.0, 20.0 + 2.6*M_SQRT1_2}, {13.0, 20.0 + 2.6*M_SQRT1_2}, {13.0, 20.0 - M_SQRT1_2}}} +)); diff --git a/sim/tests/unitTests/core/slave/vehicleModelsImporter_Tests.cpp b/sim/tests/unitTests/core/slave/vehicleModelsImporter_Tests.cpp index ffd8522bfe76a013389b6161c9c124499ba712b0..36280a2e19293714e538e33d835f4e86d5965dfa 100644 --- a/sim/tests/unitTests/core/slave/vehicleModelsImporter_Tests.cpp +++ b/sim/tests/unitTests/core/slave/vehicleModelsImporter_Tests.cpp @@ -49,7 +49,7 @@ const std::string validVehicleString{ "<Center x=\"1.6\" y=\"1.7\" z=\"1.8\"/>" "<Dimensions width=\"1.9\" length=\"2.0\" height=\"2.1\"/>" "</BoundingBox>" - "<Performance maxSpeed=\"22.0\" maxDeceleration=\"23.0\"/>" + "<Performance maxSpeed=\"22.0\" maxAcceleration=\"10.0\" maxDeceleration=\"23.0\"/>" "<Axles>" "<FrontAxle maxSteering=\"1.1\" wheelDiameter=\"26.0\" trackWidth=\"27.0\" positionX=\"28.0\" positionZ=\"29.0\"/>" "<RearAxle maxSteering=\"0.0\" wheelDiameter=\"31.0\" trackWidth=\"32.0\" positionX=\"0.0\" positionZ=\"34.0\"/>" @@ -93,7 +93,7 @@ const std::string parametrizedVehicleString{ "<Center x=\"$CustomX\" y=\"1.7\" z=\"1.8\"/>" "<Dimensions width=\"1.9\" length=\"$CustomLength\" height=\"2.1\"/>" "</BoundingBox>" - "<Performance maxSpeed=\"$CustomSpeed\" maxDeceleration=\"23.0\"/>" + "<Performance maxSpeed=\"$CustomSpeed\" maxAcceleration=\"10.0\" maxDeceleration=\"23.0\"/>" "<Axles>" "<FrontAxle maxSteering=\"1.1\" wheelDiameter=\"26.0\" trackWidth=\"$CustomFrontTrackWidth\" positionX=\"28.0\" positionZ=\"29.0\"/>" "<RearAxle maxSteering=\"0.0\" wheelDiameter=\"31.0\" trackWidth=\"32.0\" positionX=\"0.0\" positionZ=\"34.0\"/>" @@ -134,15 +134,24 @@ TEST(VehicleModelsImporter, GivenValidVehicle_ImportsCorrectGeometry) ASSERT_NO_THROW(VehicleModelsImporter::ImportVehicleModel(fakeVehicleRoot, vehicleModelMap)); ASSERT_NO_THROW(vehicleModelParameters = vehicleModelMap.at("validCar").Get(EMPTY_PARAMETERS)); - EXPECT_THAT(vehicleModelParameters.length, DoubleEq(2.0)); - EXPECT_THAT(vehicleModelParameters.width, DoubleEq(1.9)); - EXPECT_THAT(vehicleModelParameters.height, DoubleEq(2.1)); - EXPECT_THAT(vehicleModelParameters.trackwidth, DoubleEq(32.0)); - EXPECT_THAT(vehicleModelParameters.wheelbase, DoubleEq(28.0)); - EXPECT_THAT(vehicleModelParameters.heightCOG, DoubleEq(0.0)); - EXPECT_THAT(vehicleModelParameters.distanceReferencePointToFrontAxle, DoubleEq(28.0)); - EXPECT_THAT(vehicleModelParameters.distanceReferencePointToLeadingEdge, DoubleEq(2.6)); // BB center x + length / 2 - EXPECT_THAT(vehicleModelParameters.staticWheelRadius, DoubleEq(15.5)); + EXPECT_THAT(vehicleModelParameters.boundingBoxDimensions.length, DoubleEq(2.0)); + EXPECT_THAT(vehicleModelParameters.boundingBoxDimensions.width, DoubleEq(1.9)); + EXPECT_THAT(vehicleModelParameters.boundingBoxDimensions.height, DoubleEq(2.1)); + EXPECT_THAT(vehicleModelParameters.boundingBoxCenter.x, DoubleEq(1.6)); + EXPECT_THAT(vehicleModelParameters.boundingBoxCenter.y, DoubleEq(1.7)); + EXPECT_THAT(vehicleModelParameters.boundingBoxCenter.z, DoubleEq(1.8)); + EXPECT_THAT(vehicleModelParameters.performance.maxSpeed, DoubleEq(22.0)); + EXPECT_THAT(vehicleModelParameters.performance.maxDeceleration, DoubleEq(23.0)); + EXPECT_THAT(vehicleModelParameters.frontAxle.maxSteering, DoubleEq(1.1)); + EXPECT_THAT(vehicleModelParameters.frontAxle.wheelDiameter, DoubleEq(26.0)); + EXPECT_THAT(vehicleModelParameters.frontAxle.trackWidth, DoubleEq(27.)); + EXPECT_THAT(vehicleModelParameters.frontAxle.positionX, DoubleEq(28.)); + EXPECT_THAT(vehicleModelParameters.frontAxle.positionZ, DoubleEq(29.)); + EXPECT_THAT(vehicleModelParameters.rearAxle.maxSteering, DoubleEq(0.0)); + EXPECT_THAT(vehicleModelParameters.rearAxle.wheelDiameter, DoubleEq(31.0)); + EXPECT_THAT(vehicleModelParameters.rearAxle.trackWidth, DoubleEq(32.)); + EXPECT_THAT(vehicleModelParameters.rearAxle.positionX, DoubleEq(0.)); + EXPECT_THAT(vehicleModelParameters.rearAxle.positionZ, DoubleEq(34.)); } TEST(VehicleModelsImporter, GivenValidVehicle_ImportsCorrectEngineParameters) @@ -155,11 +164,11 @@ TEST(VehicleModelsImporter, GivenValidVehicle_ImportsCorrectEngineParameters) ASSERT_NO_THROW(VehicleModelsImporter::ImportVehicleModel(fakeVehicleRoot, vehicleModelMap)); ASSERT_NO_THROW(vehicleModelParameters = vehicleModelMap.at("validCar").Get(EMPTY_PARAMETERS)); - EXPECT_THAT(vehicleModelParameters.decelerationFromPowertrainDrag, DoubleEq(3.0)); - EXPECT_THAT(vehicleModelParameters.minimumEngineTorque, DoubleEq(7.0)); - EXPECT_THAT(vehicleModelParameters.maximumEngineTorque, DoubleEq(8.0)); - EXPECT_THAT(vehicleModelParameters.minimumEngineSpeed, DoubleEq(9.0)); - EXPECT_THAT(vehicleModelParameters.maximumEngineSpeed, DoubleEq(10.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("DecelerationFromPowertrainDrag"), DoubleEq(3.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("MinimumEngineTorque"), DoubleEq(7.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("MaximumEngineTorque"), DoubleEq(8.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("MinimumEngineSpeed"), DoubleEq(9.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("MaximumEngineSpeed"), DoubleEq(10.0)); } TEST(VehicleModelsImporter, GivenValidGeometry_ImportsCorrectDynamics) @@ -172,18 +181,15 @@ TEST(VehicleModelsImporter, GivenValidGeometry_ImportsCorrectDynamics) ASSERT_NO_THROW(VehicleModelsImporter::ImportVehicleModel(fakeVehicleRoot, vehicleModelMap)); ASSERT_NO_THROW(vehicleModelParameters = vehicleModelMap.at("validCar").Get(EMPTY_PARAMETERS)); - EXPECT_THAT(vehicleModelParameters.steeringRatio, DoubleEq(15.0)); - EXPECT_THAT(vehicleModelParameters.axleRatio, DoubleEq(2.0)); - EXPECT_THAT(vehicleModelParameters.airDragCoefficient, DoubleEq(1.0)); - EXPECT_THAT(vehicleModelParameters.frictionCoeff, DoubleEq(4.0)); - EXPECT_THAT(vehicleModelParameters.frontSurface, DoubleEq(5.0)); - EXPECT_THAT(vehicleModelParameters.weight, DoubleEq(24.0)); - EXPECT_THAT(vehicleModelParameters.maxVelocity, DoubleEq(22.0)); - EXPECT_THAT(vehicleModelParameters.maximumSteeringWheelAngleAmplitude, DoubleEq(1.1 * 15.0)); // maxSteering front wheel * SteeringRatio - EXPECT_THAT(vehicleModelParameters.maxCurvature, DoubleEq(std::sin(1.1) / 28.0)); // sin(maxSteering fron wheel) / wheelbase - EXPECT_THAT(vehicleModelParameters.momentInertiaRoll, DoubleEq(11.0)); - EXPECT_THAT(vehicleModelParameters.momentInertiaPitch, DoubleEq(12.0)); - EXPECT_THAT(vehicleModelParameters.momentInertiaYaw, DoubleEq(13.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("SteeringRatio"), DoubleEq(15.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("AxleRatio"), DoubleEq(2.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("AirDragCoefficient"), DoubleEq(1.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("FrictionCoefficient"), DoubleEq(4.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("FrontSurface"), DoubleEq(5.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("Mass"), DoubleEq(24.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("MomentInertiaRoll"), DoubleEq(11.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("MomentInertiaPitch"), DoubleEq(12.0)); + EXPECT_THAT(vehicleModelParameters.properties.at("MomentInertiaYaw"), DoubleEq(13.0)); } TEST(VehicleModelsImporter, GivenValidVehicle_ImportsCorrectGearing) @@ -196,8 +202,10 @@ TEST(VehicleModelsImporter, GivenValidVehicle_ImportsCorrectGearing) ASSERT_NO_THROW(VehicleModelsImporter::ImportVehicleModel(fakeVehicleRoot, vehicleModelMap)); ASSERT_NO_THROW(vehicleModelParameters = vehicleModelMap.at("validCar").Get(EMPTY_PARAMETERS)); - EXPECT_THAT(vehicleModelParameters.numberOfGears, Eq(3)); - EXPECT_THAT(vehicleModelParameters.gearRatios, ElementsAre(0.0, 6.0, 6.1, 6.2)); + EXPECT_THAT(vehicleModelParameters.properties.at("NumberOfGears"), DoubleEq(3)); + EXPECT_THAT(vehicleModelParameters.properties.at("GearRatio1"), DoubleEq(6)); + EXPECT_THAT(vehicleModelParameters.properties.at("GearRatio2"), DoubleEq(6.1)); + EXPECT_THAT(vehicleModelParameters.properties.at("GearRatio3"), DoubleEq(6.2)); } TEST(VehicleModelsImporter, GivenParametrizedVehicle_ImportsCorrectParameters) @@ -210,10 +218,10 @@ TEST(VehicleModelsImporter, GivenParametrizedVehicle_ImportsCorrectParameters) ASSERT_NO_THROW(VehicleModelsImporter::ImportVehicleModel(fakeVehicleRoot, vehicleModelMap)); ASSERT_NO_THROW(vehicleModelParameters = vehicleModelMap.at("validCar")); - EXPECT_THAT(vehicleModelParameters.length.name, Eq("CustomLength")); - EXPECT_THAT(vehicleModelParameters.length.defaultValue, DoubleEq(3.0)); - EXPECT_THAT(vehicleModelParameters.maxVelocity.name, Eq("CustomSpeed")); - EXPECT_THAT(vehicleModelParameters.maxVelocity.defaultValue, DoubleEq(30.0)); + EXPECT_THAT(vehicleModelParameters.boundingBoxDimensions.length.name, Eq("CustomLength")); + EXPECT_THAT(vehicleModelParameters.boundingBoxDimensions.length.defaultValue, DoubleEq(3.0)); + EXPECT_THAT(vehicleModelParameters.performance.maxSpeed.name, Eq("CustomSpeed")); + EXPECT_THAT(vehicleModelParameters.performance.maxSpeed.defaultValue, DoubleEq(30.0)); EXPECT_THAT(vehicleModelParameters.frontAxle.trackWidth.name, Eq("CustomFrontTrackWidth")); EXPECT_THAT(vehicleModelParameters.frontAxle.trackWidth.defaultValue, DoubleEq(1.9)); } @@ -253,8 +261,7 @@ TEST(VehicleModelsImporter, GivenValidPedestrian_ImportsCorrectValues) // workaround for ground truth not being able to handle pedestrians //EXPECT_THAT(vehicleModelParameters.vehicleType, Eq(AgentVehicleType::Pedestrian)); EXPECT_THAT(vehicleModelParameters.vehicleType, Eq(AgentVehicleType::Car)); - EXPECT_THAT(vehicleModelParameters.width, DoubleEq(4.0)); - EXPECT_THAT(vehicleModelParameters.length, DoubleEq(5.0)); - EXPECT_THAT(vehicleModelParameters.height, DoubleEq(6.0)); - EXPECT_THAT(vehicleModelParameters.weight, DoubleEq(7.0)); + EXPECT_THAT(vehicleModelParameters.boundingBoxDimensions.width, DoubleEq(4.0)); + EXPECT_THAT(vehicleModelParameters.boundingBoxDimensions.length, DoubleEq(5.0)); + EXPECT_THAT(vehicleModelParameters.boundingBoxDimensions.height, DoubleEq(6.0)); }