Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate names of colliding entities in contact points message #1351

Merged
merged 10 commits into from
Feb 28, 2022

Conversation

adityapande-1995
Copy link
Contributor

@adityapande-1995 adityapande-1995 commented Feb 18, 2022

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

🎉 New feature

Summary

Currently, the contact points message has a Enitity member whose name field is not populated and just contains the id. This PR populates the name with the entity's full name, for e.g. world:shapes:model:ground_plane:link:link:collision:collision so it is clear in the message which pair of entities is colliding.

Test it

Modified an existing test case to check the full name of a colliding entity (contact_system.cc integration test)

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Feb 18, 2022
Signed-off-by: Aditya <[email protected]>
src/systems/physics/Physics.cc Outdated Show resolved Hide resolved
src/systems/physics/Physics.cc Outdated Show resolved Hide resolved
test/integration/contact_system.cc Outdated Show resolved Hide resolved
@azeey
Copy link
Contributor

azeey commented Feb 22, 2022

Can you also fix the codecheck errors?

@adityapande-1995 adityapande-1995 self-assigned this Feb 22, 2022
@codecov
Copy link

codecov bot commented Feb 22, 2022

Codecov Report

Merging #1351 (84faae9) into ign-gazebo6 (d03a77e) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@               Coverage Diff               @@
##           ign-gazebo6    #1351      +/-   ##
===============================================
+ Coverage        62.98%   62.99%   +0.01%     
===============================================
  Files              301      301              
  Lines            24199    24208       +9     
===============================================
+ Hits             15242    15251       +9     
  Misses            8957     8957              
Impacted Files Coverage Δ
src/systems/physics/Physics.hh 100.00% <ø> (ø)
src/systems/physics/Physics.cc 71.75% <100.00%> (+0.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d03a77e...84faae9. Read the comment docs.

@peci1
Copy link
Contributor

peci1 commented Feb 23, 2022

Thanks for the PR, it looks useful! However, I would really like to see a performance analysis of this. Try to create a world with say 10 000 contacts and measure the update rate with and without this PR...

@adityapande-1995
Copy link
Contributor Author

adityapande-1995 commented Feb 24, 2022

Performance benchmarking :

Generate world file

I used the following erb template to generate a test world file :

<?xml version="1.0" ?>
<!--
  To generate sdf file using this erb template, run `erb -T 1 shapes_population.sdf.erb > shapes_population.sdf`
-->
<sdf version="1.6">
  <world name="shapes">
    <physics name="1ms" type="ignored">
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1.0</real_time_factor>
    </physics>
    <plugin
      filename="ignition-gazebo-physics-system"
      name="ignition::gazebo::systems::Physics">
    </plugin>
    <plugin
      filename="ignition-gazebo-sensors-system"
      name="ignition::gazebo::systems::Sensors">
      <render_engine>ogre2</render_engine>
    </plugin>
    <plugin
      filename="ignition-gazebo-scene-broadcaster-system"
      name="ignition::gazebo::systems::SceneBroadcaster">
    </plugin>
    <plugin
      filename="ignition-gazebo-contact-system"
      name="ignition::gazebo::systems::Contact">
    </plugin>

    <scene>
      <ambient>1.0 1.0 1.0</ambient>
      <background>0.8 0.8 0.8</background>
    </scene>

    <light type="directional" name="sun">
      <cast_shadows>true</cast_shadows>
      <pose>0 0 10 0 0 0</pose>
      <diffuse>0.8 0.8 0.8 1</diffuse>
      <specular>0.8 0.8 0.8 1</specular>
      <attenuation>
        <range>1000</range>
        <constant>0.9</constant>
        <linear>0.01</linear>
        <quadratic>0.001</quadratic>
      </attenuation>
      <direction>-0.5 0.1 -0.9</direction>
    </light>

    <model name="ground_plane">
      <static>true</static>
      <link name="link">
        <collision name="collision">
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
        </collision>
        <visual name="visual">
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <material>
            <ambient>0.8 0.8 0.8 1</ambient>
            <diffuse>0.8 0.8 0.8 1</diffuse>
            <specular>0.8 0.8 0.8 1</specular>
          </material>
        </visual>
      </link>
    </model>

    <%
      # number of population
      n = 100
      for m in (0..n)
        geom_1 = 'box'
    %>

    <model name="<%= geom_1 %>_<%= m.to_s %>">
      <pose><%= 0 + m*1.5 %> 0 0.5 0 0 0</pose>
      <link name="box_link">
        <inertial>
          <inertia>
            <ixx>1</ixx>
            <ixy>0</ixy>
            <ixz>0</ixz>
            <iyy>1</iyy>
            <iyz>0</iyz>
            <izz>1</izz>
          </inertia>
          <mass>1.0</mass>
        </inertial>
        <collision name="box_collision">
          <geometry>
            <box>
              <size>1 1 1</size>
            </box>
          </geometry>
        </collision>
        
        <sensor name='sensor_contact_<%= m.to_s %>' type='contact'>
	<contact>
	  <collision>box_collision</collision>
	  <topic>/robot_collision</topic>
        </contact>
        <always_on>1</always_on>
        <update_rate>1000</update_rate>
       </sensor>

        <visual name="box_visual">
          <geometry>
            <box>
              <size>1 1 1</size>
            </box>
          </geometry>
          <material>
            <ambient>1 0 0 1</ambient>
            <diffuse>1 0 0 1</diffuse>
            <specular>1 0 0 1</specular>
          </material>
        </visual>
      </link>
    </model>

    <%
      end
    %>
  </world>
</sdf>

Then, erb -T 1 template.erb > test.sdf ; ign gazebo -r -s test.sdf runs the simulation.

Data collection

I collected the real time factor data in a text file (let the simulation run for around 30 seconds) : ign topic -e -t /stats | grep real_time_factor | cut -c 19- > data.txt, and got an average of that data using : awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; print n}' data.txt

Results

Trails Avg real time factor gazebo6 branch Avg real time factor current branch % change
1. 0.0918426 0.0894021 -2.65
2. 0.0914473 0.0910263 -0.46
3. 0.0927287 0.0912242 -1.62
4. 0.0926891 0.0915801 ​ -1.19

On an average, the real time factor for this branch seems to be slower by 1.5%

@adityapande-1995 adityapande-1995 force-pushed the aditya/contact_pts_set_entity_names branch from 2e2e1dd to e08983e Compare February 24, 2022 23:37
@adityapande-1995
Copy link
Contributor Author

adityapande-1995 commented Feb 24, 2022

Added an optional parameter so that the names of colliding entities will not be populated and performance won't be affected. This parameter remains true by default (so the names will be populated).

Copy link
Contributor

@azeey azeey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a couple of minor comments.

src/systems/physics/Physics.cc Outdated Show resolved Hide resolved
test/integration/contact_system.cc Outdated Show resolved Hide resolved
@azeey
Copy link
Contributor

azeey commented Feb 25, 2022

Also could you document the parameter in Physics.hh?

@adityapande-1995 adityapande-1995 force-pushed the aditya/contact_pts_set_entity_names branch from 60a263b to ed305a9 Compare February 25, 2022 00:25
@adityapande-1995
Copy link
Contributor Author

I've added the docstring, not sure if that is the preferred style though.

@@ -64,6 +64,19 @@ namespace systems

/// \class Physics Physics.hh ignition/gazebo/systems/Physics.hh
/// \brief Base class for a System.
/// Includes optional parameter : <include_entity_names>. When set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good. For other systems we have been listing the parameters in a bullet list, but since this is the only parameter here, I think the format is fine.

test/worlds/contact.sdf Outdated Show resolved Hide resolved
@peci1
Copy link
Contributor

peci1 commented Feb 26, 2022

Performance benchmarking :

Thanks a lot for the benchmark, it's good to see the performance isn't affected that heavily. In normal situations with just a few contacts, the difference would be negligible.

@adityapande-1995 adityapande-1995 merged commit 1e31b53 into ign-gazebo6 Feb 28, 2022
@adityapande-1995 adityapande-1995 deleted the aditya/contact_pts_set_entity_names branch February 28, 2022 21:34
@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/new-ignition-releases-2022-03-25-fortress-edifice-citadel/1343/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏯 fortress Ignition Fortress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants