-
Notifications
You must be signed in to change notification settings - Fork 60
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 (3/5): Remove non-API member functions: EntityManager’s member functions forwarded to EntityBase (1/2) #1473
RJD-1057 (3/5): Remove non-API member functions: EntityManager’s member functions forwarded to EntityBase (1/2) #1473
Conversation
… exceptions were thrown Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
… API Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
Signed-off-by: Mateusz Palczuk <[email protected]>
…p-time' into RJD-1057-remove-functions-forwarded-to-entity-base
…d' into RJD-1057-remove-functions-forwarded-to-entity-base
…ntityBase, remove forwarding
…ion to EntityBase, remove forwarding
…sInLanelet, remove forwarding
…tityBase, also some getters, left setVelocityLimit and setBehaviorParameter
…develop templated is() in EntityBase and use it, rename isEgoSpawned to isAnyEgoSpawned, refactor
…ng setBehaviorParameter and setVelocityLimit
…ng request*, move requestLaneChange to EntityBase
…n forwarding, set "waiting" as init action state in behavior_tree
…awned, move checkCollision directly to API
…develop getEgoEntity and dedicated methods in EgoEntity
…o RJD-1057-remove-functions-forwarded-to-entity-base
…y in calc it directly in evaluateTimeHeadway
…ctions-forwarded-to-entity-base-middle
Considering recent changes in #1497 to the relation (composition -> inheritance) of
|
@hakuturu583 @yamacir-kit |
Sorry, but please revert all of your latest changes related to #1497. The current state of FieldOperatorApplication is intentional (including all members being public). The concealer is currently being refactored, but is purposely stopped midway to reduce the burden of resolving conflicts in RJD-1057. The changes you have made are the ones I did not dare to make.. I appreciate your attitude, but please do not add any more changes to this already huge pull request. Reviewing a pull request with more than 1000 lines takes an excruciating amount of time. It takes a day just to get a rough understanding of the changes, and several more reads to be confident that merging the pull request will not cause any problems. The review burden grows exponentially, not linearly, with the number of lines of code. Making new code changes late in the review requires not only verifying the new changes, but also verifying whether the new changes affect existing or unchanged code, or vice versa. Because scenario_simulator_v2 is a tool used directly for Autoware testing, the attitude of "aggressively changing the code and quickly resolving bugs as soon as they are found" is not allowed. Whatever the reality, it is important that it is "believed" that there are no bugs or regressions and that it will remain stable. This means that if Autoware fails a simulator test, a bug in scenario_simulator_v2 should not be the first suspect. This is why we put so much effort into pull requests, and why we hate large diff increments. |
Does the PR now meet all expectations? Can we proceed with the regression tests? |
This Pull request was conflicted by #1472 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
But, currently CI/CD is broken.
So, please wait the CI was fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I forgot.
This branch must be follow upstream.
@dmoszynski friendly ping. |
Quality Gate passedIssues Measures |
@hakuturu583 @yamacir-kit Done 🙇 What do you think? 🙇 |
@dmoszynski I will review source code. And after that, please run regression test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code is LGTM.
Please run regression test.
No regressions confirmed here |
Description
Abstract
This pull request introduces the change of exposing direct access to Entity objects through the API. This change increases flexibility of using the API and removes the need to have many forwarding functions to Entities member functions.
Background
This pull request is one of many that aim to modularize the scenario_simulator_v2.
The main goal of this PR was to remove numerous member functions of
EntityManager
(and subsequently some of API too) that forwarded calls to Entities member functions:scenario_simulator_v2/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp
Lines 162 to 216 in 0dbf4ec
This has largely been achieved by exposing direct access to Entity and its member functions through the
API::getEntity
function:scenario_simulator_v2/simulation/traffic_simulator/include/traffic_simulator/api/api.hpp
Line 303 in 8940b3e
The following change was to adjust all cpp mock scenarios to use the new interface.
This is the main reason why this PR is so large - all mock scenarios had to be corrected.
Scenarios using the new interface have been changed similarly to the example below.
Before:
scenario_simulator_v2/mock/cpp_mock_scenarios/src/follow_lane/acquire_position_in_world_frame.cpp
Lines 41 to 64 in 0dbf4ec
After:
scenario_simulator_v2/mock/cpp_mock_scenarios/src/follow_lane/acquire_position_in_world_frame.cpp
Lines 41 to 64 in 8940b3e
Similar changes had to be applied to the whole codebase relying on the API like simulator_core.hpp.
What is more,
EgoEntity
has been modified in such a way, that the functionscenario_simulator_v2/simulation/traffic_simulator/include/traffic_simulator/entity/ego_entity.hpp
Line 68 in 0dbf4ec
has been replaced with a set of other functions below:
scenario_simulator_v2/simulation/traffic_simulator/include/traffic_simulator/entity/ego_entity.hpp
Lines 155 to 164 in 8940b3e
This change simplifies the interface of calling Ego specific actions like
engage
orsendCooperateCommand
.Details
Below are the detailed interface changes that have been made to
EntityStatus
,EntityBase
,EntityManager
and theAPI
.EntityStatus
laneMatchingSucceed
toisInLanelet
:auto laneMatchingSucceed() const noexcept -> bool;
->
auto isInLanelet() const noexcept -> bool;
EntityBase
Removed forwarded using macro to
EntityStatus
:laneMatchingSucceed
:laneMatchingSucceed
Removed
asFieldOperatorApplication
,reachPosition
andrequestClearRoute
:auto asFieldOperatorApplication() const -> concealer::FieldOperatorApplication &;
bool reachPosition(const geometry_msgs::msg::Pose & target_pose, const double tolerance) const;
bool reachPosition(const CanonicalizedLaneletPose & lanelet_pose, const double tolerance) const;
bool reachPosition(const std::string & target_name, const double tolerance) const;
void requestClearRoute();
Added:
isStopped
,isInPosition
andisInLanelet
.Note: Maybe it's a good idea to provide that
tolerance
is always of typestd::optional<double>
?EgoEntity
asFieldOperatorApplication
:auto asFieldOperatorApplication() const -> concealer::FieldOperatorApplication & override;
FieldOperatorApplicationFor
FieldOperatorApplication
(see this comment).asFieldOperatorApplication
:EntityManager
Removed forwarded using macro to
EntityBase
:activateOutOfRangeJob
,asFieldOperatorApplication
,cancelRequest
,get2DPolygon
,getBehaviorParameter
,getBoundingBox
,getCanonicalizedStatusBeforeUpdate
,getCurrentAccel
,getCurrentTwist
,getDefaultMatchingDistanceForLaneletPoseCalculation
,getEntityType
,getEntityTypename
,getLinearJerk
,getRouteLanelets
,getStandStillDuration
,getTraveledDistance
,isControlledBySimulator
,laneMatchingSucceed
,reachPosition
,requestAcquirePosition
,requestAssignRoute
,requestClearRoute
,requestFollowTrajectory
,requestLaneChange
,requestSpeedChange
,requestSynchronize
,requestWalkStraight
,setAcceleration
,setAccelerationLimit
,setAccelerationRateLimit
,setBehaviorParameter
,setControlledBySimulator
,setDecelerationLimit
,setDecelerationRateLimit
,setLinearJerk
,setLinearVelocity
,setMapPose
,setTwist
,setVelocityLimit
:,FORWARD_TO_ENTITY(activateOutOfRangeJob);
,FORWARD_TO_ENTITY(asFieldOperatorApplication);
,FORWARD_TO_ENTITY(cancelRequest);
,FORWARD_TO_ENTITY(get2DPolygon);
,FORWARD_TO_ENTITY(getBehaviorParameter);
,FORWARD_TO_ENTITY(getBoundingBox);
,FORWARD_TO_ENTITY(getCanonicalizedStatusBeforeUpdate);
,FORWARD_TO_ENTITY(getCurrentAccel);
,FORWARD_TO_ENTITY(getCurrentTwist);
,FORWARD_TO_ENTITY(getDefaultMatchingDistanceForLaneletPoseCalculation);
,FORWARD_TO_ENTITY(getEntityType);
,FORWARD_TO_ENTITY(getEntityTypename);
,FORWARD_TO_ENTITY(getLinearJerk);
,FORWARD_TO_ENTITY(getRouteLanelets);
,FORWARD_TO_ENTITY(getStandStillDuration);
,FORWARD_TO_ENTITY(getTraveledDistance);
,FORWARD_TO_ENTITY(isControlledBySimulator);
,FORWARD_TO_ENTITY(laneMatchingSucceed);
,FORWARD_TO_ENTITY(reachPosition);
,FORWARD_TO_ENTITY(requestAcquirePosition);
,FORWARD_TO_ENTITY(requestAssignRoute);
,FORWARD_TO_ENTITY(requestClearRoute);
,FORWARD_TO_ENTITY(requestFollowTrajectory);
,FORWARD_TO_ENTITY(requestLaneChange);
,FORWARD_TO_ENTITY(requestSpeedChange);
,FORWARD_TO_ENTITY(requestSynchronize);
,FORWARD_TO_ENTITY(requestWalkStraight);
,FORWARD_TO_ENTITY(setAcceleration);
,FORWARD_TO_ENTITY(setAccelerationLimit);
,FORWARD_TO_ENTITY(setAccelerationRateLimit);
,FORWARD_TO_ENTITY(setBehaviorParameter);
,FORWARD_TO_ENTITY(setControlledBySimulator);
,FORWARD_TO_ENTITY(setDecelerationLimit);
,FORWARD_TO_ENTITY(setDecelerationRateLimit);
,FORWARD_TO_ENTITY(setLinearJerk);
,FORWARD_TO_ENTITY(setLinearVelocity);
,FORWARD_TO_ENTITY(setMapPose);
,FORWARD_TO_ENTITY(setTwist);
FORWARD_TO_ENTITY(setVelocityLimit);
Removed
is
,isStopping
,isInLanelet
,checkCollision
,getEntityStatus
,getCurrentAction
:bool is(const std::string & name) const;
bool isStopping(const std::string & name) const;
bool isInLanelet(const std::string & name, const lanelet::Id lanelet_id, const double tolerance);
bool checkCollision(const std::string & first_entity_name, const std::string & second_entity_name);
auto getEntityStatus(const std::string & name) const -> const CanonicalizedEntityStatus &;
auto getCurrentAction(const std::string & name) const -> std::string;
Renamed
entityExists
toisEntitySpawned
auto entityExists(const std::string & name) -> bool;
->
auto isEntitySpawned(const std::string & name) -> bool;
Renamed
getEntity
togetEntityOrNullptr
(which does not throw an exception but returns nullptr)auto getEntity(const std::string & name) const -> std::shared_ptr<entity::EntityBase>;
->
auto getEntityOrNullptr(const std::string & name) const -> std::shared_ptr<entity::EntityBase>;
Renamed
isEgoSpawned
toisAnyEgoSpawned
:auto isEgoSpawned() const -> bool;
->
auto isAnyEgoSpawned() const -> bool;
Added
getEntity
(which throws an exception).getEgoEntity
:API
Removed forwarded using macro to
EntityManager
:activateOutOfRangeJob
,asFieldOperatorApplication
,cancelRequest
,checkCollision
,entityExists
,getBehaviorParameter
,getBoundingBox
,getCanonicalizedStatusBeforeUpdate
,getCurrentAccel
,getCurrentAction
,getCurrentTwist
,getDefaultMatchingDistanceForLaneletPoseCalculation
,getEgoName
,getEntityNames
,getEntityStatus
,getLinearJerk
,getStandStillDuration
,getTraveledDistance
,isEgoSpawned
,isInLanelet
,laneMatchingSucceed
,reachPosition
,requestAcquirePosition
,requestAssignRoute
,requestClearRoute
,requestFollowTrajectory
,requestSpeedChange
,requestSynchronize
,requestWalkStraight
,setAcceleration
,setAccelerationLimit
,setAccelerationRateLimit
,setBehaviorParameter
,setDecelerationLimit
,setDecelerationRateLimit
,setLinearVelocity
,setMapPose
,setTwist
,setVelocityLimit
:,FORWARD_TO_ENTITY_MANAGER(activateOutOfRangeJob);
,FORWARD_TO_ENTITY_MANAGER(asFieldOperatorApplication);
,FORWARD_TO_ENTITY_MANAGER(cancelRequest);
,FORWARD_TO_ENTITY_MANAGER(checkCollision);
,FORWARD_TO_ENTITY_MANAGER(entityExists);
,FORWARD_TO_ENTITY_MANAGER(getBehaviorParameter);
,FORWARD_TO_ENTITY_MANAGER(getBoundingBox);
,FORWARD_TO_ENTITY_MANAGER(getCanonicalizedStatusBeforeUpdate);
,FORWARD_TO_ENTITY_MANAGER(getCurrentAccel);
,FORWARD_TO_ENTITY_MANAGER(getCurrentAction);
,FORWARD_TO_ENTITY_MANAGER(getCurrentTwist);
,FORWARD_TO_ENTITY_MANAGER(getDefaultMatchingDistanceForLaneletPoseCalculation);
,FORWARD_TO_ENTITY_MANAGER(getEgoName);
,FORWARD_TO_ENTITY_MANAGER(getEntityNames);
,FORWARD_TO_ENTITY_MANAGER(getEntityStatus);
,FORWARD_TO_ENTITY_MANAGER(getLinearJerk);
,FORWARD_TO_ENTITY_MANAGER(getStandStillDuration);
,FORWARD_TO_ENTITY_MANAGER(getTraveledDistance);
,FORWARD_TO_ENTITY_MANAGER(isEgoSpawned);
,FORWARD_TO_ENTITY_MANAGER(isInLanelet);
,FORWARD_TO_ENTITY_MANAGER(laneMatchingSucceed);
,FORWARD_TO_ENTITY_MANAGER(reachPosition);
,FORWARD_TO_ENTITY_MANAGER(requestAcquirePosition);
,FORWARD_TO_ENTITY_MANAGER(requestAssignRoute);
,FORWARD_TO_ENTITY_MANAGER(requestClearRoute);
,FORWARD_TO_ENTITY_MANAGER(requestFollowTrajectory);
,FORWARD_TO_ENTITY_MANAGER(requestSpeedChange);
,FORWARD_TO_ENTITY_MANAGER(requestSynchronize);
,FORWARD_TO_ENTITY_MANAGER(requestWalkStraight);
,FORWARD_TO_ENTITY_MANAGER(setAcceleration);
,FORWARD_TO_ENTITY_MANAGER(setAccelerationLimit);
,FORWARD_TO_ENTITY_MANAGER(setAccelerationRateLimit);
,FORWARD_TO_ENTITY_MANAGER(setBehaviorParameter);
,FORWARD_TO_ENTITY_MANAGER(setDecelerationLimit);
,FORWARD_TO_ENTITY_MANAGER(setDecelerationRateLimit);
,FORWARD_TO_ENTITY_MANAGER(setLinearVelocity);
,FORWARD_TO_ENTITY_MANAGER(setMapPose);
,FORWARD_TO_ENTITY_MANAGER(setTwist);
FORWARD_TO_ENTITY_MANAGER(setVelocityLimit);
Removed
setEntityStatus
,requestLaneChange
andgetTimeHeadway
:auto setEntityStatus(...) -> void;
void requestLaneChange(...);
std::optional<double> getTimeHeadway(const std::string & from, const std::string & to);
Added
checkCollision
:EntityManager
:isEntitySpawned
,isAnyEgoSpawned
,getEntityOrNullptr
,getEgoEntity
:Examples of interface changes
Below are many examples of how to use the interface after the changes.
entityExists
->isEntitySpawned
->
is<>
->
getEntity
->getEntityOrNullptr
->
reachPosition
->isInPosition
->
getCurrentAction
->
setEntityStatus
->setStatus
->
asFieldOperatorApplication
-> replacements->
->
Others
->
->
References
INTERNAL LINK1
INTERNAL LINK2
Destructive Changes
--
Known Limitations
--