-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
c9adf10
to
0b1be75
Compare
@@ -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), |
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.
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() && |
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.
ここでinit_with_tf_
フラグ必要ですか?
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()); | ||
} | ||
} |
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.
try-catchではダメですか?
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 = |
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.
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); |
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.
init_with_tf_
がfalseになるとどうなりますか?
Summary
rvizでinitial_poseのframe_idがmapでない場合mapへ座標変換
init_with_tfがtrueのときbase_linkのTFの位置を原点にしてスキャンマッチングを開始
fix Rvizでmap以外のフレームを原点にinitialposeを設定すると初期位置が誤った位置になる #37
fix robot_localizationと組み合わせる際に「現在のTFの関係」を参照して初期位置に設定したい #38
Attention