Skip to content

Commit

Permalink
Merge pull request #185 from RA-Consulting-GmbH/issue-183
Browse files Browse the repository at this point in the history
-added cardinality check and fixed isSet method in OSC 1.2
  • Loading branch information
Deakon997 authored Oct 13, 2022
2 parents e724ddd + 45bb740 commit ce1eb12
Show file tree
Hide file tree
Showing 34 changed files with 21,272 additions and 15,381 deletions.
2 changes: 2 additions & 0 deletions cpp/applications/openScenarioTester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ if (SUPPORT_OSC_1_2)
"src/TestVariableValidationV1_2.h"
"src/TestDeprecatedValidationV1_2.h"
"src/TestExamplesOscV1_2.h"
"src/TestCardinalityV1_2.h"
)
endif (SUPPORT_OSC_1_2)

Expand Down Expand Up @@ -189,6 +190,7 @@ set( SOURCES
"src/TestVariableValidationV1_2.cpp"
"src/TestDeprecatedValidationV1_2.cpp"
"src/TestExamplesOscV1_2.cpp"
"src/TestCardinalityV1_2.cpp"
)
endif (SUPPORT_OSC_1_2)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@
<VehicleCategoryDistributionEntry category="car" weight="2"></VehicleCategoryDistributionEntry>
</VehicleCategoryDistribution>
<ControllerDistribution>
<ControllerDistributionEntry weight="2"></ControllerDistributionEntry>
<ControllerDistributionEntry weight="2" >
<CatalogReference catalogName="DriverCatalog" entryName="DefaultDriver"/>
</ControllerDistributionEntry>
</ControllerDistribution>
</TrafficDefinition>
</TrafficSourceAction>
Expand All @@ -280,7 +282,9 @@
<VehicleCategoryDistributionEntry category="car" weight="2"></VehicleCategoryDistributionEntry>
</VehicleCategoryDistribution>
<ControllerDistribution>
<ControllerDistributionEntry weight="2"></ControllerDistributionEntry>
<ControllerDistributionEntry weight="2" >
<CatalogReference catalogName="DriverCatalog" entryName="DefaultDriver"/>
</ControllerDistributionEntry>
</ControllerDistribution>
</TrafficDefinition>
<InitialSpeedRange upperLimit="3" lowerLimit="4"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</ParameterValueSet>
</ValueSetDistribution>
</DeterministicMultiParameterDistribution>
<!-- Xor elements DeterministicMultiParameterDistribution, DeterministicSingleParameterDistribution
<DeterministicSingleParameterDistribution parameterName="Ego_Speed">
<DistributionSet>
<Element value="10.0" />
Expand All @@ -28,6 +29,7 @@
<Range lowerLimit="15.0" upperLimit="25.0" />
</DistributionRange>
</DeterministicSingleParameterDistribution>
-->
</Deterministic>
</ParameterValueDistribution>
</OpenSCENARIO>
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "TestFlexInterfaceV1_2.h"
#include "TestInjectedParametersV1_2.h"
#include "TestWriterApiV1_2.h"
#include "TestCardinalityV1_2.h"
#endif

#ifdef SUPPORT_OSC_1_0
Expand Down Expand Up @@ -263,6 +264,7 @@ bool TestV1_2(std::string basePath)
NET_ASAM_OPENSCENARIO::v1_2::TestVariableValidation testVariableValidation(basePath);
NET_ASAM_OPENSCENARIO::v1_2::TestDeprecatedValidation testDeprecatedValidation(basePath);
NET_ASAM_OPENSCENARIO::v1_2::TestExamplesOsc testExamplesOsc(basePath);
NET_ASAM_OPENSCENARIO::v1_2::TestCardinality testCardinality(basePath);

auto result = true;

Expand Down Expand Up @@ -350,6 +352,9 @@ bool TestV1_2(std::string basePath)
result = testDeprecatedValidation.TestValidation() && result;

result = testExamplesOsc.TestScenarios() && result;

result = testCardinality.TestEmptyStory() && result;
result = testCardinality.TestMultipleGroupElements() && result;

return result;
}
Expand Down
63 changes: 63 additions & 0 deletions cpp/applications/openScenarioTester/src/TestCardinalityV1_2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2020 RA Consulting
*
* RA Consulting GmbH licenses this file under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "TestCardinalityV1_2.h"
#include "FileResourceLocator.h"
#include <iostream>

#include "PropertyTreeContext.h"
#include "ScenarioLoaderException.h"

#undef ERROR

namespace NET_ASAM_OPENSCENARIO
{
namespace v1_2
{
TestCardinality::TestCardinality(std::string& executablePath) : TestBase(executablePath)
{
}

bool TestCardinality::TestEmptyStory()
{
ClearMessageLogger();
const std::string kFileName = _executablePath + "/" + kInputDir + "cardinalityChecks/EmptyStory.xosc";
(void)ExecuteParsing(kFileName);

std::vector<NET_ASAM_OPENSCENARIO::FileContentMessage> messages;
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage(
"Too few children children are set (Act). min defined: 1. actual size: 0",
NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(65, 4, kFileName)));
const bool kResult = Assert(AssertMessages(messages, NET_ASAM_OPENSCENARIO::ERROR, _messageLogger), ASSERT_LOCATION);
return kResult;
}

bool TestCardinality::TestMultipleGroupElements()
{
ClearMessageLogger();
const std::string kFileName = _executablePath + "/" + kInputDir + "cardinalityChecks/ActionsMultipleElements.xosc";
(void)ExecuteParsing(kFileName);

std::vector<NET_ASAM_OPENSCENARIO::FileContentMessage> messages;
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage(
"One of these properties is required (GlobalAction; UserDefinedAction; PrivateAction)",
NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(157, 14, kFileName)));
const bool kResult = Assert(AssertMessages(messages, NET_ASAM_OPENSCENARIO::ERROR, _messageLogger), ASSERT_LOCATION);
return kResult;
}
}
}
35 changes: 35 additions & 0 deletions cpp/applications/openScenarioTester/src/TestCardinalityV1_2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2020 RA Consulting
*
* RA Consulting GmbH licenses this file under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once
#include "TestBaseV1_2.h"

namespace NET_ASAM_OPENSCENARIO
{
namespace v1_2
{
class TestCardinality: public TestBase
{
public:

TestCardinality(std::string& executablePath);

bool TestEmptyStory();
bool TestMultipleGroupElements();
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ namespace NET_ASAM_OPENSCENARIO
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'value' is deprecated and must not be used with element 'BrakePercent' or 'BrakeForce'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(179, 18, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'intensity' is deprecated and must not be used with attribute 'illuminance'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(79, 16, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'velocity' is deprecated and must not be used with attribute 'speed'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(257, 18, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'velocity' is deprecated and must not be used with element 'InitialSpeedRange'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(276, 18, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'velocity' is deprecated and must not be used with element 'InitialSpeedRange'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(278, 18, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'cloudState' is deprecated and must not be used with attribute 'fractionalCloudCover'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(78, 14, kFilename)));
// From 1.1
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'curvatureDot' is deprecated and must not be used with attribute 'isSetCurvaturePrime'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(298, 26, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'alongRoute' is deprecated and must not be used with attribute 'coordinateSystem'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(323, 25, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'alongRoute' is deprecated and must not be used with attribute 'relativeDistanceType'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(323, 25, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'curvatureDot' is deprecated and must not be used with attribute 'isSetCurvaturePrime'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(302, 26, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'alongRoute' is deprecated and must not be used with attribute 'coordinateSystem'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(327, 25, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'alongRoute' is deprecated and must not be used with attribute 'relativeDistanceType'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(327, 25, kFilename)));
messages.push_back(NET_ASAM_OPENSCENARIO::FileContentMessage("Attribute 'intensity' is deprecated and must not be used with attribute 'precipitationIntensity'.", NET_ASAM_OPENSCENARIO::ERROR, NET_ASAM_OPENSCENARIO::Textmarker(80, 16, kFilename)));

bool result = Assert(AssertMessages(messages, NET_ASAM_OPENSCENARIO::ERROR, _messageLogger), ASSERT_LOCATION);
Expand Down
Loading

0 comments on commit ce1eb12

Please sign in to comment.