-
Notifications
You must be signed in to change notification settings - Fork 277
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
Add ECM tutorial #628
Comments
Thanks, it's helpful to know what questions developers need answered while working with the code. I'll add a link to #83, which also has several good questions. |
I'm adding a few other things to document/outline regarding ECM (and more generally, entity/component) usage for current/stable releases, which at this point covers Citadel through Edifice:
|
@peci1 @adlarkin
I assume in the mean time you might have a better understanding of above mentioned concepts? Or, given writing a tutorial is a non-trivial amount of work: would you have any info that you can share (even if it's some old notes or even just a scan of handwritten notes or whatever) that can help to better understand the core concepts? I think this is very much true:
For anyone interested in the answer to the I didn't fully dig into it, but I think the initialization is done here, in the physics plugin. So that implies that you can't use |
I think the concept that is not documented is that the Physics system updates/populates some components by default but some other components are not updated unless the user (plugin author) has created that component on an entity. This is mainly done for performance reasons so that the Physics system can avoid costly component updates if no one is using them. In your gz-sim/src/systems/physics/Physics.cc Line 3613 in 42c285e
JointPosition component. If so, the Physics system will resize the underlying data structure to the right size based on the degrees of freedom of the joint. It then updates the values based on the results from the physics engine.
So systems like the gz-sim/src/systems/joint_state_publisher/JointStatePublisher.cc Lines 118 to 130 in 42c285e
With all that being said, there are also convenience classes that do this for you, e.g. The Joint class has a EnablePositionCheck member function that creates the necessary components. The goal is for these convenience classes to be the main interface for plugin authors and interacting with the ECM directly would be an advanced use case. I agree all of this needs to be documented well, but I hope that was helpful. |
@azeey Suddenly these common comments make sense! :-)
Well... there are several more concepts that are very difficult to learn from scratch. E.g.:
|
Has any tutorial or more detailed ECM documentation appeared in the meantime ? |
Any system can add and remove entities and components at any time, so there is in general no distinct point where the ECM is "complete". A common pattern is to set a bool See e.g. here for an example. |
#2207 has a little more detail as to which entities are available when
|
fyi @xela-95, this is similar to what we discussed last week. |
Desired behavior
Have a tutorial explaining how to work with Entities and Components to newcomers.
Alternatives considered
Have people doing random things that sometimes work :-D I've looked in the tutorials folder, but there's nothing resembling an ECM tutorial (except the terminology tutorial which contains one-sentence explanations of the terms).
Implementation suggestion
I can't help creating the tutorial. I can only comment whether the new tutorial helped me understand the concepts better.
Additional context
As a newbie to the ECM system used here, it is extremely difficult for me to get a concept on how to work with all the ECM "magic". There's a lot of stuff happening automatically which I don't understand. I think if you want external collaborators to improve Gazebo, such a tutorial is really needed a lot.
For example, I don't understand why the following code doesn't crash:
So, I initialize the component with a default-constructed
components::JointPosition
component, which should be backed by a vector of doubles. I expect that a default-constructed vector is empty, so I'd also expect the component to contain the empty list. But why does accessing the first element of the component data work right after theif
? Is it because the component always exists before this plugin is created, so theif
never executes, or is it because of some auto-magic of the ECM that would automatically connect the created component to what already exists in the simulation and figure out "hey, this is a revolute joint, so it's position component should always be a 1-vector"?Further questions I came up with and are difficult for me to answer:
I think questions like this are very important to be clearly answered so that people can write safe and working code. The earlier such a tutorial is created, the more community contributions you can expect :)
The text was updated successfully, but these errors were encountered: