-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RJD-1057 (5/5): Remove non-API member functions: Improve responsibility simulator_core<->api #1337
Draft
TauTheLepton
wants to merge
53
commits into
RJD-1057-remove-functions-forwarded-to-entity-base-refactor
Choose a base branch
from
ref/RJD-1057-improve-responsibility-simulator-core-api
base: RJD-1057-remove-functions-forwarded-to-entity-base-refactor
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,287
−1,320
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…lized functions for distance calculations for each coordinate system
…nput instead of CanonicalizedLaneletPose
…ded-to-entity-base' into ref/RJD-1057-improve-responsibility-simulator-core-api
…wn() and setStatus() methods
…ded-to-entity-base-refactor' into ref/RJD-1057-improve-responsibility-simulator-core-api
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
…ze(), guarantee canonicalization of input in API, add exceptions to canonicalize()
… of https://github.com/tier4/scenario_simulator_v2 into ref/RJD-1057-improve-responsibility-simulator-core-api
…ce, move it to distance utils and use globally
…ded-to-entity-base-refactor' into ref/RJD-1057-improve-responsibility-simulator-core-api
…ded-to-entity-base-refactor' into ref/RJD-1057-improve-responsibility-simulator-core-api
|
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
…ed-to-entity-base-refactor' into ref/RJD-1057-improve-responsibility-simulator-core-api Signed-off-by: Mateusz Palczuk <[email protected]>
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
…ed-to-entity-base-refactor' into ref/RJD-1057-improve-responsibility-simulator-core-api Signed-off-by: Mateusz Palczuk <[email protected]>
…ed-to-entity-base-refactor' into ref/RJD-1057-improve-responsibility-simulator-core-api Signed-off-by: Mateusz Palczuk <[email protected]>
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
Fix the `SimulatorCore::DistanceConditionEvaluation::prerequisite` helper function to work not only with `std::string` but also other types convertible to `std::string` like `openscenario_interpreter::EntityRef` Signed-off-by: Mateusz Palczuk <[email protected]>
No regressions confirmed here |
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
…Entity` Signed-off-by: Mateusz Palczuk <[email protected]>
Change behavior from not matching the templated function to matching to everything, but then asserting the correct types. This better reflects the intention, as we do not want to match some other function for different types, but to terminate the compilation Signed-off-by: Mateusz Palczuk <[email protected]>
…ctor' into ref/RJD-1057-improve-responsibility-simulator-core-api
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
DO NOT MERGE | WHEN THE RIGHT TIME COMES, TARGET WILL BE CHANGED TO MASTER
Abstract
This pull request aims to improve the responsibility division between
traffic_simulator
API andopenscenario_interpreter
SimulatorCore.The changes include refactoring, renaming functions and reordering them in the source files. So even though the number of changes reported by github is rather high, many of the changes consist of moving functions around with slight if none modifications.
Background
This pull request is one of many that aim to modularize the scenario_simulator_v2.
Details
Canonicalization
The main changes are that canonicalization process (of lanelet pose) is a responsibility of
traffic_simulator
. This way the communication withtraffic_simulator
API is done on NON canonicalized data structures and traffic_simulator has to canonicalize the data.Note
A result of aforementioned changes, most of
cpp_mock_scenarios
had to be adjusted to communicate using regular lanelet pose instead of canonicalized one.This leads to GitHub reporting many lines changed and the PR seem to be big, but many of these changes are simply adjusting
cpp_mock_scenarios
like the following.Before
scenario_simulator_v2/mock/cpp_mock_scenarios/src/collision/crashing_npc.cpp
Lines 54 to 56 in bcc35ae
After
scenario_simulator_v2/mock/cpp_mock_scenarios/src/collision/crashing_npc.cpp
Lines 54 to 56 in f1cb1c2
Important
Because of the change of canonicalization, the NativeLanePosition type in SimulatorCore has been changed
Before
scenario_simulator_v2/openscenario/openscenario_interpreter/include/openscenario_interpreter/simulator_core.hpp
Lines 37 to 39 in bcc35ae
After
scenario_simulator_v2/openscenario/openscenario_interpreter/include/openscenario_interpreter/simulator_core.hpp
Lines 36 to 38 in f1cb1c2
SimulatorCore
This PR focuses on improving the interaction between the API and SimulatorCore.
This is why SimulatorCore needed many modifications.
Below they are broken down into the subclasses of SimulatorCore.
General
Changes include conversion of some SimulatorCore classes member functions to explicitly list arguments instead of using the variadic templates.
For example
applyAddEntityAction
before changescenario_simulator_v2/openscenario/openscenario_interpreter/include/openscenario_interpreter/simulator_core.hpp
Lines 302 to 306 in dbf0c03
and after the change
scenario_simulator_v2/openscenario/openscenario_interpreter/include/openscenario_interpreter/simulator_core.hpp
Lines 332 to 338 in 6c8d04b
Many member functions of
SimulatorCore::ConditionEvaluation
have been changed to include a check whether the Entity exists and if not return NaN or other appropriate default value.For example
SimulatorCore::ConditionEvaluation::evaluateCollisionCondition
before changescenario_simulator_v2/openscenario/openscenario_interpreter/include/openscenario_interpreter/simulator_core.hpp
Lines 540 to 544 in dbf0c03
and after the change
scenario_simulator_v2/openscenario/openscenario_interpreter/include/openscenario_interpreter/simulator_core.hpp
Lines 641 to 649 in 6c8d04b
Others
Function
NonStandardOperation::activateNonUserDefinedControllers
has been moved directly to the SimulatorCore class.CoordinateSystemConversion
SimulatorCore::CoordinateSystemConversion::convert<>
functions have been renamed toconvertToNativeLanePosition
andconvertToNativeWorldPosition
and slightly improved.CoordinateSystemConversion::makeNativeRelativeWorldPosition
functions have been removed, as they were no longer needed.SimulatorCore::CoordinateSystemConversion
have been refactored and moved to a new classSimulatorCore::DistanceConditionEvaluation
as they were only used for distance calculations anyway.DistanceConditionEvaluation
This subclass has been added to group all distance functions. Many functions added to this class are functions moved from
SimulatorCore::CoordinateSystemConversion
.Note
Keep in mind, that due to the fact, that many underlying API functions can be passed some combination of Entity name and position as arguments, many function of this class have been converted to templates to accept different types as arguments.
These functions perform common checks whether an Entity exists (when the name is passed as an argument). These checks have been separated in a
prerequisite
function.CoordinateSystemConversion
class have been removed in favor of new distance functions, because the relative pose was only used for distance calculation.CoordinateSystemConversion::makeNativeRelativeLanePosition
has been removed in favor ofDistanceConditionEvaluation::lateralEntityDistance
andDistanceConditionEvaluation::longitudinalEntityDistance
CoordinateSystemConversion::makeNativeBoundingBoxRelativeLanePosition
has been removed in favor ofDistanceConditionEvaluation::lateralEntityBoundingBoxDistance
andDistanceConditionEvaluation::longitudinalEntityBoundingBoxDistance
CoordinateSystemConversion::makeNativeBoundingBoxRelativeWorldPosition
has been removed in favor ofDistanceConditionEvaluation::euclideanBoundingBoxDistance
DistanceConditionEvaluation::euclideanDistance
has been added for distance calculation.CoordinateSystemConversion::evaluateLateralRelativeLanes
has been changed tolateralRelativeLanes
with some slight modifications.lateralLaneDistance
has been developed to be used instead ofCoordinateSystemConversion::makeNativeRelativeWorldPosition
longitudinalLaneDistance
has been developed to be used instead ofCoordinateSystemConversion::makeNativeRelativeWorldPosition
lateralLaneBoundingBoxDistance
has been developed to be used instead ofCoordinateSystemConversion::makeNativeBoundingBoxRelativeLanePosition
longitudinalLaneBoundingBoxDistance
has been developed to be used instead ofCoordinateSystemConversion::makeNativeBoundingBoxRelativeLanePosition
ActionApplication
activatePerformanceAssertion
has been moved fromNonStandardOperation
class.ConditionEvaluation
evaluateRelativeSpeed
has been divided into part inConditionEvaluation
scenario_simulator_v2/openscenario/openscenario_interpreter/include/openscenario_interpreter/simulator_core.hpp
Lines 622 to 630 in f1cb1c2
and part in
API
scenario_simulator_v2/simulation/traffic_simulator/src/api/api.cpp
Lines 458 to 473 in f1cb1c2
evaluateTimeHeadaway
has been divided into part inConditionEvaluation
scenario_simulator_v2/openscenario/openscenario_interpreter/include/openscenario_interpreter/simulator_core.hpp
Lines 651 to 660 in f1cb1c2
and part in
API
scenario_simulator_v2/simulation/traffic_simulator/src/api/api.cpp
Lines 374 to 389 in f1cb1c2
NonStandardOperation
evaluateCurrentState
evaluateRelativeHeading
TrafficLightsOperation
NonStandardOperation
setConventionalTrafficLightsState
setConventionalTrafficLightConfidence
getConventionalTrafficLightsComposedState
compareConventionalTrafficLightsState
resetConventionalTrafficLightPublishRate
setV2ITrafficLightsState
resetV2ITrafficLightPublishRate
Syntax
Important
Because of the changes listed in
SimulatorCore
, manyopenscenario_interpreter
syntax classes had to be adjusted.For most of the syntax classes the changes were limited only to changing the parent class in inheritance structure, or just using the new functions from
SimulatorCore
rather than the old ones.DistanceCondition
Many changes have been applied to
DistanceCondition
ofopenscenario_interpreter
. Most of these changes are simplifications that don't use the overloaded lambda functions and visitors, but rather just use newly developedSimulatorCore::DistanceConditionEvaluation
member functions.For example the function
DistanceCondition::distance<CoordinateSystem::entity, RelativeDistanceType::euclidianDistance, RoutingAlgorithm::undefined, false>
has been changed fromscenario_simulator_v2/openscenario/openscenario_interpreter/src/syntax/distance_condition.cpp
Lines 144 to 176 in dbf0c03
to
scenario_simulator_v2/openscenario/openscenario_interpreter/src/syntax/distance_condition.cpp
Lines 143 to 149 in 6c8d04b
The simplification comes from reducing the overloaded lambdas that have identical implementations to just one function call.
ReachPositionCondition
Similarly to
DistanceCondition
the structure has been reworked to not use overloaded lambda functions and visitors, but rather directly call distance function.Distance calculation in
traffic_simulator
For simplicity some distance calculation functions have been added to
traffic_simulator
API so thatopenscenario_interpreter
did not implement distance calculations but could use these functions herescenario_simulator_v2/simulation/traffic_simulator/include/traffic_simulator/api/api.hpp
Lines 245 to 298 in 6c8d04b
EntityBase (
traffic_simulator
)requestSynchronize
In this PR additionally to all other changes, the
EntityBase::requestSynchronize
function has been refactored in order to make it easier to read and understand.Most of the logic code was kept unchanged, but some reformating was applied to use the init-statement to declare variables inside the if statements which in the same time checks whether the value is correct.
What is more, a check whether the entity this synchronize request is applied on is an Ego entity, has been moved to overloaded member function of
EgoEntity
class herescenario_simulator_v2/simulation/traffic_simulator/src/entity/ego_entity.cpp
Lines 279 to 285 in e5f3ce9
References
INTERNAL LINK 1
INTERNAL LINK 2
Destructive Changes
--
Known Limitations
--