Problem with ydlidar and conversion LaserScan -> PointCloud

asked 2019-11-12 07:43:26 -0500

AnotherBeginner gravatar image

updated 2019-11-13 07:01:11 -0500

Hello, i'm new to ROS and i would like to have some help about this.
So i have the ydlidar F4 pro at the moment, i managed to visualize with rviz the laserScan topic etc it works fine.
Now i want to have (x,y,z) points so that my future robot will be able to move past objects and for this I would like to have points.
The thing is that i managed to convert LaserScan to PointCloud and visualize it in rviz (again) but 1/4 of the lidar seems to be not working in my cpp program but on rviz it works fine.
If you can help me i would be very grateful Edit : link in google drive couldn't attach it here https://drive.google.com/open?id=1P3Z...
Edit 2 : i'm using ydlidat_test_v2.cpp this is the one i have problem with
Edit 3 : log file https://drive.google.com/open?id=1Ye_...
Edit : library https://github.com/YDLIDAR/ydlidar_ros lidar http://www.ydlidar.com/product/F4
https://drive.google.com/open?id=1USF...

edit retag flag offensive close merge delete

Comments

but 1/4 of the lidar seems to be not working in my cpp program

Can you be more explicit about what isn't working ? You don't get anything printed ? The calculations are wrong ? You have 1/4 of the data missing ?

Delb gravatar image Delb  ( 2019-11-12 07:56:32 -0500 )edit

Yes so the calcul is wrong like for 1/4 the points given in the cpp are (0,0,0) for the all quarter but the rest is fine, but the rviz visualisation is normal for the topic that is repost (i take scan and change to PointCloud then publish it to cloud)

AnotherBeginner gravatar image AnotherBeginner  ( 2019-11-12 08:00:57 -0500 )edit

Can you edit your question to add the code that is producing your ouput ? We can't tell which file you are using (is it ydlidar_test_v2.cpp ?).

The common part between your files is that you print data under the condition that the range is under 0.5 meters, are all your obstacles closer than 50 cm from your lidar ?

Delb gravatar image Delb  ( 2019-11-12 08:12:24 -0500 )edit

yes i'm using the v2, i wanted to focus on specific distance so it didn't spam the console

AnotherBeginner gravatar image AnotherBeginner  ( 2019-11-12 08:19:21 -0500 )edit

And if you check the data with rostopic echo /scan, are there some points at range 0.0 ?

Delb gravatar image Delb  ( 2019-11-12 08:34:02 -0500 )edit

Yes i think there are some in the scan but in the cloud they aren't

AnotherBeginner gravatar image AnotherBeginner  ( 2019-11-12 08:34:37 -0500 )edit

Maybe the convert part is wrong i don't know, maybe the lidar as problems but that would be strange because on rviz i have 360°

AnotherBeginner gravatar image AnotherBeginner  ( 2019-11-13 03:11:58 -0500 )edit

Can you remove the range condition so that we can see all the laser scan data in your log file please ?

Also, what is your lidar resolution ? It seems odd that your variable count returns 606, it's generally 360 or 720 :

int count = scan->scan_time / scan->time_increment;

Maybe there is an internal conversion that creates an issue here, or your variables are wrong. But then I would be surprised that scan->ranges[i] doesn't print an error if index is wrong. Can you also add the value of time_increment, scan_time and angle_increment in your question please ?

Delb gravatar image Delb  ( 2019-11-13 04:42:15 -0500 )edit