스터디 노트
article thumbnail

Ubuntu 18.04 ROS melodic 그냥 저를 위한 글입니다.(되돌아보기위함) 설명이 불친절할 수 있습니다 ㅜㅜ

 

ROS 설치시 PCL 라이브러리 들이 함께 설치된다고 한다. 

 

확인 방법

dpkg -l | grep pcl

 

 

 

이후 기존 패키지에서 사용하려면 따로 패키지들을 포함 시켜주어야 함

사용 할 라이브러리들을 catkin package 생성 명령어로 우선 생성해주고 

catkin_create_pkg my_pcl_tutorial pcl_conversions pcl_ros roscpp sensor_msgs 

 생성된 CMakelist 파일이나 Package.xml 파일 참조해서 나에게 필요한 부분만 빼와서 써도됨.

 

아래의 pcl 소스는 임형태님 블로그 참조(맨 아래 링크)

#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>

template <class T>
void print_pc(pcl::PointCloud<T>& cloud){
    int count = 0;
    for (const auto& pt: cloud.points){
        ROS_INFO("%d",count++);
        ROS_INFO("%f, %f, %f ",pt.x,pt.y,pt.z);
    }
}
int main(int argc, char **argv)
{
    
    ros::init(argc, argv, "off_node_two");
    ros::Rate loop_rate(10);
    pcl::PointCloud<pcl::PointXYZ> cloud_init0;
    int count=0;
    
    cloud_init0.resize(3);
    cloud_init0.points[0].x=1;  cloud_init0.points[0].y=2;  cloud_init0.points[0].z=3;
    cloud_init0.points[1].x=2;  cloud_init0.points[1].y=4;  cloud_init0.points[1].z=6;
    cloud_init0.points[2].x=3;  cloud_init0.points[2].y=8;  cloud_init0.points[2].z=9;
    print_pc(cloud_init0);
    
    pcl::PointCloud<pcl::PointXYZ> cloud_init1;
    pcl::PointXYZ point_xyz;

    point_xyz.x = 1;    point_xyz.y = 2;    point_xyz.z = 3;
    cloud_init1.push_back(point_xyz);
    print_pc(cloud_init1);
    
    while(ros::ok())
    {
        ros::spinOnce();
        loop_rate.sleep();
        ++count;
    }
    return 0;
}

pcl::PointCloud<pcl::PointXYZ> cloud_init0; 

-포인트 클라우드에는 <pcl::PointXYZ>, <pcl::PointXYZI>, <pcl::PointXYZRGB> .. 등과 같은 자료형이 존재(c++ vector와 비슷)하고 필요에따라 선언해서 사용하면 되는듯하다.  

- 해당 자료형 자식 멤버중에 resize를 통해서 얼만큼의 개수를 담을지 정할 수 있다.

 

그리고 PointXYZ타입의 변수를 선언해서 포인트를 담고 자료형인 PointCloud에 담을 수 있음. 

ex) cloud_init1.push_back(point_xyz)

 

 

http://wiki.ros.org/pcl/Tutorials

 

pcl/Tutorials - ROS Wiki

A comprehensive list of PCL tutorials can be found on PCL's external website. Here are a few of the tutorials that you might want to check out: More information about PCL integration in ROS (e.g. point cloud data types, publishing/subscribing) can be found

wiki.ros.org

https://limhyungtae.github.io/

 

Hyungtae Lim

Robotics, Deep Learning, and SLAM {% for post in paginator.posts %} {{ post.title }} {% if post.subtitle %} {{ post.subtitle }} {% endif %} Posted on {{ post.date | date: site.date_format }} {% if post.image %} {% endif %} {{ post.excerpt | strip_html | xm

limhyungtae.github.io

 

'maengkyun > Robotics' 카테고리의 다른 글

ROS python3 tf, tf2 error  (0) 2022.02.08
[Review] Fast Depth Completion on the cpu [추후 수정]  (0) 2022.01.07
[Ouster] 3D LIDAR SETTING 수정중  (0) 2021.12.02
[TEST Video] Aritificial Potential Field  (0) 2021.09.05
assda  (0) 2021.08.31
profile

스터디 노트

@myeongkyun

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!