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

Add downsampleCloudMsg function to noetic-devel #58

Merged

Conversation

h-wata
Copy link

@h-wata h-wata commented Feb 7, 2024

PR Type

  • Feature
  • Bug fix
  • Refactor
  • Documentation
  • Other

Overview

@Alpaca-zip mentioned that there is a plan to add the downsampleCloudMsg feature to noetic-devel, as mentioned in the comment below, which is why this function is being added.

Detail

Test

  • I have tested this change with gazebo

Attention

  • There's no rush, so please review when you have time. Feel free to point out any issues with the implementation.

@Alpaca-zip Alpaca-zip self-requested a review February 8, 2024 06:28
Copy link
Owner

@Alpaca-zip Alpaca-zip left a comment

Choose a reason for hiding this comment

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

Thank you for submitting a Pull Request for my upcoming tasks. I appreciate your contribution and will proceed with a code review for this PR.

  • The function msg2TransformedCloud() appears to be unused and therefore seems unnecessary. You can find it here:
    Link to code snippet

  • The usage of cloud2TransformedCloud() is correct in the following part of the code:
    Link to code snippet
    However, the way cloud2TransformedCloud() is utilized here seems to be incorrect:
    Link to code snippet
    It should actually contain the following transformation:

    geometry_msgs::TransformStamped tf =
            tf_buffer_->lookupTransform(cam_model_.tfFrame(), header.frame_id, header.stamp);

    Therefore, it would be beneficial to modify cloud2TransformedCloud() to take the source and target frames as arguments to increase its versatility.

  • Regarding the GitHub Actions, all checks are failing due to an oversight on my part. It seems that removing the following lines should fix the issue:
    Link to CI configuration
    This fix is beyond the scope of this PR, so I will address it in a separate PR. However, if it's of concern to you, feel free to make the correction within this PR.

@Alpaca-zip
Copy link
Owner

I have checked the changes made so far. I would appreciate it if you could confirm the following points.

  • In the cloud2TransformedCloud() method described here:

    transformed_cloud = cloud2TransformedCloud(downsampled_cloud, cam_model_.tfFrame(), cloud_msg->header);
    it is necessary to transform the point cloud from header.frame_id (the LiDAR frame) to cam_model_.tfFrame() (the camera frame).

    On the other hand, in the cloud2TransformedCloud() method described here:

    cloud2TransformedCloud(detection_cloud_raw, cam_model_.tfFrame(), header);
    it is necessary to transform the point cloud from cam_model_.tfFrame() (the camera frame) to header.frame_id (the LiDAR frame).

    Currently, the implementation of cloud2TransformedCloud() in both cases is transforming the pointcloud from cam_model_.tfFrame() (the camera frame) to header.frame_id (the LiDAR frame).

    Here is an example implementation of cloud2TransformedCloud() that you might find useful:

    TrackerWithCloudNode::cloud2TransformedCloud(const pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud,
    const std::string& source_frame, const std::string& target_frame,
    const rclcpp::Time& stamp)
    {
    try
    {
    geometry_msgs::msg::TransformStamped tf_stamped = tf_buffer_->lookupTransform(target_frame, source_frame, stamp);
    Eigen::Affine3f eigen_transform = tf2::transformToEigen(tf_stamped.transform).cast<float>();
    pcl::PointCloud<pcl::PointXYZ>::Ptr transformed_cloud(new pcl::PointCloud<pcl::PointXYZ>());
    transformPointCloud(cloud, transformed_cloud, eigen_transform);
    return transformed_cloud;
    }
    catch (tf2::TransformException& e)
    {
    RCLCPP_WARN(this->get_logger(), "%s", e.what());
    return cloud;
    }
    }

    Notice
    Please be aware that the first argument of lookupTransform() is target_frame, and the second argument is source_frame.
    Link to reference

  • The following section means explicitly specifying the source branch of the pull request for checkout, but it seems that this method cannot find branches from forks. It appears that actions/checkout@v2 can automatically checkout?(*) the source branch of the pull request on GitHub Actions, so it is necessary to delete the following sections that are being used:

    with:
      ref: ${{ github.head_ref }}

    Specifically, these are:


英語があまり得意な方ではないので、ミスリーディングを減らすために日本語も残しておきます。
以下の点ご確認いただけますと幸いです。

  • 以下のcloud2TransformedCloud()では、header.frame_id(LiDARのframe)からcam_model_.tfFrame()(カメラのframe)に点群を変換する必要があります。

    transformed_cloud = cloud2TransformedCloud(downsampled_cloud, cam_model_.tfFrame(), cloud_msg->header);

    一方で以下のcloud2TransformedCloud()では、cam_model_.tfFrame()(カメラのframe)からheader.frame_id(LiDARのframe)に点群を変換する必要があります。

    cloud2TransformedCloud(detection_cloud_raw, cam_model_.tfFrame(), header);

    しかしながら現在の実装では、上記の両方においてcloud2TransformedCloud()cam_model_.tfFrame()(カメラのframe)からheader.frame_id(LiDARのframe)に点群を変換するようになってしまっています。

    ROS 2版ですがcloud2TransformedCloud()の実装例が以下にございますのでこちらを是非参考にしてください。

    TrackerWithCloudNode::cloud2TransformedCloud(const pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud,
    const std::string& source_frame, const std::string& target_frame,
    const rclcpp::Time& stamp)
    {
    try
    {
    geometry_msgs::msg::TransformStamped tf_stamped = tf_buffer_->lookupTransform(target_frame, source_frame, stamp);
    Eigen::Affine3f eigen_transform = tf2::transformToEigen(tf_stamped.transform).cast<float>();
    pcl::PointCloud<pcl::PointXYZ>::Ptr transformed_cloud(new pcl::PointCloud<pcl::PointXYZ>());
    transformPointCloud(cloud, transformed_cloud, eigen_transform);
    return transformed_cloud;
    }
    catch (tf2::TransformException& e)
    {
    RCLCPP_WARN(this->get_logger(), "%s", e.what());
    return cloud;
    }
    }

    Notice
    lookupTransform()の第一引数はtarget_frame、第二引数はsource_frameであることにご注意ください。
    Link to reference

  • 以下の箇所はプルリクエストのソースブランチを明示的に指定してチェックアウトすることを意味しますが、どうやらこの方法ではフォーク先のブランチは見つけられないようです。actions/checkout@v2はそれ単体でも自動でプルリクエストのソースブランチにチェックアウトをしてくれるらしい?(*)のでGithub Action上で利用している以下の箇所はすべて削除する必要があります。

    with:
      ref: ${{ github.head_ref }}

    削除の対象は以下の全てです。

@h-wata
Copy link
Author

h-wata commented Feb 13, 2024

@Alpaca-zip
Thank you your replay and apologize my misunderstandings.
Made the fixes from the review.
Could you please review the changes when you have a moment? Thanks.

@Alpaca-zip Alpaca-zip self-requested a review February 13, 2024 06:27
Copy link
Owner

@Alpaca-zip Alpaca-zip left a comment

Choose a reason for hiding this comment

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

src/tracker_with_cloud_node.cpp Outdated Show resolved Hide resolved
@Alpaca-zip
Copy link
Owner

https://github.com/Alpaca-zip/ultralytics_ros/actions/runs/7883310972/job/21510311360?pr=58

Sorry for the inconvenience, it seems that the GitHub Action failed because the repository you forked to did not have access to Secrets. The Docker login is not required just to build the image, so could you please remove the code in the following section?

- name: login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

I'd like to proceed with the merge after making this adjustment. Thank you for your cooperation.

@Alpaca-zip
Copy link
Owner

  • I have tested this change with KITTI data set.

@h-wata h-wata force-pushed the feature/downsampleCloudMsg_function branch from 3c1416f to 4c8a92f Compare February 14, 2024 01:53
@Alpaca-zip Alpaca-zip self-requested a review February 14, 2024 13:58
@Alpaca-zip Alpaca-zip merged commit ce0951f into Alpaca-zip:noetic-devel Feb 14, 2024
3 of 8 checks passed
@h-wata h-wata deleted the feature/downsampleCloudMsg_function branch February 15, 2024 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants