ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Adding a lidar scanner on a car

asked 2020-02-06 16:37:35 -0600

John999991 gravatar image

updated 2020-02-10 18:48:43 -0600

jayess gravatar image

Dear all, I have exported a small car model from Solidworks to URDF and I am trying to add a lidar laser scanner at the top. I have already tried many things but haven't managed to make the lidar even appear on top of the car, in gazebo. Most of the time I get an error saying that gazebo URDF parser cannot parse the file.

I am using the gazebo7.

The URDF(without the lidar) is the following:

<?xml version="1.0" encoding="utf-8"?>

<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="robot">

  <link
    name="base_link">
    <inertial>
      <origin
        xyz="0.00394152246605745 -0.175487321975129 -0.0315221316804128"
        rpy="0 0 0" />
      <mass
        value="4.05665355311749" />
      <inertia
        ixx="0.0147593093765132"
        ixy="-1.60349764774838E-07"
        ixz="2.63848097894018E-07"
        iyy="0.0259026379424139"
        iyz="-0.000771824542874729"
        izz="0.0208164827082191" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://robot/meshes/base_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.752941176470588 0.752941176470588 0.752941176470588 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://robot/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>
  <link
    name="FL">
    <inertial>
      <origin
        xyz="0.014 6.9389E-18 0"
        rpy="0 0 0" />
      <mass
        value="0.061522" />
      <inertia
        ixx="5.5443E-05"
        ixy="8.0237E-21"
        ixz="-2.5215E-22"
        iyy="3.0092E-05"
        iyz="0"
        izz="3.0092E-05" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://robot/meshes/FL.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.29804 0.29804 0.29804 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://robot/meshes/FL.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="FLJ"
    type="continuous">
    <origin
      xyz="-0.14809 0.0035605 0.044019"
      rpy="0.99029 0 -3.1416" />
    <parent
      link="base_link" />
    <child
      link="FL" />
    <axis
      xyz="1 0 0" />
  </joint>
  <link
    name="FR">
    <inertial>
      <origin
        xyz="-0.014 6.9389E-18 6.9389E-18"
        rpy="0 0 0" />
      <mass
        value="0.061522" />
      <inertia
        ixx="5.5443E-05"
        ixy="-1.9005E-20"
        ixz="6.5291E-21"
        iyy="3.0092E-05"
        iyz="-1.0164E-20"
        izz="3.0092E-05" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://robot/meshes/FR.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.29804 0.29804 0.29804 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://robot/meshes/FR.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="FRJ"
    type="continuous">
    <origin
      xyz="0.15595 0.0035605 0.044019"
      rpy="2.8107 0 -3.1416" />
    <parent
      link="base_link" />
    <child
      link="FR" />
    <axis
      xyz="1 0 0" />
  < ...
(more)
edit retag flag offensive close merge delete

Comments

do you see any errors with original URDF file,I mean without lidar ?

Fetullah Atas gravatar image Fetullah Atas  ( 2020-02-06 19:22:51 -0600 )edit

No. Everything loads and behaves perfectly.

John999991 gravatar image John999991  ( 2020-02-07 07:12:49 -0600 )edit

Gazebo requires that each link has an inertialelement to be simulated. http://gazebosim.org/tutorials/?tut=r... From your provided snippet it looks like the link laz_base doesn't have one.

Also (but it may be because you copy pasted only part of the files) each opened tag in your xacro files needs a matching closing tag (</link>, </robot>etc)

marguedas gravatar image marguedas  ( 2020-02-08 04:07:53 -0600 )edit

Please see the answer above. I couldn't paste the amount of lines required to show you the .xarco so, I used the answer instead of the comment.

John999991 gravatar image John999991  ( 2020-02-08 04:49:47 -0600 )edit
1

@John999991: please do not post answers unless you are answering your own question.

To provide additional information, edit your original question. You may use the edit button to do that.

gvdhoorn gravatar image gvdhoorn  ( 2020-02-08 04:54:33 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-02-10 04:11:59 -0600

Joe28965 gravatar image

Most of the time I get an error saying that gazebo URDF parser cannot parse the file.

This means you were able to get it to spawn without errors some of the times? If it spawns, you say it spawns without you being able to see the lidar.

So, the tutorial I was reading said you have to include :

  <xacro:include filename="$(find PACKAGE)/urdf/lidar.uxacro"/>
  <joint name="lidarGlue" type="fixed">
    <parent link="body"/>
    <child link="laz_base"/>
    <origin xyz="0 0 ${body_height/2}"/>
  </joint>

on your URDF file so that the geometry may appear on the 'Parent Link'.

So, I changed the Parent link to my own ( basse_plate ) and ${body_height/2} to 0 as well as adding a rpy="0 0 0" after origin xyz.

In other words, you say the distance between the origin of the body and the origin of the lidar is 0 in every direction. The origin of a body is by default in the center of the link. In other words, if it spawns without errors, your lidar will probably be somewhere hidden inside your car near the center of basse_plate

The parser refuses to load the model and the problem seems to be :

<xacro:include filename="$(find PACKAGE)/urdf/lidar.uxacro"/>

I also deleted the $(find PACKAGE)/urdf/ part placing the lidar.uxacro on the same folder as my robots URDF file and rename lidar.uxacro to lidar.xacro ( as the name of the lidar URDF I created earlier ), but I didn't manage to load the Lidar on the model.

That last part there is correct, you should change it to lidar.xacro if that's what your file is called. I'm not sure about the first part. $(find PACKAGE)/urdf is used to tell xacro where to find your file. If your file is located in `~/catkin_ws/src/YOUR_PACKAGE_NAME/FIRST_FOLDER/ANOTHER_FOLDER/lidar.xacro your line should look like:

<xacro:include filename="$(find YOUR_PACKAGE_NAME)/FIRST_FOLDER/ANOTHER_FOLDER/lidar.xacro"/>

Which is what they do on that line you edited. (of course replace the all capitals parts with the names of your package and any folders that are between your package and your lidar.xacro file.

If you still have any questions please add the precise error as well. I've some experience concerning xacro and urdf, but I will be able to help a lot easier with the exact error.

edit flag offensive delete link more

Comments

Let me provide an update:

The base link now in named: TB

I included the following XML at the end of the URDF of my robot:

  <xacro:include filename="$(find robot)/urdf/lidar.urdf"/>
  <joint name="TBJ" type="fixed">
    <parent link="TB"/>
    <child link="laz_base"/>
    <origin xyz="0 0 0"/>
  </joint>

So: robot = My package

TBJ: The joint on which the base of the Lidar wil be attached

I have converted XARCO to URDF (using: rosrun xacro xacro file1.xacro > file2.urdf ) and <origin xyz="0 0 ${base_height/2}"/> to <origin xyz="0 0 0"/>

Result:

Error [parser_urdf.cc:3408] Unable to call parseURDF on robot model

Error [parser.cc:340] parse as old deprecated model file failed.

If on the other hand I use the original lidar.xarco instead of the URDF one, I get:

Spawn status: SpawnModel: Entity pushed ...(more)

John999991 gravatar image John999991  ( 2020-02-10 14:32:25 -0600 )edit

Sorry for taking so long to reply, I was feeling a bit under the weather.

so the strange part is, I've copied the code you've provided and made my own two files and I was able to spawn it in gazebo. Obviously I didn't have any of your meshes, so I replaced them with simple boxes, but it worked for me.

Couple questions, I assume you use a launch file to spawn the robot in Gazebo. What does the launch file look like?

Second, regarding this line rosrun xacro xacro file1.xacro > file2.urdf was your terminal in the folder where your xacro file was located when you called it? if it was in your home folder, it would throw an error (it's fiddly like that)

Third, again regarding rosrun xacro xacro file1.xacro > file2.urdf The correct way would be for file1.xacro ...(more)

Joe28965 gravatar image Joe28965  ( 2020-02-12 01:43:02 -0600 )edit

Thank you for your reply. I have managed yesterday to spawn my model with the Lidar on top. The problem seemed to be a duplicate definition of the robot name tag, somewhere, which I didn't see all this time. Now with that being said, it is rather difficult to make it send distance data to ROS. If you can point a good tutorial on how to place a lidar on a model and cooperate with ROS, it would be most helpful. Thanx again!

John999991 gravatar image John999991  ( 2020-02-12 02:30:41 -0600 )edit

There are quite a few tutorials available on gazebosim.org, I would recommend you check this one out Tutorial: Using Gazebo plugins with ROS it has a lot of tutorials on different sensors, one is a lidar

Joe28965 gravatar image Joe28965  ( 2020-02-12 02:41:03 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2020-02-06 16:37:35 -0600

Seen: 1,214 times

Last updated: Feb 10 '20