Gazebo | Ignition | Community
Ask Your Question
0

[Buoyancy Plugin] Possible bug

asked 2016-06-28 12:01:44 -0600

Marco gravatar image

Hi everybody,

I'm using Gazebo 6.6.0 with Ubuntu 14.04 and currently I'm experiencing strange behaviors with the buoyancy plugin shipped with this version.

The following minimal working example shows two sphere, of mass 1 kg, and the usage of the buoyancy plugin where I force the volume of these two sphere to be equal to their mass. Having fluid density equal to 1 should result having the two objects floating in the air, because in this case force_of_gravity == force_of_buoyancy. Unfortunately only the first sphere, l1, floats whereas the second one falls down.

<?xml version='1.0'?>
<sdf version='1.5'>
<model name="buoyancy_example">

  <!-- ================== link l1 ================== -->
  <link name="l1">

    <pose>0 0 1 0 0 0</pose>

    <inertial> <mass>1</mass> </inertial>

    <visual name='visual'>
      <geometry>
          <sphere> <radius>0.5</radius> </sphere>
      </geometry>
    </visual>

    <collision name='collision'>
      <geometry>
          <sphere> <radius>0.5</radius> </sphere>
      </geometry>
    </collision>

  </link>

  <!-- ================== link l2 ================== -->
  <link name="l2">

    <pose>2 0 1 0 0 0</pose>

    <inertial> <mass>1</mass> </inertial>

    <visual name='visual'>
      <geometry>
          <sphere> <radius>0.5</radius> </sphere>
      </geometry>
    </visual>

    <collision name='collision'>
      <geometry>
          <sphere> <radius>0.5</radius> </sphere>
      </geometry>
    </collision>

  </link>

  <!-- ================== buoyancy plugin ================== -->
  <plugin name="buoyancy" filename="libBuoyancyPlugin.so">

    <fluid_density>1</fluid_density>

    <link name="l1">
      <center_of_volume>0 0 0</center_of_volume>
      <volume>1</volume> <!-- volume == mass ==> object should float -->
    </link>

    <link name="l2">
      <center_of_volume>0 0 0</center_of_volume>
      <volume>1</volume> <!-- volume == mass ==> object should float -->
    </link>

  </plugin>

</model>
</sdf>

image description

Based on my trials I believe that the problem is in this for statement here, which doesn't return the next link element within the plugin tag. Does anyone know how I can fix this bug and be able to use multiple "links" tags within this plugin?

Thanks,

Marco.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-06-28 12:07:20 -0600

chapulina gravatar image

updated 2016-06-29 11:07:05 -0600

It looks like a bug. That statement you mentioned should be:

linkElem = linkElem->GetNextElement("link")

It would be great if you could make a pull request to Gazebo with the fix, and a bonus if you add a test with your use case. The pull request could be targeted at branch gazebo6.

edit flag offensive delete link more

Comments

Hi, I just checked your suggest and now the plugin works ... thanks :) I'll make the pull request, but I'm not totally sure about how to write a test for it ... could you give me more information about how to do it? Thanks

Marco gravatar imageMarco ( 2016-06-29 02:35:34 -0600 )edit

Oh I wouldn't worry too much about the test, it would just be a bonus ;) It would probably involve writing an integration test: https://bitbucket.org/osrf/gazebo/src/default/test/integration/

chapulina gravatar imagechapulina ( 2016-06-29 11:05:51 -0600 )edit

ok, I created a pull request targeted to gazebo6. About the test: I'm not totally sure about how to check if the plugin is working well. Should I spawn two objects and check if the heights of their centers of gravity are > 0 ?

Marco gravatar imageMarco ( 2016-06-30 01:50:57 -0600 )edit

Thanks! Sounds good. Make sure to let enough iterations pass so the models have time to float.

chapulina gravatar imagechapulina ( 2016-06-30 09:22:34 -0600 )edit

The pull request with the fix has been merged by the way ;) You're still welcome to add a test, it will make sure we don't break this in the future by mistake.

chapulina gravatar imagechapulina ( 2016-06-30 12:24:44 -0600 )edit

cool! I'll try to write a simple test in the next days ;)

Marco gravatar imageMarco ( 2016-07-01 01:39:39 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-06-28 12:01:44 -0600

Seen: 521 times

Last updated: Jun 29 '16