-
Notifications
You must be signed in to change notification settings - Fork 313
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
base: gz-sim9
Are you sure you want to change the base?
Conversation
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]>
There was a problem hiding this 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).
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. |
// 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include <memory>
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]>
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]>
There was a problem hiding this 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.
// Look for link entity using "LinkByName" into "model" defined above | ||
|
||
this->linkEntity = model.LinkByName(_ecm, linkName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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); |
using namespace gz; | ||
using namespace sim; | ||
using namespace systems; |
There was a problem hiding this comment.
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" ?> |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still pending
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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]>
Reviewed Signed-off-by: Pasquale Siciliano <[email protected]>
reviewed. Signed-off-by: Pasquale Siciliano <[email protected]>
Reviewed. Signed-off-by: Pasquale Siciliano <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code updated
@@ -0,0 +1,76 @@ | |||
<?xml version="1.0" ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still pending
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]>
There was a problem hiding this 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_ |
There was a problem hiding this comment.
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" ?> |
There was a problem hiding this comment.
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" ?> |
There was a problem hiding this comment.
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.
There was a problem hiding this 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 ?
There was a problem hiding this 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 ->". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
// Store the _identity value using the "this ->". | |
// Store the _identity value in "this->entity" member variable |
// Create the model object to access all the function using as attibute the "entity" variable. | ||
// The function "Model()" enables to get some important details |
There was a problem hiding this comment.
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:
// 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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// In the next section, all the functions that we need are recalled. | |
// In the next section, all the functions that we need are defined. |
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]>
There was a problem hiding this 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.
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.