leggedrobotics / raisimLib

RAISIM, A PHYSICS ENGINE FOR ROBOTICS AND AI RESEARCH
http://www.raisim.com
327 stars 50 forks source link

about the getContactPointVel method in ArticulatedSystem #56

Closed WSPeng closed 4 years ago

WSPeng commented 4 years ago

Hi,

I am trying to use the getContactPointVel method, with the pointID and raisim::Vec<3> vel as arguments. but I get segfault. Do you have any suggestion to fix the problem?

for example, then code is: raisim::Vec<3> footVel_hl; footVel_hl.setZero(); for(auto& contact: robot -> getContacts()) { if ( footIndex_hl == contact.getlocalBodyIndex() ) { robot->getContactPointVel(footIndex_hl, footVel_hl); } }

jhwangbo commented 4 years ago

getContactPointVel takes the contactId as the first argument. There can be many contacts on body "foddIndex_hl" so your syntax cannot be used. So you should do

raisim::Vec<3> footVel_hl;
footVel_hl.setZero();
for(size_t i=0; i<robot->getContacts().size(); i++) {
  if ( footIndex_hl == robot->getContacts()[i].getlocalBodyIndex() ) {
    robot->getContactPointVel(i, footVel_hl);
  }
}

Not tested but should work. Let me know if it doesn't

WSPeng commented 4 years ago

Yes, it works! Thank you ;D