当前位置:   article > 正文

ros::tf中的插值函数_tf 插值

tf 插值

插值函数原型链接如下:
ros::tf中的插值函数
ros::tf中的插值函数
验证代码如下:

#include <ros/ros.h>
#include <geometry_msgs/PointStamped.h>
#include <tf/transform_listener.h>
int main(int argc, char** argv){
	while(1)
	{
		float ratio;
		tf::Vector3 data_begin(0,0,0);
		tf::Vector3 data_end(2,3,4);
		tf::Vector3 data_lerp;

		ROS_INFO("data_begin.x = %f data_begin.y = %f data_begin.z = %f",data_begin.x(),data_begin.y(),data_begin.z());
		ROS_INFO("data_end.x = %f data_end.y = %f data_end.z = %f",data_end.x(),data_end.y(),data_end.z());

		ratio = 0;
		data_lerp = data_begin.lerp(data_end,ratio);
		ROS_INFO("ratio = %f ",ratio);
		ROS_INFO("data_lerp.x = %f data_lerp.y = %f data_lerp.z = %f",data_lerp.x(),data_lerp.y(),data_lerp.z());

		ratio = 0.3;
		data_lerp = data_begin.lerp(data_end,ratio);
		ROS_INFO("ratio = %f ",ratio);
		ROS_INFO("data_lerp.x = %f data_lerp.y = %f data_lerp.z = %f",data_lerp.x(),data_lerp.y(),data_lerp.z());

		ratio = 0.5;
		data_lerp = data_begin.lerp(data_end,ratio);
		ROS_INFO("ratio = %f ",ratio);
		ROS_INFO("data_lerp.x = %f data_lerp.y = %f data_lerp.z = %f",data_lerp.x(),data_lerp.y(),data_lerp.z());

		ratio = 0.7;
		data_lerp = data_begin.lerp(data_end,ratio);
		ROS_INFO("ratio = %f ",ratio);
		ROS_INFO("data_lerp.x = %f data_lerp.y = %f data_lerp.z = %f",data_lerp.x(),data_lerp.y(),data_lerp.z());

		ratio = 1;
		data_lerp = data_begin.lerp(data_end,ratio);
		ROS_INFO("ratio = %f ",ratio);
		ROS_INFO("data_lerp.x = %f data_lerp.y = %f data_lerp.z = %f",data_lerp.x(),data_lerp.y(),data_lerp.z());

	}  
  }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41

运行结果如下:
运行结果如下

另外tf还支持四元数球形插值:
函数原型链接如下:
四元数球形插值
四元数球形插值

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/206516
推荐阅读
相关标签
  

闽ICP备14008679号