Skip to content
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

Feature/synchronized action #1234

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open

Conversation

curious-jp
Copy link

@curious-jp curious-jp commented Apr 17, 2024

Description

Added API to call synchronized action.

Background

For further information look here .

Known Limitations

Currently, the conditions under which synchronized action can be fully achieved are quite limited.

Copy link

Checklist for reviewers ☑️

All references to "You" in the following text refer to the code reviewer.

  • Is this pull request written in a way that is easy to read from a third-party perspective?
  • Is there sufficient information (background, purpose, specification, algorithm description, list of disruptive changes, and migration guide) in the description of this pull request?
  • If this pull request contains a destructive change, does this pull request contain the migration guide?
  • Labels of this pull request are valid?
  • All unit tests/integration tests are included in this pull request? If you think adding test cases is unnecessary, please describe why and cross out this line.
  • The documentation for this pull request is enough? If you think adding documents for this pull request is unnecessary, please describe why and cross out this line.

@hakuturu583 hakuturu583 added the bump major If this pull request merged, bump major version of the scenario_simulator_v2 label May 1, 2024
@curious-jp curious-jp marked this pull request as ready for review May 1, 2024 09:10
@hakuturu583 hakuturu583 added bump minor If this pull request merged, bump minor version of the scenario_simulator_v2 and removed bump major If this pull request merged, bump major version of the scenario_simulator_v2 bump minor If this pull request merged, bump minor version of the scenario_simulator_v2 labels May 1, 2024
Comment on lines +902 to +903
auto EntityBase::isArrivedToTargetLaneletPose(
const CanonicalizedLaneletPose & target_lanelet_pose, const double threshold) -> bool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto EntityBase::isArrivedToTargetLaneletPose(
const CanonicalizedLaneletPose & target_lanelet_pose, const double threshold) -> bool
auto EntityBase::isArrivedToTargetLaneletPose(
const CanonicalizedLaneletPose & target_lanelet_pose, const double threshold) const -> bool

@@ -298,6 +298,7 @@ class EntityManager
FORWARD_TO_ENTITY(getDistanceToRightLaneBound, const);
FORWARD_TO_ENTITY(getEntityStatusBeforeUpdate, const);
FORWARD_TO_ENTITY(getEntityType, const);
FORWARD_TO_ENTITY(isArrivedToTargetLaneletPose, );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FORWARD_TO_ENTITY(isArrivedToTargetLaneletPose, );
FORWARD_TO_ENTITY(isArrivedToTargetLaneletPose, const);

Comment on lines +902 to +912
auto EntityBase::isArrivedToTargetLaneletPose(
const CanonicalizedLaneletPose & target_lanelet_pose, const double threshold) -> bool
{
const auto entity_distance_to_target = getDistanceToTargetLaneletPose(target_lanelet_pose);

if (entity_distance_to_target <= threshold) {
return true;
} else {
return false;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider using reachPosition function.

Comment on lines +922 to +924
/**
* @brief Check if the entity has already arrived to the target lanelet.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @brief Check if the entity has already arrived to the target lanelet.
*/
/// @brief Check if the entity has already arrived to the target lanelet.

Comment on lines +939 to +941
/**
* @brief This is function for synchronization.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @brief This is function for synchronization.
*/
/// @brief This is function for synchronization.

Comment on lines +963 to +965
/**
* @brief Making entity slow down since the speed is too fast
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* @brief Making entity slow down since the speed is too fast
*/
/// @brief Making entity slow down since the speed is too fast

if (!ego_distance.has_value()) {
RCLCPP_WARN_ONCE(
rclcpp::get_logger("traffic_simulator"),
"ego has already passed away or has some problem");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message is unclear.
Instead of "something is wrong," please describe the possible causes of the problem and how you are addressing it.
For example, "Please check the results of the scenario run to see if Ego has passed the target point. If not, please contact the developer as there may be an undiscovered bug.

}
const auto ego_velocity = other_status_.find("ego")->second.getTwist().linear.x;
const auto entity_velocity = this->getStatus().getTwist().linear.x;
const auto ego_arrival_time = (ego_velocity != 0) ? ego_distance.value() / ego_velocity : 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To determine if it is equal to 0 for a double type, consider the machine epsilon.


auto entity_velocity_to_synchronize = entity_velocity;

auto accel_limit_ = accel_limit * 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you multiply 1?
Also, why do you use auto? not const auto

const auto entity_velocity = this->getStatus().getTwist().linear.x;
const auto ego_arrival_time = (ego_velocity != 0) ? ego_distance.value() / ego_velocity : 0;

auto entity_velocity_to_synchronize = entity_velocity;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why do you use auto? not const auto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump minor If this pull request merged, bump minor version of the scenario_simulator_v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants