Problem with ydlidar and conversion LaserScan -> PointCloud
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=1P3ZJaaWVvoYzl7F6YIFOwn-gXIzEbc--
Edit 2 : i'm using ydlidattestv2.cpp this is the one i have problem with
Edit 3 : log file https://drive.google.com/open?id=1Ye_kQBcWE4K6tc5g-_QE7aHbAjn-VRUM
Edit : library https://github.com/YDLIDAR/ydlidar_ros lidar http://www.ydlidar.com/product/F4
https://drive.google.com/open?id=1USFekN6o4FUNAj_9siF8bIMUYu3C2sKG
Asked by AnotherBeginner on 2019-11-12 08:43:26 UTC
Comments
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 ?
Asked by Delb on 2019-11-12 08:56:32 UTC
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)
Asked by AnotherBeginner on 2019-11-12 09:00:57 UTC
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 than50 cm
from your lidar ?Asked by Delb on 2019-11-12 09:12:24 UTC
yes i'm using the v2, i wanted to focus on specific distance so it didn't spam the console
Asked by AnotherBeginner on 2019-11-12 09:19:21 UTC
And if you check the data with
rostopic echo /scan
, are there some points at range0.0
?Asked by Delb on 2019-11-12 09:34:02 UTC
Yes i think there are some in the scan but in the cloud they aren't
Asked by AnotherBeginner on 2019-11-12 09:34:37 UTC
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°
Asked by AnotherBeginner on 2019-11-13 04:11:58 UTC
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
returns606
, it's generally360
or720
: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 oftime_increment
,scan_time
andangle_increment
in your question please ?Asked by Delb on 2019-11-13 05:42:15 UTC
i copied the library from this site https://github.com/YDLIDAR/ydlidar_ros it's the basic version for lidar this is this lidar http://www.ydlidar.com/product/F4 i didn't understand the last question about time_increment etc what do you want me to do ? print them?
Asked by AnotherBeginner on 2019-11-13 06:04:59 UTC
Yes either print with your code, or show their value in the output of
rostopic echo /scan
Asked by Delb on 2019-11-13 06:10:23 UTC
ok i have 3 log, the rostopic echo scan, cloud and my code log without the distance restriction here is the link https://drive.google.com/open?id=1USFekN6o4FUNAj_9siF8bIMUYu3C2sKG
Asked by AnotherBeginner on 2019-11-13 07:43:42 UTC
Your ranges array size
606
is still bothering me. In your launch file I see that the baudrate is defined at115200
while the documentation of the ydlidar F4 states that it should be230400
, I'm not sure it could be the origin of your issue but can you try to change that ?Asked by Delb on 2019-11-13 08:36:57 UTC
oh yes that's true it's strange that it worked at 115200 i changed it but there are no changes on my problem 1/4 still give me 0 If it help it's the quarter on the left of the connector so between 500 -> 600 it gives (0,0,0)
Asked by AnotherBeginner on 2019-11-13 08:50:05 UTC
Here are the parameters of the lidar when i launch maybe you will see something PARAMETERS
* /rosdistro: melodic
* /rosversion: 1.14.3
* /ydlidar_node/angle_max: 180.0
* /ydlidar_node/angle_min: -180.0
* /ydlidar_node/auto_reconnect: True
* /ydlidar_node/baudrate: 230400
* /ydlidar_node/frame_id: laser_frame
* /ydlidar_node/frequency: 7.0
* /ydlidar_node/ignore_array:
* /ydlidar_node/low_exposure: False
* /ydlidar_node/port: /dev/ydlidar
* /ydlidar_node/range_max: 16.0
* /ydlidar_node/range_min: 0.1
* /ydlidar_node/resolution_fixed: True
* /ydlidar_node/reversion: False
* /ydlidar_node/samp_rate: 9
Asked by AnotherBeginner on 2019-11-13 09:16:00 UTC
I have a last idea : How do you power the lidar ? Is it only by connecting it to the computer ? In the documentation under the device connection part it says :
So can you try to use and external power supply and see if you finally get the ranges array at the size
720
instead of606
?Asked by Delb on 2019-11-14 08:48:19 UTC