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/init on tf #40

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Feature/init on tf #40

wants to merge 3 commits into from

Conversation

nyxrobotics
Copy link

@nyxrobotics nyxrobotics commented Feb 7, 2024

Summary

Attention

  • hdl_localization立ち上げと同時にロボットが動いていると収束が悪い問題は解決できませんでした

@nyxrobotics nyxrobotics marked this pull request as ready for review February 7, 2024 12:09
@@ -267,11 +267,13 @@ void HdlLocalizationNodelet::pointsCallback(const sensor_msgs::PointCloud2ConstP
// transform pointcloud into base_frame_id
std::string tf_error;
pcl::PointCloud<HdlLocalizationNodelet::PointT>::Ptr cloud(new pcl::PointCloud<HdlLocalizationNodelet::PointT>());
if (this->tf_buffer_.canTransform(base_frame_id_, pcl_cloud->header.frame_id, stamp, ros::Duration(0.1), &tf_error))
if (this->tf_buffer_.canTransform(base_frame_id_, pcl_cloud->header.frame_id, ros::Time(0), ros::Duration(0.1),

Choose a reason for hiding this comment

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

stampを使わない理由は何ですか?

tf_global2rviz.transform.rotation.z = 0.0;
tf_global2rviz.transform.rotation.w = 1.0;
// If the origin of rviz and the global(map) frame are different, coordinate transformation is performed
if (init_with_tf_ && global_frame_id_ != pose_msg->header.frame_id && !global_frame_id_.empty() &&

Choose a reason for hiding this comment

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

ここでinit_with_tf_フラグ必要ですか?

Comment on lines +469 to +473
if (tf_global2rviz.header.frame_id != global_frame_id_)
{
ROS_ERROR("[Failed to get transform from %s to %s", global_frame_id_.c_str(), pose_msg->header.frame_id.c_str());
}
}

Choose a reason for hiding this comment

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

try-catchではダメですか?

Comment on lines +474 to +486
tf2::Vector3 vec_rviz2robot(pose_msg->pose.pose.position.x, pose_msg->pose.pose.position.y,
pose_msg->pose.pose.position.z);
tf2::Quaternion q_rviz2robot(pose_msg->pose.pose.orientation.x, pose_msg->pose.pose.orientation.y,
pose_msg->pose.pose.orientation.z, pose_msg->pose.pose.orientation.w);
// Get initial pose from global to robot
tf2::Vector3 vec_global2rviz(tf_global2rviz.transform.translation.x, tf_global2rviz.transform.translation.y,
tf_global2rviz.transform.translation.z);
tf2::Quaternion q_global2rviz(tf_global2rviz.transform.rotation.x, tf_global2rviz.transform.rotation.y,
tf_global2rviz.transform.rotation.z, tf_global2rviz.transform.rotation.w);
tf2::Vector3 vec_global2robot = vec_global2rviz + (tf2::Matrix3x3(q_global2rviz) * vec_rviz2robot);
tf2::Quaternion q_global2robot = q_global2rviz * q_rviz2robot;
Eigen::Vector3f init_position = Eigen::Vector3f(vec_global2robot.x(), vec_global2robot.y(), vec_global2robot.z());
Eigen::Quaternionf init_orientation =

Choose a reason for hiding this comment

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

tf2_eigen.hのtf2::transformToEigenを使うとメッセージ変換が簡単にできると思います.

@@ -36,6 +36,7 @@ void HdlLocalizationNodelet::onInit()
bool specify_init_pose = private_nh_.param<bool>("specify_init_pose", false);
Eigen::Vector3f init_position = Eigen::Vector3f::Zero();
Eigen::Quaternionf init_orientation = Eigen::Quaternionf::Identity();
init_with_tf_ = private_nh_.param<bool>("init_with_tf", true);

Choose a reason for hiding this comment

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

init_with_tf_がfalseになるとどうなりますか?

@nyxrobotics nyxrobotics marked this pull request as draft October 3, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants