Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.
jhwangbo edited this page Sep 29, 2019 · 11 revisions

RaiSim Wiki

Q & A

1. How to get contact force?

RaiSim uses a velocity-based simulation scheme and there it only provides contact impulses. Users should divide it by the time step in order to get the average force applied over the time step. In addition, the impulse is defined in the contact frame.

Here is an example (using ANYmal model)

    /// Let's check all contact impulses acting on "LF_SHANK"
    auto footIndex = anymal_->getBodyIdx("LF_SHANK");

    /// for all contacts on the robot, check ...
    for(auto& contact: anymal_->getContacts()) {
      if ( footIndex == contact.getlocalBodyIndex() ) {
        std::cout<<"Contact impulse in the contact frame: "<<contact.getImpulse()->e()<<std::endl;
        std::cout<<"Contact frame: \n"<<contact.getContactFrame()->e()<<std::endl;
        std::cout<<"Contact impulse in the world frame: "<<contact.getContactFrame()->e() * contact.getImpulse()->e()<<std::endl;
        std::cout<<"Contact Normal in the world frame: "<<contact.getNormal().e().transpose()<<std::endl;
        std::cout<<"Contact position in the world frame: "<<contact.getPosition().e().transpose()<<std::endl;
        /// this method available as of sept 29th 2019
        std::cout<<"It collides with: "<<world.getObject(contact.getPairObjectIndex().getName())<<std::endl;
        std::cout<<"please check Contact.hpp for the full list of the methods"<<std::endl; 
      }
    }
Clone this wiki locally