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

CLI model info dump #893

Merged
merged 9 commits into from
Jul 23, 2021
Merged

Conversation

WagnerMarcos
Copy link
Contributor

@WagnerMarcos WagnerMarcos commented Jun 28, 2021

🎉 New feature

Related to #313

Summary

Adding a model command that is able to print:

  • Whole model (model pose, model links, model joints, model bounding box)
  • Just pose.
  • All links.
  • All joints.
  • A given link.
  • A given joint.

For this, the command can be used the following way:
ign model -m [model_name] to get the full information of the model.
ign model -m [model_name] --pose to get the pose information.
ign model -m [model_name] --links to get the links information.
ign model -m [model_name] --joints to get the joints information.
ign model -m [model_name] --link [link_name] to get a certain link information.
ign model -m [model_name] --joint [joint_name] to get a certain joint information.

Pendings in this PR:

  • Complete tests.

Description

This features implements a new command allowing the user to request information about a model in the running world. To get this information, a copy of the ECM is created making use of the serialized state message, which is acquired from the /state service, as shown in #859. From there, each desired component is taken from the ECM snapshot and serialized.

This command was going to be initially implemented along the gazebo command, but then it was separated into a new folder following the log structure, in order to separate the responsibilities of each command and also avoid any unwanted conflict between the subcommands.

Using this command you will be able to the following information:

  • Model name.
  • Model pose.
  • Model links.
    • Link name.
    • Link parent.
    • Link mass.
    • Link inertial matrix.
    • Link pose.
  • Model joints.
    • Joint name.
    • Joint parent.
    • Joint parent link.
    • Joint child link.
  • Model boundary box.
    • Bounding box name.
    • Bounding box parent.
    • Bounding box size.
    • Bounding box center.
    • Bounding box minimum corner.
    • Bounding box maximum corner.

Test it

  • Run a gazebo simulation
  • Try some of the aforementioned commands.

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

@github-actions github-actions bot added the 🏰 citadel Ignition Citadel label Jun 28, 2021
@francocipollone francocipollone self-requested a review June 28, 2021 18:04
@francocipollone
Copy link
Contributor

I will review it while the tests are finished.

@chapulina chapulina changed the title Wagnermarcos/cli model info dump CLI model info dump Jun 28, 2021
@WagnerMarcos WagnerMarcos force-pushed the wagnermarcos/CLI_model_info_dump branch 2 times, most recently from f4e5cdd to df9eee1 Compare June 29, 2021 19:50
@WagnerMarcos
Copy link
Contributor Author

Here is a little demo running the diff_drive world. You can see here the usage of the model command, requesting the list of available models in the world, the whole model description, and even the link list and then a link in particular. You can request all the joints and a particular joint the same way.

modelDemo.mp4

I am of course open to any suggestion about the way the information is displayed here.

@WagnerMarcos
Copy link
Contributor Author

The functionality yet to be tested is to display the properties of a bounding box component, even though the implementation for it is ready. The reason for this is that I haven't found a world containing such component. Any suggestions about a world I could use for this?

@WagnerMarcos WagnerMarcos force-pushed the wagnermarcos/CLI_model_info_dump branch from bc3d437 to 5e33380 Compare July 1, 2021 17:18
@chapulina
Copy link
Contributor

I haven't found a world containing such component

We don't have any systems or examples using that component. Some system needs to create the AxisAlignedBox component for the entity, like SubT's VisibilityPlugin does.

My suggestion is to leave this functionality out for now. In the future we could add a simple system that enables bounding box calculation on demand (because it's too expensive to do it all the time).

Copy link
Contributor

@francocipollone francocipollone left a comment

Choose a reason for hiding this comment

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

Nice new feature!
I left a bunch of minor comments. ptal!

model/src/cmd/cmdmodel.rb.in Outdated Show resolved Hide resolved
model/src/cmd/cmdmodel.rb.in Outdated Show resolved Hide resolved
model/src/cmd/ignmodel.yaml.in Outdated Show resolved Hide resolved
model/src/cmd/cmdmodel.rb.in Outdated Show resolved Hide resolved
model/src/cmd/cmdmodel.rb.in Outdated Show resolved Hide resolved
model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
model/src/ModelCommandAPI_TEST.cc Outdated Show resolved Hide resolved
model/src/ModelCommandAPI_TEST.cc Outdated Show resolved Hide resolved
Copy link
Contributor

@francocipollone francocipollone left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments!. Just added a few nits

model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
model/src/ModelCommandAPI_TEST.cc Outdated Show resolved Hide resolved
model/src/ModelCommandAPI_TEST.cc Outdated Show resolved Hide resolved
@francocipollone francocipollone marked this pull request as ready for review July 12, 2021 14:51
@francocipollone
Copy link
Contributor

CI is failing when running test because of :

Library error for [/usr/local/lib/libignition-gazebo3-model.so.3.8.0]: can't load /usr/local/lib/libignition-gazebo3-model.so.3.8.0

I haven't faced this error when running it locally though.

@francocipollone
Copy link
Contributor

Probably adding a tutorial using the ign model cli at ignition-gazebo/tutorials would be needed, right @chapulina ?

@chapulina
Copy link
Contributor

Probably adding a tutorial using the ign model cli at ignition-gazebo/tutorials would be needed, right @chapulina ?

+1, that would help giving the tool some visibility, otherwise it's difficult for users to discover it. It doesn't need to be too detailed, just straight to the point showing that the tool exists and some examples. Thanks!

@WagnerMarcos WagnerMarcos force-pushed the wagnermarcos/CLI_model_info_dump branch 2 times, most recently from 5eb97ed to bc9c373 Compare July 14, 2021 19:06
Copy link
Contributor

@francocipollone francocipollone left a comment

Choose a reason for hiding this comment

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

Thanks for adding the tutorial! I left a couple of comments.

model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
tutorials/model_command.md Outdated Show resolved Hide resolved
tutorials/model_command.md Outdated Show resolved Hide resolved
tutorials/model_command.md Outdated Show resolved Hide resolved
tutorials/model_command.md Outdated Show resolved Hide resolved
tutorials/model_command.md Outdated Show resolved Hide resolved
@francocipollone francocipollone force-pushed the wagnermarcos/CLI_model_info_dump branch from 13bc30a to 154b625 Compare July 15, 2021 12:58
@codecov
Copy link

codecov bot commented Jul 15, 2021

Codecov Report

Merging #893 (b907c86) into ign-gazebo3 (46425e0) will increase coverage by 0.22%.
The diff coverage is 90.17%.

Impacted file tree graph

@@               Coverage Diff               @@
##           ign-gazebo3     #893      +/-   ##
===============================================
+ Coverage        77.92%   78.14%   +0.22%     
===============================================
  Files              215      216       +1     
  Lines            12089    12262     +173     
===============================================
+ Hits              9420     9582     +162     
- Misses            2669     2680      +11     
Impacted Files Coverage Δ
src/cmd/ModelCommandAPI.cc 90.17% <90.17%> (ø)
src/ServerPrivate.cc 84.39% <0.00%> (+2.92%) ⬆️

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 46425e0...b907c86. Read the comment docs.

@francocipollone
Copy link
Contributor

CI is failing when running test because of :

Library error for [/usr/local/lib/libignition-gazebo3-model.so.3.8.0]: can't load /usr/local/lib/libignition-gazebo3-model.so.3.8.0

154b625 fixes this. IGN_CONFIG_PATH wasn't correctly set when running the tests.

Copy link
Contributor

@francocipollone francocipollone left a comment

Choose a reason for hiding this comment

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

Nice job! I left just some nits

tutorials/model_command.md Outdated Show resolved Hide resolved
tutorials/model_command.md Outdated Show resolved Hide resolved
tutorials.md.in Outdated Show resolved Hide resolved
@francocipollone
Copy link
Contributor

@chapulina Ready for the review!

Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

Works for me! I did a first pass. Let me know if any comments seem unreasonable 👍

model/src/CMakeLists.txt Outdated Show resolved Hide resolved
model/src/ModelCommandAPI_TEST.cc Outdated Show resolved Hide resolved
CMakeLists.txt Outdated
@@ -149,7 +149,9 @@ set(IGNITION_GAZEBO_GUI_PLUGIN_INSTALL_DIR
#============================================================================
# Configure the build
#============================================================================
ign_configure_build(QUIT_IF_BUILD_ERRORS)
ign_configure_build(QUIT_IF_BUILD_ERRORS
COMPONENTS model
Copy link
Contributor

Choose a reason for hiding this comment

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

it was separated into a new folder following the log structure

Usually following an existing pattern is a good idea, but I'm not sure that creating a separate component is necessary in this case.

On ign-transport the log feature was kept in a separate component because it brings a new dependency which we didn't want to add to the core of the library (SQLite). But in this case, the model command is not bringing any new dependencies and I think it's not sufficiently separate from the core to justify being its own component.

Would it be possible to move the new command into src/cmd? I think this should also simplify a lot of the current CMake code.

Copy link
Contributor Author

@WagnerMarcos WagnerMarcos Jul 20, 2021

Choose a reason for hiding this comment

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

I made a commit with only this change so you can have a look at it. I didn't merge cmdgazebo.rb.in and cmdmodel.rb.in files into one single file because the gazebo command implements many defaults value and sub-commands itself and mixing them would be difficult to follow. Because of this I had to also leave gazebo.yaml.in and ignmodel.yaml.in in different files so the command find different ruby files to process it.

Implementing both commands in the same file was my initial approach when I first started so its doable, but I thought it was really messy and I had to adapt some of the gazebo command implementation so it could coexist with the model one, so thats the reason I decided to look for a way to keep them in different files.

Let me know what you think about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

See #928 for a possible solution

model/src/ModelCommandAPI_TEST.cc Outdated Show resolved Hide resolved
model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
tutorials/model_command.md Outdated Show resolved Hide resolved
model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
model/src/cmd/ModelCommandAPI.cc Outdated Show resolved Hide resolved
WagnerMarcos and others added 5 commits July 19, 2021 16:06
@WagnerMarcos WagnerMarcos force-pushed the wagnermarcos/CLI_model_info_dump branch from 084ead9 to 2f8d28c Compare July 20, 2021 13:39
Signed-off-by: Marcos Wagner <[email protected]>
@WagnerMarcos WagnerMarcos force-pushed the wagnermarcos/CLI_model_info_dump branch from 2f8d28c to 66bb5cf Compare July 20, 2021 17:56
Signed-off-by: Marcos Wagner <[email protected]>
@WagnerMarcos WagnerMarcos force-pushed the wagnermarcos/CLI_model_info_dump branch from 55018ee to 25c21d0 Compare July 22, 2021 19:02
@WagnerMarcos WagnerMarcos requested a review from chapulina July 22, 2021 19:07
@chapulina
Copy link
Contributor

I have various suggestions on #928

Signed-off-by: Louise Poubel <[email protected]>
Signed-off-by: Franco Cipollone <[email protected]>

Co-authored-by: Franco Cipollone <[email protected]>
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

Let's get it in! Thanks for the new feature! 🎉

@chapulina chapulina merged commit 2cd5994 into ign-gazebo3 Jul 23, 2021
@chapulina chapulina deleted the wagnermarcos/CLI_model_info_dump branch July 23, 2021 23:28
@chapulina chapulina mentioned this pull request Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏰 citadel Ignition Citadel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants