[Lidar 파일 변환]bag to csv,pcd & pcd viewer & pcap to bag(Ouster)

이용욱·2022년 4월 12일
0

Lidar

목록 보기
5/6
post-thumbnail

ROS 환경에서 라이다 데이터는 주로 bag 파일로 저장 되어진다. 하지만 활용하기 위해서는 pcd나 bin 파일로 변환 해줘야 한다.

1) bag ->

1-1) bag to pcd

rosrun pcl_ros bag_to_pcd <input_file.bag> <topic> <output_directory>

예를 들면 rosrun pcl_ros bag_to_pcd test.bag /os1_cloud_node/points ./home 와 같다.
실시간으로 변환 하기 위해서는 아래 코드를 이용한다.

$ rosrun pcl_ros pointcloud_to_pcd input:=/velodyne/pointcloud2
혹은
$ rosrun pcl_ros pointcloud_to_pcd input:=/os1_cloud_node/points

1-2) bag to CSV

2) pcd ->

2-1) pcd to image

$ rosrun pcl_ros convert_pcd_to_image <cloud.pcd>

[PCD시각화 방법]
pcl-tools 패키지 설치

$ rosrun perception_pcl pcd_viewer <filename>
$ pcd_viewer <filename>
$ pcl_viewer -multiview 1 <pcd_filepath>

2-1) pcd 파일 뷰어

pcd 파일 뷰어 설치

$ sudo apt-get install -y pcl-tools

원하는 파일을 Visualization

$ pcl_viewer <파일명>.pcd

2-2) pcd 데이터 확인

$ head "<파일명>"


Visual Studio를 통해 pcd 파일을 불러오면 데이터 확인 가능하다. 이 경우 DATA는 ascii 타입으로 fileds 정보가 표현된다

만약 binary 타입으로 DATA를 열 경우에는 아래와 같은 결과가 나타나는데 ascii 타입과 달리 fields 순서대로 데이터가 제공되지 않아 이해하는데 어려움이 있다
(데이터 전체 내용은 아래 txt를 확인할 것)

3) pcap ->

3-1) pcap to bag

Ouster 라이다 센서 데이터인 .pcap 파일을 bag 파일로 변환하는 툴을 설명한다. 아래 페이지 참고.
pcap to bag tools

# 워크 스페이스 생성
$ mkdir -p my_ws/src
$ git clone https://github.com/Krishtof-Korda/pcap-to-bag.git
$ cd myworkspace
# ouster 워크 스페이스와 링크가 필요하다.
$ ln -s /path/to/ouster_ws ./src/ # 본인이 가지고 있는 ouster 워크 스페이스 경로를 /path/to/ouster_ws 대신 넣어주자.
$ ln -s /my_ws ./src/ # 위에서 다운 받은 워크 스페이스 경로를 넣어주자.
$ catkin_make -DCMAKE_BUILD_TYPE=Release

빌드가 성공하면,
pcap_to_bag 실행 파일은

folder: my_ws/devel/lib/pcap_to_bag/

에 있으며,

./pcap_to_bag (name_of_pcap.pcap) (name_of_bag.bag) number_of_laser_channels

로 실행이 가능하다. 즉, 예를 들어, 64채널 라이다를 이용한 pcap 파일이라면,

./pcap_to_bag my.pcap my.bag 64

3-2) pcap to las

참고 : ouster sdk site
To convert to the first 5 scans of our sample data from a pcap file to LAS, you can try:

$ python3 -m ouster.sdk.examples.pcap $SAMPLE_DATA_PCAP_PATH $SAMPLE_DATA_JSON_PATH pcap-to-las --scan-num 5

3-3) pcap to pcd

참고 : ouster sdk site
To convert to the first 5 scans of our sample data from a pcap file to PCD, you can try:

$ python3 -m ouster.sdk.examples.pcap $SAMPLE_DATA_PCAP_PATH $SAMPLE_DATA_JSON_PATH pcap-to-pcd --scan-num 5
profile
자율주행에 관심이 있으며, Lidar SLAM을 공부하고 있습니다. [개인 홈페이지 : https://woogiee.wixsite.com/youngwooklee]

0개의 댓글