Ask Your Question
0

Creating world file for Gazebo with xacro

asked 2016-04-03 08:38:56 -0600

sefi_roee gravatar image

I'm trying to generate random boxes in a world file for Gazebo simulator. I know how to create a model sdf, and how to include it from the world file.

Now I want to create different sizes of boxes in the world file using xacro and width/height parameters.

I can't get it work. Please help :)

edit retag flag offensive close merge delete

Comments

Do you want to place models randomly? Or Do you want to place models with different sizes in world? What should be randomly size, position or both?

dyupleks gravatar imagedyupleks ( 2016-04-04 05:34:35 -0600 )edit

Hi, tnx for responding. Right now, my world file using multiple times <include> tag to include my object model (in the model the size is fixed to 1x1 and the position isn't determined) and adds <pose> tag for each. I'd like to be able to pass the "size" as a parameter to the included object.

sefi_roee gravatar imagesefi_roee ( 2016-04-04 06:26:43 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2016-04-04 07:03:33 -0600

I think it would be right in your case to use <population> tag. Pls, look at this tutorial . There exist random distribution of positions. Also, you can fix a size, but the size will be common size of N models, which you point in <model_count> tag.

"I'd like to be able to pass the "size" as a parameter to the included object" ---- In case, you want to put models with different size, I guess <population> tag will be not appropriate for that ..

edit flag offensive delete link more

Comments

Thanks for that. What if i have a different situation: I have a list of predetermined "size"s and "pose"s, and I want to generate world file includes them. I want the file to be as clean as possible, so I want to use single model file and include it many times and only specify size/pose for each?

sefi_roee gravatar imagesefi_roee ( 2016-04-04 07:31:24 -0600 )edit

<population> tag is not for this case.. Maybe, you are on right way to use multiple times <include>.. I cant be sure, because I dont know another solution.. Sorry :)

dyupleks gravatar imagedyupleks ( 2016-04-04 08:27:19 -0600 )edit

Ty. and is there a way to pass the "size" and "pose" as parameters in the include tag?

sefi_roee gravatar imagesefi_roee ( 2016-04-04 09:37:52 -0600 )edit

You can use <pose> tag inside of <include>. I never note the <size> tag in <include>. Look at this SDF specification . You can find all documentation about a tag and be sure what to use inside one..

dyupleks gravatar imagedyupleks ( 2016-04-04 21:33:15 -0600 )edit

The question "How to fix size of a model" is not answered for me too. Before, I changed it by SketchUp Make, but there must be a way to fix size in Gazebo too..

dyupleks gravatar imagedyupleks ( 2016-04-04 21:44:05 -0600 )edit

I hope there is a way to do it using xacro :)

sefi_roee gravatar imagesefi_roee ( 2016-04-04 21:51:32 -0600 )edit
0

answered 2016-04-03 13:57:02 -0600

Adnen gravatar image
edit flag offensive delete link more

Comments

First thing i did is to google it out and read this tutorial. Still, i couldnt work this out.

sefi_roee gravatar imagesefi_roee ( 2016-04-03 22:19:55 -0600 )edit
0

answered 2016-04-15 10:35:09 -0600

sefi_roee gravatar image

Hi, With the help I got, I was able to do the following:

I create the xacro file for the object:

<?xml version="1.0"?>

<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="box_obstacle">
   <xacro:arg name="row" default="0"/>
   <xacro:arg name="col" default="0"/>
   <xacro:arg name="width" default="1"/>
   <xacro:arg name="height" default="1"/>

  <link name="obstacle" type="fixed">
    <inertial>
      <origin xyz="$(arg row) $(arg col) 0.5" />
      <mass value="1.0" />
      <inertia  ixx="0.0" ixy="0.0"  ixz="0.0"  iyy="0.0"  iyz="0.0"  izz="0.0" />
    </inertial>
    <visual>
      <origin xyz="$(arg row) $(arg col) 0.5"/>
      <geometry>
        <box size="$(arg width) $(arg height) 1" />
      </geometry>
    </visual>
    <collision>
      <origin xyz="$(arg row) $(arg col) 0.5"/>
      <geometry>
        <box size="$(arg width) $(arg height) 1" />
      </geometry>
    </collision>
  </link>
  <gazebo reference="obstacle">
    <static>true</static>
    <material>Gazebo/Black</material>
  </gazebo>

</robot>

and my launch file looks like this:

 <launch>
     <arg name="world" default="$(find my_package)/worlds/empty.world"/>

      <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
      <include file="$(find gazebo_ros)/launch/empty_world.launch">
          <arg name="world_name" value="$(arg world)"/>
      </include>

     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=6.5 col:=4.0 width:=3 height:=6" name="obstacle_0" />
     <node args="-urdf -param obstacle_0 -model obstacle_0" name="spawn_obstacle_0" output="screen" pkg="gazebo_ros" respawn="false" type="spawn_model" />
     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=4.5 col:=4.0 width:=1 height:=2" name="obstacle_1" />
     <node args="-urdf -param obstacle_1 -model obstacle_1" name="spawn_obstacle_1" output="screen" pkg="gazebo_ros" respawn="false" type="spawn_model" />
     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=-4.5 col:=-9.0 width:=9 height:=2" name="obstacle_2" />
     <node args="-urdf -param obstacle_2 -model obstacle_2" name="spawn_obstacle_2" output="screen" pkg="gazebo_ros" respawn="false" type="spawn_model" />
</launch>

This works fine with few "obstacles", but when I try about 10 (instead of 3 here) the simulator doing weired things (I'm trying to attach images but >5 points are needed :()

 <launch>
     <arg name="world" default="$(find my_package)/worlds/empty.world"/>

      <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
      <include file="$(find gazebo_ros)/launch/empty_world.launch">
          <arg name="world_name" value="$(arg world)"/>
      </include>

     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=6.5 col:=4.0 width:=3 height:=6" name="obstacle_0" />
     <node args="-urdf -param obstacle_0 -model obstacle_0" name="spawn_obstacle_0" output="screen" pkg="gazebo_ros" respawn="false" type="spawn_model" />
     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=4.5 col:=4.0 width:=1 height:=2" name="obstacle_1" />
     <node args="-urdf -param obstacle_1 -model obstacle_1" name="spawn_obstacle_1" output="screen" pkg="gazebo_ros" respawn="false" type="spawn_model" />
     <param command="$(find xacro)/xacro.py $(find my_package)/objects/obstacle.urdf.xacro row:=-4.5 col:=-9.0 width:=9 height:=2" name="obstacle_2 ...
(more)
edit flag offensive delete link more

Comments

1

I suggest you to write new question, because the title differ from the content

dyupleks gravatar imagedyupleks ( 2016-04-16 10:24:26 -0600 )edit

Good point. Thanks

sefi_roee gravatar imagesefi_roee ( 2016-04-16 12:24:22 -0600 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-04-03 08:38:56 -0600

Seen: 2,074 times

Last updated: Apr 15 '16