Laser plugin always get inf value ?

asked 2021-06-04 12:18:56 -0500

jenanaputra gravatar image

updated 2021-06-07 01:09:01 -0500

I am using ubuntu 18.04, ROS Melodic , and Gazebo9 in Virtual Box to simulate my robot. I wanna my robot to be able to detect some obstacles in front of it, so I added laser plugin to my URDF file. When I set the visualize tag to be true and set the reference of laser plugin to MyRobot/base_link, the laser ray in Gazebo looks flickering. When I printed the value of /scan topic, all of the values of /scan topic always inf even though an obstacle placed in front of my robot, but it's sometimes returns a measured distance value.

When I set the reference of laser plugin to MyRobot/altimeter, the ray in Gazebo is gone. The /scan topic is available, but its value always inf even though an obstacle placed in front of my robot.

So, Does anyone know how to solve it ?

I also attached my file.xacro :

            <?xml version="1.0"?>
<robot name="MyRobot" xmlns:xacro="http://www.ros.org/wiki/xacro">
    <xacro:include filename="$(find r_description)/urdf/materials.xacro" />
    <xacro:include filename="$(find r_description)/urdf/MyRobot.gazebo" />
    <link name="MyRobot/base_link">
        <visual>
            <geometry>
                <mesh filename="package://r_description/meshes/base_link.STL"/> 
            </geometry>
            <material name="orange"/>
            <origin rpy="0 0 0" xyz="0 3.81548 -0.85"/>
        </visual>

        <inertial>
            <origin xyz="0 0 1" rpy="0 0 0"/>
            <mass value="1"/>
            <inertia
                ixx="1.0" ixy="0.0" ixz="0.0"
                iyy="1.0" iyz="0.0"
                izz="1.0"/>
        </inertial>

    <collision>
            <origin rpy="0 0 0" xyz="0 3.81548 -0.85"/>
    </collision>

    </link>

    <link name="MyRobot/dvl">
        <visual>
            <origin rpy="0 0 0" xyz="1.153 0 0.129"/>
        </visual>

        <inertial>
            <origin xyz="0 0 1" rpy="0 0 0"/>
            <mass value="1"/>
            <inertia
                ixx="1.0" ixy="0.0" ixz="0.0"
                iyy="1.0" iyz="0.0"
                izz="1.0"/>
        </inertial>

    <collision>
            <origin rpy="0 0 0" xyz="1.153 0 0.129"/>
    </collision>
    </link>

    <joint name="base_link_to_dvl_joint" type="fixed">
        <parent link="MyRobot/base_link"/>
        <child link="MyRobot/dvl"/>
        <origin rpy="0 0 0" xyz="1.153 0 0.129"/>
    </joint>

    <link name="MyRobot/altimeter">
        <visual>
            <origin rpy="0 0 0" xyz="1.45 0 -0.085"/>
        </visual>

        <inertial>
            <origin xyz="0 0 1" rpy="0 0 0"/>
            <mass value="1"/>
            <inertia
                ixx="1.0" ixy="0.0" ixz="0.0"
                iyy="1.0" iyz="0.0"
                izz="1.0"/>
        </inertial>

    <collision>
            <origin rpy="0 0 0" xyz="1.45 0 -0.085"/>
    </collision>

    </link>

    <joint name="base_link_to_altimeter_joint" type="fixed">
        <parent link="MyRobot/base_link"/>
        <child link="MyRobot/altimeter"/>
        <origin rpy="0 0 0" xyz="1.45 0 -0.085"/>
    </joint>

    <link name="MyRobot/gps">
        <visual>
            <origin rpy="0 0 0" xyz="-0 ...
(more)
edit retag flag offensive close merge delete

Comments

This is the file.gazebo :

<?xml version="1.0"?>

<robot> <gazebo reference="MyRobot/base_link"> <material>Gazebo/Orange</material> </gazebo>

<gazebo reference="MyRobot/base_link"> <sensor type="ray" name="lds_lfcd_sensor"> <pose>0 0 0 0 0 -0.77</pose> <visualize>true</visualize> <update_rate>50</update_rate> <ray> <scan> <horizontal> <samples>720</samples> <resolution>1</resolution> <min_angle>0.0</min_angle> <max_angle>1.57</max_angle> </horizontal> </scan> <range> <min>0.120</min> <max>10</max> <resolution>0.015</resolution> </range> <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.01</stddev> </noise> </ray> <plugin name="gazebo_ros_lds_lfcd_controller" filename="libgazebo_ros_laser.so"> <topicname>scan</topicname>

jenanaputra gravatar image jenanaputra  ( 2021-06-04 12:22:24 -0500 )edit

Its tough to see with the formatting issues (hint: indent all your code blocks by 4 spaces and then copy into the question). My guess is that you have an stl that describes some geometry around base_link and you have the laser scan inside of that geometry. The laser scans will hit your geometry from the inside causing erratic behavior. Your altimeter link is set to -0.085 from base_link. This means it is under base_link. If you base_link is in contact with your ground plane, then your altimeter link is below the ground plane. In this case Inf values make sense as there is nothing below the ground plane for the laser scans to interact with. Please fix the formatting on the xacro and include the whole .gazebo file for more help.

djchopp gravatar image djchopp  ( 2021-06-05 09:38:18 -0500 )edit