Acquiring 3d pointcloud data from 2d laserscan data [closed]
I am getting 3d data with my 2d urg04lx laser scanner(lidar). But the laser does not show scanned objects clearly. For example I put an object in front of the laser. When I scan that object, I want to be able to see that object on the rviz screen. I turn the laser scanner with the servo. I need your advice.
Update:
I did it Mr. @William . My codes are below . Please look at these: Is there a frequency mismatch between servo (or arduino) and laser scanner?
scan_to_pcl:
#!/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()
pcl_assembler_client:
#!/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()
my urdf code:
<?xml version="1.0"?>
<robot name="model1">
<link name="base_link">
<visual>
<geometry>
<box size="0.6 0.2 0.2"/>
</geometry>
</visual>
</link>
<link name="laser">
<visual>
<geometry>
<box size="0.2 0.2 0.2"/>
</geometry>
<origin rpy="0 1.57 0" xyz="0.3 0 0.3"/>
</visual>
</link>
<joint name="base_tilt_joint" type="revolute">
<parent link="base_link"/>
<child link="laser"/>
<axis xyz="0 -1 0"/>
<limit effort="3.0" velocity="9.178465545" lower="0.02" upper="3.14" />
</joint>
</robot>
my launch file:
<launch>
<param name="robot_description" textfile="$(find lidar_package)/urdf/tilt_mech.urdf" />
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find lidar_package)/urdf/urdf.rviz" required="true" />
<node name="scan_to_pcl" pkg="lidar_package" 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="lidar_package" type="pcl_assembler_client.py" output="screen"/>
</launch>
Please do not delete your questions after they've been answered.
okey sorry. Can ı close it?