Ask Your Question
1

Trouble running Gazebo simulation with camera plugin

asked 2020-02-29 12:50:16 -0500

Naza karim gravatar image

Hi

I am trying to add a camera to the iris drone in my gazebo simulation. I tried using many models (iris_fpv_cam, iris_downward_depth_camera, iris_stereo_camera ...) by changing px4 launch files' vehicle argument. But i keep getting:

Error: Unknown model 'iris_fpv_cam'
ERROR [px4] Startup script returned with return value: 256

I also tried to modify iris.sdf and iris.xacro files as described here. And I get the following errors:

Error [parser.cc:550] Required attribute[name] in element[collision] is not specified in SDF.
Error [parser.cc:769] Error reading element <collision>
Error [parser.cc:769] Error reading element <link>
Error [parser.cc:769] Error reading element <model>
Error [parser.cc:394] Unable to read element <sdf>
Error:   Could not find the 'robot' element in the xml file
         at line 81 in /build/urdfdom-UJ3kd6/urdfdom-0.4.1/urdf_parser/src/model.cpp
Error [parser_urdf.cc:3408] Unable to call parseURDF on robot model
Error [parser.cc:340] parse as old deprecated model file failed.

Can someone please assist me on how to add a downward camera attached to my drones?

Thank you

edit retag flag offensive close merge delete

Comments

Hi @Naza karim,

To understand better your problem, can you post your URDF files here?

For me, it seems that Gazebo is having problems parsing the URDF description, missing certain tags and attributes.

Weasfas gravatar image Weasfas  ( 2020-03-02 02:21:44 -0500 )edit

Hi @Weasfas , thanks for your comment. Here is my iris.sdf: https://pastebin.com/VjeCp5K0 and in iris.xacro, I just added a xacro property :

<xacro:property name="camera_link" value="0.05" />
Naza karim gravatar image Naza karim  ( 2020-03-02 05:59:20 -0500 )edit

The modifications I made in the file is from line 56 to 85.

Naza karim gravatar image Naza karim  ( 2020-03-02 06:02:08 -0500 )edit

In line 65 of the SDF is defined a collision and visual with no names, as SDF standard states, the name is compulsory. Try that cause I think all other errors come from the parsing of that unique line.

Weasfas gravatar image Weasfas  ( 2020-03-02 06:19:16 -0500 )edit

Thank you @Weasfas , I added names and corrected the format to fit sdf files, but not yet able to see ROS topic that publishes images.

Naza karim gravatar image Naza karim  ( 2020-03-02 08:45:27 -0500 )edit

@Naza karim Have you found a solution for this? I am having the exact same problem.

rezenders gravatar image rezenders  ( 2020-05-07 14:52:51 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2020-03-02 06:30:09 -0500

Joe28965 gravatar image

updated 2020-03-02 06:40:13 -0500

so by looking at the iris.sdf file, I can see that you've pasted URDF into the .sdf file. If we take a look at the following two pieces of code we can see what I mean:

  <inertial>
    <mass value="1e-5" />
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <inertia ixx="1e-6" ixy="0" ixz="0" iyy="1e-6" iyz="0" izz="1e-6" />
  </inertial>

This first part is from line 80-84, the piece you've added.

  <inertial>
    <pose frame=''>0 0 0 0 -0 0</pose>
    <mass>0.015</mass>
    <inertia>
      <ixx>1e-05</ixx>
      <ixy>0</ixy>
      <ixz>0</ixz>
      <iyy>1e-05</iyy>
      <iyz>0</iyz>
      <izz>1e-05</izz>
    </inertia>
  </inertial>

This second part is from line 89-100, the part that already existed.

The way you write down sdf vs urdf is different, so your piece of code should look like this:

  <inertial>
    <pose frame=''>0 0 0 0 0 0</pose>
    <mass>1e-05</mass>
    <inertia>
      <ixx>1e-06</ixx>
      <ixy>0</ixy>
      <ixz>0</ixz>
      <iyy>1e-06</iyy>
      <iyz>0</iyz>
      <izz>1e-06</izz>
    </inertia>
  </inertial>

The same goes for all the lines you've added (56-85).

To get to the actual error you're seeing Required attribute[name] in element[collision] is not specified in SDF that's from line 65-70.

  <collision>
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <geometry>
  <box size="${camera_link} ${camera_link} ${camera_link}"/>
    </geometry>
  </collision>

The collision requires a name, so line 65 should have been:

  <collision name="camera_link_collision">

There are probably more errors, but like I said, I think you get those errors because you just simply add URDF in a .sdf file. I know that the other way around, you can fix this by adding

<gazebo reference="${link_name}">
     ...
</gazebo>

around the piece of sdf. I don't know if there is a URDF equivalent or if you should just rewrite it to sdf.

EDIT because I forgot: http://sdformat.org/spec might be an interesting site to take a look at.

edit flag offensive delete link more

Comments

Thank you for mentioning this @Joe28965 . I have modified the sdf file, attached. I can see the box that should represents the camera now, but I still don't see any ROS topic that publishes images :(

Naza karim gravatar image Naza karim  ( 2020-03-02 08:26:36 -0500 )edit

The only error I get:

ERROR [commander] LED: open /dev/led0 failed
WARN  [commander] LED init failed

But the simulation is launching without errors now, regardless of the fact that I can't access camera images.

Naza karim gravatar image Naza karim  ( 2020-03-02 08:43:22 -0500 )edit

that's because you never call the plugin anywhere. The sdf file you have so far gives you the physical representation of the camera, it does not actually simulate the working of the camera (Imagine me just giving you the shell of the camera, without any electrical components, you won't be able to get an image). In order to get an image you need to add the camera plugin. this tutorial should be able to help you.

Joe28965 gravatar image Joe28965  ( 2020-03-02 09:09:40 -0500 )edit

@Joe28965 Should I create an iris.gazebo file or modify it? I can't find it. I have seen the tutorial but it is not clear to me.

Naza karim gravatar image Naza karim  ( 2020-03-02 09:13:47 -0500 )edit

what you could try is add the plugin to the bottom of your .sdf file (with the other plugins). That might be enough to get it to work, although I'm not sure

Joe28965 gravatar image Joe28965  ( 2020-03-02 09:49:16 -0500 )edit

have you been able to get it working since?

Joe28965 gravatar image Joe28965  ( 2020-03-05 04:01:25 -0500 )edit

Yes, I used iris_base.xacro file instead.

Naza karim gravatar image Naza karim  ( 2020-03-28 15:00:54 -0500 )edit
0

answered 2020-05-15 18:17:59 -0500

rezenders gravatar image

I had the same issue, you can check the link https://github.com/PX4/sitl_gazebo/is...

You have to maintain the vehicle argument as iris(just don't change it) and change only the sdf argument.

<include file="$(find px4)/launch/mavros_posix_sitl.launch">
    <arg name="respawn_gazebo" value="true"/>
    <arg name="respawn_mavros" value="true"/>
    <arg name="sdf" value="$(find mavlink_sitl_gazebo)/models/$(arg iris_fpv_cam)/$(arg iris_fpv_cam).sdf"/>
    <arg name="verbose" value="true"/>
</include>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-02-29 12:50:16 -0500

Seen: 1,079 times

Last updated: May 15 '20