1
$\begingroup$

I am running my roslaunch script and collect the pointclouds by using rviz and manually click and export the ply/pcd to a file and analyse it after. Now I want to run the script without rviz and make it export the file of the collected pointclouds in the end when killing the process of collecting data. What is the best way to do this? Is there any service from ros itself that I can call?

Edit: I am using ROS NOETIC

$\endgroup$
2
  • $\begingroup$ Please edit your question to tell us which version of ros you are using. $\endgroup$
    – Mike973
    Nov 14, 2023 at 13:14
  • $\begingroup$ Are you asking for advice on creating a custom ros node yourself, or are you looking for a ros node that someone else has already written? Do you know c++? $\endgroup$
    – Mike973
    Nov 16, 2023 at 14:24

1 Answer 1

1
$\begingroup$

Try point_cloud_io write.

rosrun point_cloud_io write _topic:=/your_topic _folder_path:=/home/user/my_point_clouds

It saves a ply file per point cloud message, if you want to merge them you could use meshlab *ply then Flatten visible layers (https://stackoverflow.com/questions/65202838/export-all-meshes) in the gui.

Or from the command line use this flatten.mlx file

<!DOCTYPE FilterScript>
<FilterScript>
 <filter name="Flatten Visible Layers">
  <Param type="RichBool" tooltip="If true, flatten only visible layers, otherwise, all layers are used" description="Merge Only Visible Layers" name="MergeVisible" value="true"/>
  <Param type="RichBool" tooltip="Delete all the layers used as source in flattening. &lt;br>If all layers are visible only a single layer will remain after the invocation of this filter" description="Delete Layers " name="DeleteLayer" value="true"/>
  <Param type="RichBool" tooltip="Merge the vertices that are duplicated among different layers. &#xa;&#xa;Very useful when the layers are spliced portions of a single big mesh." description="Merge duplicate vertices" name="MergeVertices" value="false"/>
  <Param type="RichBool" tooltip="Do not discard unreferenced vertices from source layers&#xa;&#xa;Necessary for point-cloud layers" description="Keep unreferenced vertices" name="AlsoUnreferenced" value="true"/>
 </filter>
</FilterScript>

(cut and paste that into a file called flatten.mlx)

meshlabserver -i point_cloud*.ply -o merged_cloud.ply -s flatten.mlx

output

Loading Plugins:
Current Plugins Dir is: /usr/lib/x86_64-linux-gnu/meshlab/plugins 
Total 266 filtering actions
Total 13 io plugins
Opening a file with extension ply
Mesh .../point_cloud_0.ply loaded has 32400 vn 0 fn
Opening a file with extension ply
...
FilterScript
Reading filter with name Flatten Visible Layers
Starting Script of 1 actionsfilter: Flatten Visible Layers
LOG: 2 Deleted 29 merged layers
LOG: 2 Merged all the layers to single mesh of 939600 vertices
Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Merging layers...Deleted 29 merged layers
Merged all the layers to single mesh of 939600 vertices
...

You may want to set MergeVertices to true.

(the filter script was generated from the gui with the help of https://sourceforge.net/p/meshlab/discussion/499532/thread/f2f69f17/, if mine doesn't work try going through the export script procedure again)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.