Skip to content

Linear Velocity Plugin Tutorial #2911

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

Open
wants to merge 29 commits into
base: gz-sim9
Choose a base branch
from
Open

Conversation

Pk-Sic
Copy link

@Pk-Sic Pk-Sic commented May 18, 2025

Summary

This folder contains a simple example on how to create a plugin which set a linear velocity on a link entity.

In the example, the world contains a ground plane and a box that is freely moving. Through the custom plugin, a linear velocity vector will be applied to the box to make it move along a linear path.

The code presented is commented to provide a clear overview of what each part aims to achieve.

This folder contains a simple example on how to create a plugin which set a linear velocity on a link entity. The CMakeLists.txt file is set for the gz-sim8.

Signed-off-by: Pasquale Siciliano <[email protected]>
@Pk-Sic Pk-Sic requested a review from mjcarroll as a code owner May 18, 2025 19:13
@github-actions github-actions bot added the 🏛️ ionic Gazebo Ionic label May 18, 2025
Copy link
Contributor

@arjo129 arjo129 left a comment

Choose a reason for hiding this comment

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

We already have an example System. Of course, its always nice to have a bit more docs and I can see the code has been thoroughly commented. I wonder if we can point users here from the tutorials. Also can you change your PR title to something more descriptive.

I want to check if an LLM was used for this. (If it was that's OK we just need to know which LLM).

@Pk-Sic
Copy link
Author

Pk-Sic commented May 20, 2025

Of course, It would be great to create a section where a lot of little tutorials are loaded. I will review your comments for the code and I will implement them.
Thank you.

@Pk-Sic Pk-Sic changed the title Add files via upload Linear Velocity Plguin Tutorial May 20, 2025
@Pk-Sic Pk-Sic changed the title Linear Velocity Plguin Tutorial Linear Velocity Plugin Tutorial May 20, 2025
// On the other hand the Configure callback is called only once.

public: void Configure(const Entity &_entity,
const std::shared_ptr<const sdf::Element> &_sdf,
Copy link
Contributor

Choose a reason for hiding this comment

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

include <memory>

@github-project-automation github-project-automation bot moved this from Inbox to In review in Core development May 20, 2025
Pk-Sic and others added 4 commits May 21, 2025 18:49
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
@Pk-Sic Pk-Sic requested a review from ahcorde May 21, 2025 16:51
Pk-Sic and others added 8 commits May 21, 2025 18:52
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Comments accepted

Signed-off-by: Pasquale Siciliano <[email protected]>
Identation added.

Signed-off-by: Pasquale Siciliano <[email protected]>
namespace changed

Signed-off-by: Pasquale Siciliano <[email protected]>
- License Header added
- Namespace correction
- minor correction performed

Signed-off-by: Pasquale Siciliano <[email protected]>
New space added at the end of the file.

Signed-off-by: Pasquale Siciliano <[email protected]>
Copy link
Author

@Pk-Sic Pk-Sic left a comment

Choose a reason for hiding this comment

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

Comments reviewed and applied.

Comment on lines 85 to 87
// Look for link entity using "LinkByName" into "model" defined above

this->linkEntity = model.LinkByName(_ecm, linkName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Look for link entity using "LinkByName" into "model" defined above
this->linkEntity = model.LinkByName(_ecm, linkName);
// Look for link entity using "LinkByName" into "model" defined above
this->linkEntity = model.LinkByName(_ecm, linkName);

Comment on lines 11 to 13
using namespace gz;
using namespace sim;
using namespace systems;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this and use the right namespace where required

@@ -0,0 +1,76 @@
<?xml version="1.0" ?>
Copy link
Contributor

Choose a reason for hiding this comment

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

can you use 2 spaces instead of 4 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

still pending

Copy link
Author

Choose a reason for hiding this comment

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

done. Now it should be ok.

Copy link
Author

Choose a reason for hiding this comment

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

Let me know if the modification was applied.

Pk-Sic and others added 3 commits May 25, 2025 20:34
ok

Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
ok

Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
ok

Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Pk-Sic added 3 commits May 25, 2025 21:06
Reviewed

Signed-off-by: Pasquale Siciliano <[email protected]>
reviewed.

Signed-off-by: Pasquale Siciliano <[email protected]>
Reviewed.

Signed-off-by: Pasquale Siciliano <[email protected]>
Copy link
Author

@Pk-Sic Pk-Sic left a comment

Choose a reason for hiding this comment

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

Code updated

@Pk-Sic Pk-Sic requested a review from ahcorde May 25, 2025 19:14
@@ -0,0 +1,76 @@
<?xml version="1.0" ?>
Copy link
Contributor

Choose a reason for hiding this comment

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

still pending

Pk-Sic added 3 commits May 28, 2025 22:14
License Header + <memory> included

Signed-off-by: Pasquale Siciliano <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
2 spaces format.

Signed-off-by: Pasquale Siciliano <[email protected]>
Copy link
Author

@Pk-Sic Pk-Sic left a comment

Choose a reason for hiding this comment

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

Header changed and minor corrections applied.

@@ -0,0 +1,54 @@
#ifndef SYSTEM_PLUGIN_HELLOWORLD_HH_
Copy link
Author

Choose a reason for hiding this comment

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

There is the 2025 license header. Is this wrong? I used the http://www.apache.org/licenses/LICENSE-2.0

@@ -0,0 +1,76 @@
<?xml version="1.0" ?>
Copy link
Author

Choose a reason for hiding this comment

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

done. Now it should be ok.

@@ -0,0 +1,76 @@
<?xml version="1.0" ?>
Copy link
Author

Choose a reason for hiding this comment

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

Let me know if the modification was applied.

Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

@iche033 do you mind to take a look ?

Copy link
Contributor

@iche033 iche033 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 linear vel plugin example and tutorial. The example works for me. I left comments mostly related to coding style to that they are consistent with the rest of this library.

I noticed that the gz deps listed in CMakeLists is for Harmonic / gz-sim8. Since this is targeted at gz-sim9, I made suggestions to update those dependency versions.


this -> lName = linkName; // Do not forget to declare the lName variable in the plugin's header file (see line 61 in the PluginLinearVelocity.hh file))

// Store the _identity value using the "this ->".
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
// Store the _identity value using the "this ->".
// Store the _identity value in "this->entity" member variable

Comment on lines +77 to +78
// Create the model object to access all the function using as attibute the "entity" variable.
// The function "Model()" enables to get some important details
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can simplify this to:

Suggested change
// Create the model object to access all the function using as attibute the "entity" variable.
// The function "Model()" enables to get some important details
// Create a Model object from the "entity" to access all model-related functions

#include <gz/sim/Util.hh>

// This header is required to register plugins.
// The good practice suggests to recall it in the ".cc" file
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment referring to the <gz/plugin/Register.hh> header?

#include <gz/sim/components/Pose.hh>
#include <gz/math/Vector3.hh>

// The next row recalls the plugin's header.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// The next row recalls the plugin's header.
// The next row includes the plugin's header.


using namespace plugin_velocity;

// In the next section, all the functions that we need are recalled.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// In the next section, all the functions that we need are recalled.
// In the next section, all the functions that we need are defined.

Pk-Sic and others added 6 commits May 31, 2025 10:10
Co-authored-by: Ian Chen <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Co-authored-by: Ian Chen <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Co-authored-by: Ian Chen <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Co-authored-by: Ian Chen <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Co-authored-by: Ian Chen <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Co-authored-by: Ian Chen <[email protected]>
Signed-off-by: Pasquale Siciliano <[email protected]>
Copy link
Author

@Pk-Sic Pk-Sic left a comment

Choose a reason for hiding this comment

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

CMakelists file adapted to gz-sim9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

4 participants