GeneralContactSubsystem

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Andrea Braschi
Posts: 12
Joined: Thu Mar 11, 2021 2:42 am

GeneralContactSubsystem

Post by Andrea Braschi » Wed Jun 19, 2024 9:13 am

Hi all,

I have a Simbody question:

I am trying to write a custom HuntCrossleyForce class that can potentially output the location of the different points of contact between 2 ContactGeometry objects. I have seen in the Simbody implementation of the HuntCrossleyForce (https://github.com/simbody/simbody/blob ... yForce.cpp, line 103) that this is possible via the GeneralContactSubsystem object which has the getContacts method that, according to the corresponding header file, gives you "a list of all contacts between bodies in a contact set.". Am I wrong? However, I am struggling to use such method. I get an error at runtime. I was wondering if someone is familiar with the overall class itself or has had any experience with getting the list of contact at a given state?

Currently, this is the implementation that I am doing based on the instructions that are found in the source code and header file:

Code: Select all

const State& s = model.initSystem();

// Create a GeneralContactSubsystem
model.realizeDynamics(s);
SimTK::MultibodySystem& system = model.updMultibodySystem();
std::cout << "\n" + s.getSystemStage().getName();
GeneralContactSubsystem contact = GeneralContactSubsystem(system);


// Add body1
ContactSetIndex setIndex = contact.createContactSet();
contact.addBody(setIndex, mobilizedBody, simTK_sphere, sphere1_transform);


// Add body2
//ContactSetIndex secondIndex = contact.createContactSet();
contact.addBody(setIndex, _mobilizedBody, _simTK_sphere, sphere2_transform);


// Get Contacts
if (!contact.isInSystem())
	std::cout << "\nContact isn't in system";
const Array_<Contact>& contacts = contact.getContacts(s, setIndex);
I believe I have created the GeneralContactSubsystem class correctly as I am able to use all the other methods of it. Anyone can spot some clear mistake in the use of the getContacts method?

Many thanks in advance for the help.

Andrea

Tags:

POST REPLY