体育用品网站模板,北京广告公司工资,怎么把网址变成网页链接,电子商务网站建设的必要性文章目录 问题#xff1a;点云与网格垂直背景解决方法#xff1a;对点云坐标做变换#xff0c;绕x轴旋转90度#xff0c;将z轴指向上方将pcd转成点云#xff0c;在RVIZ中显示点云图创建launch rviz显示 问题#xff1a;点云与网格垂直
用lego-loam建图时用rosbag录制相关… 文章目录 问题点云与网格垂直背景解决方法对点云坐标做变换绕x轴旋转90度将z轴指向上方将pcd转成点云在RVIZ中显示点云图创建launch rviz显示 问题点云与网格垂直
用lego-loam建图时用rosbag录制相关点云的话题建图结束后用rosbag play将.bag包在rviz中显示但是由于该话题的点云发布的frame_id/camera_init但是rviz中默认的坐标系是base_link并且camera_init与base_link有旋转关系因此导致点云在rviz中显示时与rviz网格线呈垂直关系虽然rviz可以将默认显示的xy平面改成xz平面让点云显示正常但是此时不能在水平状态下左右旋转点云地图。
背景
ubuntu18.04melodic lego-loam订阅话题/laser_cloud_surround后保存了四个.pcd文件 pcd保存的路径在utility.h文件中设置 解决方法对点云坐标做变换绕x轴旋转90度将z轴指向上方
从PCD创建PointCloud2点云然后再在rviz中显示
将pcd转成点云在RVIZ中显示点云图
创建pcl_xy2xz.cpp文件
#includeros/ros.h
#includepcl/point_cloud.h
#includepcl_conversions/pcl_conversions.h
#includesensor_msgs/PointCloud2.h
#includepcl/common/transforms.h
#includepcl/io/pcd_io.hint main (int argc, char **argv)
{ ros::init (argc, argv, lego_loam); ros::NodeHandle nh; ros::Publisher pcl_pub nh.advertisesensor_msgs::PointCloud2 (/lego_loam_with_c16/output, 10); //待订阅的点云话题pcl::PointCloudpcl::PointXYZ cloud1,cloud2; sensor_msgs::PointCloud2 output; pcl::io::loadPCDFile (/home/gyl/wheeltec_bag/lego-loam pcl/nosmog1/finalCloud.pcd, cloud1); //自己的pcd路径Eigen::Affine3f transform_2 Eigen::Affine3f::Identity();//绕x轴旋转一个theta角transform_2.rotate(Eigen::AngleAxisf(1.570795, Eigen::Vector3f::UnitX()));//执行变换//pcl::PointCloudpcl::PointXYZ::Ptr pPointCloudOut(new pcl::PointCloudpcl::PointXYZ());pcl::transformPointCloud(cloud1, cloud2, transform_2);pcl::toROSMsg(cloud2,output);// 转换成ROS下的数据类型 最终通过topic发布output.header.stampros::Time::now();output.header.frame_id /camera_init_xz; //点云所在的坐标系frame_idros::Rate loop_rate(1); while (ros::ok()) { pcl_pub.publish(output); ros::spinOnce(); loop_rate.sleep(); } return 0;
} catkin_make编译结果报错
CMakeFiles/urdf01_rviz_node.dir/src/pcl_xy2xz.cpp.o在函数‘void pcl::createMappingpcl::PointXYZ(std::vectorpcl::PCLPointField, std::allocatorpcl::PCLPointField const, std::vectorpcl::detail::FieldMapping, std::allocatorpcl::detail::FieldMapping )’中
/usr/include/pcl-1.8/pcl/conversions.h:108对‘pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)’未定义的引用
/usr/include/pcl-1.8/pcl/conversions.h:108对‘pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)’未定义的引用
/usr/include/pcl-1.8/pcl/conversions.h:108对‘pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)’未定义的引用
CMakeFiles/urdf01_rviz_node.dir/src/pcl_xy2xz.cpp.o在函数‘main’中
/usr/include/pcl-1.8/pcl/io/pcd_io.h:56对‘vtable for pcl::PCDReader’未定义的引用
/usr/include/pcl-1.8/pcl/io/pcd_io.h:208对‘pcl::PCDReader::read(std::__cxx11::basic_stringchar, std::char_traitschar, std::allocatorchar const, pcl::PCLPointCloud2, Eigen::Matrixfloat, 4, 1, 0, 4, 1, Eigen::Quaternionfloat, 0, int, int)’未定义的引用collect2: error: ld returned 1 exit status
urdf01_rviz/CMakeFiles/urdf01_rviz_node.dir/build.make:127: recipe for target /home/gyl/hello_w/devel/lib/urdf01_rviz/urdf01_rviz_node failed
make[2]: *** [/home/gyl/hello_w/devel/lib/urdf01_rviz/urdf01_rviz_node] Error 1
CMakeFiles/Makefile2:5439: recipe for target urdf01_rviz/CMakeFiles/urdf01_rviz_node.dir/all failed
make[1]: *** [urdf01_rviz/CMakeFiles/urdf01_rviz_node.dir/all] Error 2
Makefile:140: recipe for target all failed
make: *** [all] Error 2
Invoking make -j8 -l8 failed原因就是CMakeLists.txt中没有配置好相关信息
......find_package(catkin REQUIRED COMPONENTSpcl_rospcl_conversions
)
find_package(PCL REQUIRED QUIET)catkin_package(DEPENDS PCL
)include_directories(${catkin_INCLUDE_DIRS}${PCL_INCLUDE_DIRS}
)link_directories(include${PCL_LIBRARY_DIRS}
)add_executable(自己的项目名称 src/pcl_xy2xz.cpp)
target_link_libraries(自己的项目名称 ${catkin_LIBRARIES} ${PCL_LIBRARIES})重新catkin_make编译就成功了。
创建launch
launch!-- 运行创建的pcl_xy2xz.cpp文件 --node pkgurdf01_rviz typepcl_xy2xz namepcl_xy2xz outputscreen respawnfalse/!-- 使用octomap_server将点云地图转化为八叉树地图和占据栅格地图 --node pkgoctomap_server typeoctomap_server_node nameoctomap_server!-- resolution in meters per pixel --param nameresolution value0.1 /!-- name of the fixed frame, needs to be /map for SLAM --param nameframe_id typestring value/camera_init_xz /!-- max range / depth resolution of the kinect in meter --param namesensor_model/max_range value50.0 /param namelatch valuetrue /!-- max/min height for occupancy map, should be in meters --param namepointcloud_max_z value1000 /param namepointcloud_min_z value-1000 /param nameground_filter_angle value3.14 /!-- topic from where pointcloud2 messages are subscribed --remap fromcloud_in to/lego_loam_with_c16/output //node!-- 启动rviz --node pkgrviz typerviz namerviz //launch
rviz显示
点击add 按钮添加 “PointCloud2模块” 设置topic为 “/lego_loam_with_c16/output” 设置FixedFram为 “camera_init_xz”
点云显示 八叉树地图显示 参考博客
【激光SLAM】Lego_loam使用教程Octomap 在ROS环境下实时显示使用octomap_server将点云地图转化为八叉树地图和占据栅格地图