How to access contact Information form via the EntityComponentManager?
I want to create a plugin that publishes the contact forces a specific link experiences along a particular local axis to a specific topic in order to simulate something similar to a pressure sensor. My idea was to collect all current collisions the particular link is in, sum up all the forces and project it onto the particular local axis. However, I already struggle to get the desired contact information. I started by creating a plugin that inherits from the following three interfaces:
public ISystemConfigure
public ISystemPreUpdate
public ISystemPostUpdate
Where I then go on to load all the required sdf parameters in the Configure
function and check for time leaps in the PreUpdate
. I'm also able to create and publish dummy force messages in the PostUpdate
function, however, I can't seem to figure out how to access the true contact forces the link is experiencing. The function is defined as:
void PostUpdate(const UpdateInfo &_info, const EntityComponentManager &_ecm)
I.e., I somehow have access to the contact information via the ecm
. Ideally, there'd be something like
std::vector<Contact> gz::physics::GetLinkContactsById(ecm.GetIDByName(link_name))
So what would be the best practice to get the contact information within the PostUpdate
step? Are there any examples that are doing this already?
Thanks