fast Hokuyo laser scan data with ROS

Typically: "How do I... ", "How can I... " questions
Post Reply
Thura
Posts: 5
Joined: 13 Jul 2018, 18:27

fast Hokuyo laser scan data with ROS

Post by Thura »

Hi
I'm trying to send the laser scan data from Hokuyo_URG_04LX on CoppeliaSim to ROS but so far I can't figure out how to make it work correctly.

I could send the transform from laser_frame to world_frame and tested to see it works correctly on rviz.
I created a topic with message, sensor_msgs/LaserScan and packed the sensor informations and data for sending to ROS. But when I view it on Rviz, it appears to be incorrect.

CoppeliaSim image: https://drive.google.com/file/d/1Eu_idq ... sp=sharing

Rviz image: https://drive.google.com/file/d/1ZnWAN9 ... sp=sharing

I think maybe I incorrectly assigned the values to the LaserScan message, although, I have tried many values and searched everywhere without success.

Here is my message,

Code: Select all

function sendLaserData(data)
    local laserDat
    local intensity={10}
    laserDat={
        header=
        {
            stamp=simROS.getTime(),
            frame_id="fastHokuyo"
        },
        angle_min=(-50*(math.pi/180)),
        angle_max=(50*(math.pi/180)),
        angle_increment=(0.1428*(math.pi/180)),
        time_increment=0.5,
        range_min=0.1,
        range_max=5,
        ranges=data,
        intensities=intensity
    }
    simROS.publish(pub, laserDat)
end
Please give me some recommendations
Thanks a lot!

fferri
Posts: 627
Joined: 09 Sep 2013, 19:28

Re: fast Hokuyo laser scan data with ROS

Post by fferri »

Refer to the documentation of the sensor_msgs/LaserScan message.

CoppeliaSim uses SI units (i.e.: meters, radians, and seconds).

By the way your code doesn't show how you create the data arrays.

Thura
Posts: 5
Joined: 13 Jul 2018, 18:27

Re: fast Hokuyo laser scan data with ROS

Post by Thura »

I use the array of data from the sensor, "measuredData" , as already implemented in the Hokuyo sensor child script and then pass that data directly into the function for sending to ROS as seen on the previous function code.

This is the portion of code information from CoppeliaSim

Code: Select all

 
    -- measuredData now contains all the points that are closer than the sensor range
    -- For each point there is the x, y and z coordinate (i.e. 3 number for each point)
    -- Coordinates are expressed relative to the sensor frame.
    -- You can access this data from outside via various mechanisms. The best is to first
    -- pack the data, then to send it as a string. For example:
    --

    sendLaserData(measuredData)            -- Assign to ROS message and publish the topic
    
But as seen from the pictures I attached of Coppeliasim and Rviz, The data visualization appears to be incorrect. I don't know what I did wrong here

fferri
Posts: 627
Joined: 09 Sep 2013, 19:28

Re: fast Hokuyo laser scan data with ROS

Post by fferri »

Thura wrote:
24 Mar 2020, 05:37
This is the portion of code information from CoppeliaSim

Code: Select all

 
    -- measuredData now contains all the points that are closer than the sensor range
    -- For each point there is the x, y and z coordinate (i.e. 3 number for each point)
Do you realize sensor_msgs/LaserScan works with points in polar coordinates, and expects points to be spaced evenly between angle_min and angle_max?

http://docs.ros.org/melodic/api/sensor_ ... rScan.html

fferri
Posts: 627
Joined: 09 Sep 2013, 19:28

Re: fast Hokuyo laser scan data with ROS

Post by fferri »

Note that there is a Hokuyo laser scanner (Hokuyo_URG_04LX_UG01_ROS) which is made specifically for ROS. Athough it is for the old ROS pugin, it might be easier to adjust.

Thura
Posts: 5
Joined: 13 Jul 2018, 18:27

Re: fast Hokuyo laser scan data with ROS

Post by Thura »

Thank you so much for your advises! I was so confused about the "range" element but things are clearer now.
It didn't occur to me to use the Hokuyo sensor with well implemented code for ROS. Now I'm using it and I've succeeded sending the laser data to Rviz.

Thank a million, friend!

Post Reply