0
$\begingroup$

Rosanswers logo

Hello Guys,

first of all here is my setup : Ubuntu 16.04 with ROS kinetic and Gazebo 7.0.

I have a Scenario where a simulated turtlebot drives to several objects. Actual i need some pointcloud data from him but only from the approach.

Now i use :

rosrun pcl_ros pointcloud_to_pcd input:=/depth/points

I would prefere something how i can integrate this in my code and only save pcd files in the approach of the objects. So i need something that i can start the pointcloud to pcd node and something how i can stop the node after the approach.

An code example would help me a lot.


Originally posted by Baumboon on ROS Answers with karma: 206 on 2018-05-29

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

There are a few ways one could do this. Likely the easiest is to use Python's subprocess module. Here's a small example:

import subprocess
cmd = "rosrun pcl_ros pointcloud_to_pcd input:=/depth/points"
proc = subprocess.Popen(cmd, shell=True)
# when ready to shutdown:
proc.kill()

You'd likely want to add some error/exception handling to make sure the process opened and closed successfully if you were really going to implement this.

One could also use the roslaunch Python API.

However, I personally think your proposed plan is not the optimal way to go about this. It takes time to start and stop nodes and for communications between publishers and subscribers to be established. Even if you could start and stop the pointcloud_to_pcd node on-the-fly, you'd likely be missing some clouds or saving clouds you don't want. Instead, what I would do is run the pointcloud_to_pcd node subscribing to a special topic that is only published when you actually want a particular point cloud saved to a PCD file. Then in the node where you are trying to start and stop the pointcloud_to_pcd node, you instead just publish any clouds that meet your criteria on that special topic.


Originally posted by jarvisschultz with karma: 9031 on 2018-05-29

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Baumboon on 2018-05-29:
Thats a very good idea, but i have some questions how to republish the pointcloud from /depth/points. I will open a new question.

$\endgroup$

Your Answer

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