How can I get the collision and contact force?

Discussion in 'Simulation' started by Xinyang Wu, Nov 9, 2018.

  1. Hi guys, I am trying to implement a robot, which could fetch stuff while avoiding hurting or colliding the surrounding humans. And there is already a good implementation from OpenAI, they trained a DDPG+HER agent based on their FetchReach environment: https://github.com/openai/baselines/tree/master/baselines/her.

    Starting from this implementation, I added some geom element into the XML and now when I run the play.py script I can get something like the following images.

    I am quite new to mujoco and mujoco-py. It seems that this play.py script can somehow output and plot the contact forces now. But in fact, I do not know how it implements it. Can anyone give me some hints, that how I can extract this collision information and contact forces? And then I can implement some criteria for the hurting and colliding scenario and then set the environment reward as -1 when one collision is detected.
     

    Attached Files:

  2. The train script and play script are all in the experiment directory of that HER repository.