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

fix(pose_initializer): add topic subscription to direct initialization #8941

Conversation

meliketanrikulu
Copy link
Contributor

@meliketanrikulu meliketanrikulu commented Sep 23, 2024

Description

You need to call service to initialize directly now. Documentation
However, if you trust the GNSS pose, you may want to initialize directly with the GNSS pose. For example, we think that the pose coming from GNSS for the simulation environment can be used for initialization directly. We think that the feature of using GNSS poses should be added to activate the direct initialization feature for such cases.

This PR allows you to directly initialize the position from GNSS poses with a parameter change.

Related links

Parent Issue:
#8940

  • Link

How was this PR tested?

Test Steps:

1. Checkout autoware.universe

cd ~/autoware/src/universe/autoware.universe/
git remote add autoware.universe https://github.com/meliketanrikulu/autoware.universe.git
git remote update
git checkout fix/add_topic_subscription_to_direct_initialization

2. Compile updated packages:

cd ~/autoware
colcon build --symlink-install --packages-select autoware_pose_initializer autoware_default_adapi

3. Update Parameters

To enable the direct initialization feature using GNSS poses, the parameters must be adjusted accordingly.

  1. Open the config/default_adapi.param.yaml file.
  2. Set the initialization_method parameter to 1 to activate direct initialization.

4. Run autoware

source ~/autoware/install/setup.bash
ros2 launch autoware_launch logging_simulator.launch.xml map_path:=$HOME/autoware_map/sample-map-rosbag vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit

4. Run bag file

source ~/autoware/install/setup.bash
ros2 bag play ~/autoware_map/sample-rosbag/ -r 0.2 -s sqlite3

Instead, you can test PR in any sensor model or simulation environment and observe it with the GNSS pose to see the results.

Notes for reviewers

What do we expect to see?
If we set initialization method as 1 (DIRECT Initialization method), we expect to see the vehicle initialize at exactly the same point and with the same orientation as the GNSS pose.

Interface changes

None.

Effects on system behavior

None.

@github-actions github-actions bot added component:localization Vehicle's position determination in its environment. (auto-assigned) component:system System design and integration. (auto-assigned) labels Sep 23, 2024
Copy link

github-actions bot commented Sep 23, 2024

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@meliketanrikulu meliketanrikulu marked this pull request as draft September 23, 2024 13:57
@meliketanrikulu meliketanrikulu force-pushed the fix/add_topic_subscription_to_direct_initialization branch from 101508c to daf7949 Compare September 23, 2024 13:59
@meliketanrikulu meliketanrikulu force-pushed the fix/add_topic_subscription_to_direct_initialization branch from f4d9220 to 3db8ce1 Compare September 23, 2024 14:17
@github-actions github-actions bot added the type:documentation Creating or refining documentation. (auto-assigned) label Sep 23, 2024
@meliketanrikulu meliketanrikulu changed the title fix(pose_initializer): Add topic subscription to direct initialization fix(pose_initializer): add topic subscription to direct initialization Sep 23, 2024
@meliketanrikulu meliketanrikulu self-assigned this Sep 23, 2024
@meliketanrikulu
Copy link
Contributor Author

/review

Copy link

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Key issues to review

Possible Bug
The check for gnss_ being null or uninitialized is not clear. Ensure gnss_ is properly initialized before use to avoid potential null pointer dereference.

Parameter Validation
The initialization_method_ parameter is directly used without validation. Consider adding validation to ensure it only accepts expected values (e.g., 0 or 1).

@meliketanrikulu meliketanrikulu force-pushed the fix/add_topic_subscription_to_direct_initialization branch from de8073d to e7d83c9 Compare September 23, 2024 15:28
@meliketanrikulu
Copy link
Contributor Author

meliketanrikulu commented Sep 23, 2024

/improve --extended

Comment on lines +197 to +198
auto pose = req->pose_with_covariance.empty() ? get_gnss_pose().pose.pose
: req->pose_with_covariance.front().pose.pose;

Choose a reason for hiding this comment

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

Suggestion: To improve readability and avoid potential confusion, consider renaming the variable pose to something more descriptive like initial_pose. [readability, importance: 6]

Suggested change
auto pose = req->pose_with_covariance.empty() ? get_gnss_pose().pose.pose
: req->pose_with_covariance.front().pose.pose;
auto initial_pose = req->pose_with_covariance.empty() ? get_gnss_pose().pose.pose
: req->pose_with_covariance.front().pose.pose;

@@ -27,13 +27,15 @@ LocalizationNode::LocalizationNode(const rclcpp::NodeOptions & options)
adaptor.relay_message(pub_state_, sub_state_);
adaptor.init_cli(cli_initialize_);
adaptor.init_srv(srv_initialize_, this, &LocalizationNode::on_initialize, group_cli_);

initialization_method_ = declare_parameter<int>("initialization_method");

Choose a reason for hiding this comment

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

Suggestion: To ensure the parameter initialization_method is within the expected range, add a validation check after declaring the parameter. [validation, importance: 9]

Suggested change
initialization_method_ = declare_parameter<int>("initialization_method");
initialization_method_ = declare_parameter<int>("initialization_method");
if (initialization_method_ < 0 || initialization_method_ > 1) {
throw std::invalid_argument("initialization_method must be 0 (AUTO) or 1 (DIRECT)");
}

Comment on lines +28 to +31
if (initialization_method == 0)
internal->method = tier4_localization_msgs::srv::InitializeLocalization::Request::AUTO;
else if (initialization_method == 1)
internal->method = tier4_localization_msgs::srv::InitializeLocalization::Request::DIRECT;

Choose a reason for hiding this comment

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

Suggestion: To enhance readability and maintainability, use a switch statement instead of multiple if-else statements for setting the initialization_method. [readability, importance: 7]

Suggested change
if (initialization_method == 0)
internal->method = tier4_localization_msgs::srv::InitializeLocalization::Request::AUTO;
else if (initialization_method == 1)
internal->method = tier4_localization_msgs::srv::InitializeLocalization::Request::DIRECT;
switch (initialization_method) {
case 0:
internal->method = tier4_localization_msgs::srv::InitializeLocalization::Request::AUTO;
break;
case 1:
internal->method = tier4_localization_msgs::srv::InitializeLocalization::Request::DIRECT;
break;
default:
throw std::invalid_argument("Invalid initialization_method");
}

{
return convert_response(client->call(convert_request(req))->status);
return convert_response(client->call(convert_request(req, initialization_method))->status);

Choose a reason for hiding this comment

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

Suggestion: To ensure the convert_call function is robust, add a check to handle the case where the client call fails and returns a null response. [robustness, importance: 10]

Suggested change
return convert_response(client->call(convert_request(req, initialization_method))->status);
auto response = client->call(convert_request(req, initialization_method));
if (!response) {
throw std::runtime_error("Client call failed");
}
return convert_response(response->status);

Signed-off-by: Melike Tanrıkulu <[email protected]>
Signed-off-by: Melike Tanrıkulu <[email protected]>
@meliketanrikulu meliketanrikulu force-pushed the fix/add_topic_subscription_to_direct_initialization branch from e7d83c9 to b2235ec Compare September 23, 2024 16:58
@meliketanrikulu meliketanrikulu marked this pull request as ready for review September 23, 2024 17:34
Copy link
Contributor

@YamatoAndo YamatoAndo left a comment

Choose a reason for hiding this comment

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

This makes the ndt_enable and yabloc_enabled parameters meaningless. Please revise the implementation.

@meliketanrikulu
Copy link
Contributor Author

meliketanrikulu commented Sep 24, 2024

This PR parameter change is based on the addition of DIRECT initialization. However, instead of this, it seems more logical to decide whether the pose will be DIRECT initialized by checking if the covariance of the gnss poses is 0.For this reason I want to close this and opened a new PR. Here is the mentioned PR --> #8948

However, the covariance values ​​of the GNSS poses that come in the autoware_pose_initializer package are automatically changed . This parameter decide the covariance values of GNSS poses -->

Here is the GNSS poses covariance replaced here --> https://github.com/autowarefoundation/autoware.universe/blame/d25e9a1bbedc176d4e29c70b3ed9586808bdf813/localization/autoware_pose_initializer/src/pose_initializer_core.cpp#L221
What is the reason for this? Why are default values ​​assigned instead of using the covariance values ​​that come with the poses.
@isamu-takagi @YamatoAndo

@meliketanrikulu meliketanrikulu marked this pull request as draft September 24, 2024 14:06
@YamatoAndo
Copy link
Contributor

What is the reason for this? Why are default values ​​assigned instead of using the covariance values ​​that come with the poses.

It's not that we want the covariance of the GNSS, but rather, we want to determine the kind of distribution to use when spreading the particles.

@YamatoAndo
Copy link
Contributor

it seems more logical to decide whether the pose will be DIRECT initialized by checking if the covariance of the gnss poses is 0

I don't think this method is a good approach.

@xmfcx
Copy link
Contributor

xmfcx commented Sep 25, 2024

it seems more logical to decide whether the pose will be DIRECT initialized by checking if the covariance of the gnss poses is 0

I don't think this method is a good approach.

@YamatoAndo -san, Why do you think so?

If all the covariances are 0, or lower than some threshold we define, it means, the pose is very reliable and we can use it for direct initialization.

Overriding the original covariances should be an optional feature, not the default.

The GNSS already provides this information.

@xmfcx
Copy link
Contributor

xmfcx commented Sep 25, 2024

It's not that we want the covariance of the GNSS, but rather, we want to determine the kind of distribution to use when spreading the particles.

Why shouldn't you distribute it along the covariance ellipse?

@YamatoAndo
Copy link
Contributor

Why shouldn't you distribute it along the covariance ellipse?

In the first place, the position output by the GNSS receiver often does not match the correct position on the point cloud map. While GNSS positioning errors are one factor, it is difficult to perfectly align the point cloud map with GNSS positioning. Despite this, relying on the dispersion output by the GNSS receiver to determine the particle distribution is not a good idea.
Therefore, considering various errors, I believe it would be more robust to distribute particles with a wider spread than the dispersion output by the GNSS receiver.

@xmfcx
Copy link
Contributor

xmfcx commented Sep 27, 2024

@xmfcx xmfcx closed this Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:localization Vehicle's position determination in its environment. (auto-assigned) component:system System design and integration. (auto-assigned) type:documentation Creating or refining documentation. (auto-assigned)
Projects
Status: Under review
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants