pcl画圆球_PCL之轨迹绘制(二)

之前学习点云库做一些简单的应用都是直接复制demo的代码,然后把导入文件改一下,今天尝试自己写一些程序,结果错漏百出,难受的早上,不过坚持了下来,求夸~~~

这个主要是一个简单的绘制轨迹的教程,绘制轨迹只需要两个东西,旋转R和平移T,只要我们能够得到这两个东西,再结合初始坐标点,利用点云库里面的Visualization模块中的addLine函数就可以实现轨迹的绘制了。

这里为了简单,我们直接采用模拟的数据以及模拟的旋转矩阵。先一步一步讲解流程,最后再附上源码~~

1.生成点云数据

```c++  //为了方便,我们在这里只生成一个点

pcl::PointCloud::Ptr cloud1(new pcl::PointCloud);

cloud1->width = 1;

cloud1->height = 1;

cloud1->points.resize(cloud1->width * cloud1->height);

cloud1->points[0].x = 1;

cloud1->points[0].y = 1;

cloud1->points[0].z = 1;

cout << "cloud1 size " << cloud1->points.size()<

2.模拟生成旋转矩阵

2.模拟生成旋转矩阵

```c++

//模拟一个旋转矩阵,为了简单,这里只是用一个,每次迭代都使用这个矩阵,效果是x方向一次增加1个单位长度

//我们知道旋转矩阵形式如下[ R t

0 1] 下一篇文章会讲解一下这些的由来

Eigen::Matrix4f transform_1 ;

transform_1 << 1 , 0 , 0 , 1 ,

0 , 1 , 0 , 0 ,

0 , 0 , 1 , 0 ,

0 , 0 , 0 , 1 ;

cout << transform_1 <

3.接下来会用来 Register模块中的transforms函数来实现点的转变

```c++ //将矩阵进行变化

pcl::PointCloud::Ptr cloud2(new pcl::PointCloud);

pcl::transformPointCloud (cloud1, cloud2, transform_1);

cout << "original cloud1 points "<< cloud1->points[0].x<

cout<

吐槽:不知道为啥B乎每次都把我们格式弄坏了。。。

4.最后会用到Visualization模块中的PCLVisualizer类显示窗口

pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer ("3D Viewer"));

viewer->setBackgroundColor (0, 0, 0);

viewer->addText("Trajector", 10, 10, "v1 text");

viewer->addCoordinateSystem (1.0);

viewer->initCameraParameters ();

int line_numeber = 0;

char str[25];//这一个的作用是为了下面给每条线段 1 个唯一的id符,不然的画只能画出一条线

while(!viewer->wasStopped()){

viewer->spinOnce (1000);//这一句很重要,一开始没有写这一句,导致窗口一直没有显示,用于更新屏幕

line_numeber++;//依次增加,从而实现id号的不同

sprintf(str, "%d", line_numeber);//将数字转化为字符串,addLine需要,addLine函数定义在下面

viewer->addLine<:pointxyz> (cloud1->points[0], cloud2->points[0], str);

*cloud1 = *cloud2;//将上一步的点云给另外一个

pcl::transformPointCloud (*cloud1, *cloud2, transform_1);

//cout语句用于测试

cout << "cloud1 points "<< cloud1->points[0].x<points[0].y <points[0].z<

cout << "cloud1 points "<< cloud2->points[0].x<points[0].y <points[0].z<

cout<

}

5.最后把头文件给你就组成完整的程序了

#include

#include

#include #include //这两个std文件没有作用,因为一开始想用到itoa(),将整形转化为字符的函数,后来发现这

#include //这个函数只有在window下面才存在

using namespace std;

注意点:

1.void pcl::visualization::PCLVisualizer::spinOnce(int time =1 ; bool force_redraw = false )

Spin once method.

Calls the interactor and updates the screen once.Parameters

[in] time- How long (in ms) should the visualization loop be allowed to run.

[in] force_redraw- if false it might return without doing anything if the interactor's framerate does not require a redraw yet.

while(!viewer->wasStopped()){

// viewer->spinOnce (100); }

viewer->spinOnce (100);一定要加这一句,否则什么现象也没有

2.bool pcl::visualization::PCLVisualizer::addLine(const P1 & pt1, const P2 & ptr2,const std::string& id ="line",int viewpoint = 0 )

Add a line segment from two points.Parameters

[in]pt1the first (start) point on the line

[in]pt2the second (end) point on the line

[in]idthe line id/name (default: "line")

[in]viewport(optional) the id of the new viewport (default: 0)

Note:每一条线都需要有自己的id号

总结:还是要多多自己敲代码,复制粘贴一时爽,真定编码火葬场~~~B乎的格式和Typora很不一样....,还是CSDN好。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/542983.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

note2 android4.3,玩家们动手吧 Note2安卓4.3固件已泄漏

【PConline 资讯】最近各个牌子的安卓机迎来了升级安卓4.3的大潮&#xff0c;现在三星Galaxy Note2的安卓4.3固件已经泄漏出来了。实际上&#xff0c;此前三星官方已经确认&#xff0c;Galaxy Note3可以获得官方的安卓4.3固件升级&#xff0c;但具体日期没有确定&#xff0c;只…

SDP学习笔记

一、SDP规范了回话描述的格式&#xff0c;一般结合会话协议共同工作。 常见的会话传送协议包括:SAP(Session Announcement Protocol 会话公告协议),SIP,RTSP,HTTP,和使用MIME的E-Mail。 &#xff08;PS&#xff1a;对SAP只能包含一个会话描述,其它会话协议的SDP可包含多个会话描…

sinh_带有Python示例的math.sinh()方法

sinhPython math.sinh()方法 (Python math.sinh() method) math.sinh() method is a library method of math module, it is used to get the hyperbolic sine of given number in radians, it accepts a number and returns hyperbolic sine. math.sinh()方法是数学模块的库方…

android serviceconnection unbind流程,Android unbindService 流程分析

基于Android 6.0的源码剖析&#xff0c; 分析bind service的启动流程。/frameworks/base/core/java/android/app/ContextImpl.java/frameworks/base/core/java/android/app/LoadedApk.java/frameworks/base/core/java/android/app/IServiceConnection.aidl(自动生成Binder两端)…

【JUnit 报错】 method initializationerror not found:JUnit4单元测试报错问题

今天是用JUnit测试一段代码&#xff0c;报错method initializationerror not found:&#xff1a;出现如下问题&#xff1a; 双击这个就显示出现如下的错误&#xff1a; 查询网上&#xff0c;说是junit版本的问题&#xff1a; 那我就不使用JUnit这个Libernary了&#xff0c;下载…

flash 不显示 旋转 补间动画_【图片】Flash入门5:详解制作补间动画(非传统补间)【flash软件吧】_百度贴吧...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼●●关于补间动画●●●1、准备事项注意&#xff1a;像 Flash 中的大多数内容一样&#xff0c;动画不需要任何 ActionScript。然而&#xff0c;如果您愿意&#xff0c;您可以使用 ActionScript 创建动画。在创建补间之前&#xff0…

math.ceil带小数点_Python中带有示例的math.ceil()方法

math.ceil带小数点Python math.ceil()方法 (Python math.ceil() method) math.ceil() method is a library method of math module, it is used to get the ceil value of a given number, it accepts a number/numeric expression and returns the smallest integral value wh…

将byte数组以html形式输出到页面,java 数组显示到html

java 数组显示到html[2021-02-05 01:08:54] 简介:php去除nbsp的方法&#xff1a;首先创建一个PHP代码示例文件&#xff1b;然后通过“preg_replace("/(\s|\&nbsp\;| |\xc2\xa0)/", " ", strip_tags($val));”方法去除所有nbsp即可。推荐&#xff1a;…

JDK各版本新增的主要特性

JDK1.5新特性&#xff1a; 1.自动装箱与拆箱&#xff1a; 2.枚举 3.静态导入&#xff0c;如&#xff1a;import staticjava.lang.System.out 4.可变参数&#xff08;Varargs&#xff09; 5.内省&#xff08;Introspector&#xff09;&#xff0c;主要用于操作JavaBean中的属性&…

oracle 导入sql文件 汉字乱码_将现有的sql脚本导入 Oracle 数据库,中文乱码问题...

将现有的sql 脚本导入 Oracle数据库比如 在windows 系统下&#xff0c;可以写一个 bat 来实现直接导入如&#xff1a;bat 中的内容如下&#xff0c;logs.log 将会记录执行日志sqlplus user/passworddbname create.sql > logs.logcreate.sql 中的内容可以是需要执行的sql 语句…

html图片多边形怎么写,使用CSS3构建的图像多边形裁剪动画特效

CSS语言&#xff1a;CSSSCSS确定html {background: #333;}.polygon {-webkit-clip-path: polygon(50% 0%, 79.38926% 9.54915%, 97.55283% 34.54915%, 97.55283% 65.45085%, 79.38926% 90.45085%, 50% 100%, 20.61074% 90.45085%, 2.44717% 65.45085%, 2.44717% 34.54915%, 20.…

python函数示例_带Python示例的complex()函数

python函数示例Python complex()函数 (Python complex() function) complex() function is a library function in Python, it is used to get the complex number from given a real number or/and an imaginary number (which is an optional part), it accepts either a rea…

windows 下 git 禁用 CRLF 转换 LF

2019独角兽企业重金招聘Python工程师标准>>> windows中的换行符为 CRLF&#xff0c; 而在linux下的换行符为LF&#xff0c;所以在执行add . 时出现提示&#xff0c;解决办法&#xff1a; 删除根目录 .git 文件夹禁用自动转换 > git config --global core.autocrl…

cmd执行sql文件路径 oracle_oracle 基础 执行sql文件

Oracle执行外部文件&#xff1a;sql>new.sql执行多个sql文件:1.把所有的文件都放在同一个目录下&#xff0c;然后在命令行里执行命令&#xff1a;c:>dir/b > d:/1.sql会把所有的sql文件名都输出到一个sql文件中。2.用UltraEdit打开生成的sql文件&#xff0c;altC切换到…

获取天气html,使用htmlparser获取sohu的天气预报

首先&#xff0c;我们新建一个类&#xff0c;存放天气信息/** Created on 2005-3-8** To change the template for this generated file go to* Window>Preferences>Java>Code Generation>Code and Comments*/packageorg.exoplatform.portlets.chinaweather.compon…

使用gulp构建前端(三)

为什么80%的码农都做不了架构师&#xff1f;>>> 使用gulp构建前端&#xff08;三&#xff09; 紧接着上述文章内容&#xff0c;开始新的插件的使用 插件三 gulp-clean-css&#xff0c;作用减小文件大小&#xff0c;并给引用url添加版本号避免缓存&#xff0c;一个需…

c++中atan2函数_atan2()函数以及C ++中的示例

c中atan2函数C atan2()函数 (C atan2() function) atan2() function is a library function of cmath header, it is used to find the principal value of the arc tangent of y/x, where y is the proportion of the y-coordinate and x is the proportion of the x-coordin…

python不合法的布尔表达式_python测试题

一、填空题 1.Python使用符号标示注释;以划分语句块。 2、Python序列类型包括 、、三种; 是Python中唯一的映射类型。 3、Python中的可变数据类型有,不可变数据类 型有。 4、Python的数字类型分为、、等子类型。 5、设s=‘abcdefg’,则s[3]值是 ,s[3:5]值是 , s[:5]值是…

网站html标签如何优化,网站HTML标签优化教程

真正需要SEOer掌握并经常使用的HTML标签也就那么几个&#xff0c;本小节丈哥seo带来的是页面HTML标签优化。title标签 – 标题标签1)title标签用法网站SEOHTML标签优化教程 – 丈哥seo2)标题标签的作用关于网站标题写法与操作技巧有许多&#xff0c;需要怎么优化标题的朋友可以…

hypot函数_hypot()函数与C ++中的示例

hypot函数C hypot()函数 (C hypot() function) hypot() function is a library function of cmath header, it is used to find the hypotenuse of the given numbers, it accepts two numbers and returns the calculated result of hypotenuse i.e. sqrt(x*x y*y). hypot()…