Ask Your Question
1

3D point cloud

asked 2017-08-21 07:46:47 -0600

Yogi_4 gravatar image

updated 2017-08-29 05:23:41 -0600

pcl_assembler_client.py

 #!/usr/bin/env python
import rospy
from laser_assembler.srv import AssembleScans2
from sensor_msgs.msg import PointCloud2

rospy.init_node("assemble_scans_to_cloud")
rospy.wait_for_service("assemble_scans2")
assemble_scans=rospy.ServiceProxy('assemble_scans2',AssembleScans2)
pub=rospy.Publisher("/point_Cloud",PointCloud2,queue_size=2)
r=rospy.Rate(10)
while True:
        try:
                resp=assemble_scans(rospy.Time(0,0),rospy.get_rostime())
                print "Got cloud with %u points" % len(resp.cloud.data)
                pub.publish(resp.cloud)
        except rospy.ServiceException, e:
                print "service call failed: %s" %e
        r.sleep()

scan_to_pcl.py

#!/usr/bin/env python

import rospy
from sensor_msgs.msg import PointCloud2 as pc2
from sensor_msgs.msg import LaserScan
from laser_geometry import LaserProjection

class Laser2PC():
        def __init__(self):
                self.laserProj=LaserProjection()
                self.pcPub=rospy.Publisher("/laserPointCloud",pc2,queue_size=1)
                self.laserSub=rospy.Subscriber("/scan",LaserScan,self.laserCallback)

        def laserCallback(self,data):
                cloud_out=self.laserProj.projectLaser(data)
                self.pcPub.publish(cloud_out)
if __name__=='__main__':
        rospy.init_node("scan_to_pcl")
        l2pc=Laser2PC()
        rospy.spin()

my launch file is,

<launch>

<node name="scan_to_pcl" pkg="cloud_data" type="scan_to_pcl.py"/>

<node type="point_cloud2_assembler" pkg="laser_assembler"  name="pcl_assembler_server">
<remap from="cloud" to="laserPointCloud"/>
<param name="max_clouds" type="int" value="400" />
<param name="fixed_frame" type="string" value="base_link" />
</node>


<node name="pcl_assembler_client" pkg="cloud_data" type="pcl_assembler_client.py" output="screen"/>

</launch>

These is code i'm using to generate point cloud data using the laser_assembler package but it is not extruded along the third axis i.e it is not 3D. Can someone help me out on how to achieve 3D cloud.

edit retag flag offensive close merge delete

Comments

Are you asking someone to translate it from C++ to Python for you?

jayess gravatar imagejayess ( 2017-08-24 19:00:03 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-08-24 19:02:22 -0600

jayess gravatar image

There's already a Python class that does that:

https://github.com/ros-perception/las...

edit flag offensive delete link more

Comments

Thank you for the reply I used laser_assembler to transform laser scan data to point cloud but it is not 3D(I want to extrude it along the z axis).Can you help me with this. I used projectlaser() function but it didnt give me 3D point cloud

Yogi_4 gravatar imageYogi_4 ( 2017-08-28 07:34:47 -0600 )edit

How did you try it? Please update your question with your attempts and that you need this to be 3D as that isn't stated in the question.

jayess gravatar imagejayess ( 2017-08-28 09:07:44 -0600 )edit

I have used projectlaser() function but i didn't get 3D cloud.I'm getting data published on pointcloud2 and i can also view it in rviz but not 3D cloud

Yogi_4 gravatar imageYogi_4 ( 2017-08-28 09:30:31 -0600 )edit

Please update your question with how you attempted to use it (i.e., code).

jayess gravatar imagejayess ( 2017-08-28 09:34:24 -0600 )edit

i have uploaded the code #jayess

Yogi_4 gravatar imageYogi_4 ( 2017-08-30 00:46:39 -0600 )edit

Did you solve this problem?

Mekateng gravatar imageMekateng ( 2017-09-08 03:49:08 -0600 )edit

Yeah the problem is solved

Yogi_4 gravatar imageYogi_4 ( 2017-09-08 03:51:45 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-08-21 07:46:47 -0600

Seen: 715 times

Last updated: Aug 29 '17