<commit_before>/**
* @author <a href="mailto:<EMAIL>"><NAME></a>
*/
#include "FallMotion.h"

using namespace naoth;

FallMotion::FallMotion()
  :
  AbstractMotion(motion::falling, getMotionLock())
{
  stiffness_increase = getRobotInfo().getBasicTimeStepInSecond() * 5;

  for (int i = 0; i < JointData::numOfJoint; i++)
  {
    // retain some stiffness in the head joints in order to turn the head a little during falling.
    if (JointData::getJointID(i) == JointData::HeadPitch || JointData::getJointID(i) == JointData::HeadYaw){
      freeStiffness[i] = 0.3;
      getMotorJointData().position[i] = 0.0;
    }
    else{
      freeStiffness[i] = -1.0;
    }
 
  }
}

void FallMotion::execute()
{
  if(getMotionRequest().id != getId())
  {
    // restore hardness
    if ( setStiffness(getMotorJointData(), getSensorJointData(), oldStiffness, stiffness_increase) )
    {
      setCurrentState(motion::stopped);
    }
    for (int i = 0; i < JointData::numOfJoint; i++)
    {
      getMotorJointData().position[i] = getSensorJointData().position[i];
    }

    return;
  }else if( isStopped() ) // executed the first time
  {
    // store hardness
    for (int i = 0; i < JointData::numOfJoint; i++)
    {
      oldStiffness[i] = getSensorJointData().stiffness[i];
    }//end for
  }

  // set joint free
  setStiffness(getMotorJointData(), getSensorJointData(), freeStiffness, 10);

  setCurrentState(motion::running);
}//end execute<commit_msg>added some comments to FallMotion<commit_after>/**
* @author <a href="mailto:<EMAIL>"><NAME></a>
*/
#include "FallMotion.h"

using namespace naoth;

FallMotion::FallMotion()
  :
  AbstractMotion(motion::falling, getMotionLock())
{
  stiffness_increase = getRobotInfo().getBasicTimeStepInSecond() * 5;

  for (int i = 0; i < JointData::numOfJoint; i++)
  {
    // retain some stiffness in the head joints in order to turn the head a little during falling.
    if (JointData::getJointID(i) == JointData::HeadPitch || JointData::getJointID(i) == JointData::HeadYaw){
      freeStiffness[i] = 0.3;
      getMotorJointData().position[i] = 0.0;
    }
    else{
      freeStiffness[i] = -1.0;
    }
 
  }
}

void FallMotion::execute()
{
  if(getMotionRequest().id != getId())
  {
    // gradually restore hardness
    if ( setStiffness(getMotorJointData(), getSensorJointData(), oldStiffness, stiffness_increase) )
    {
      setCurrentState(motion::stopped);
    }

    // copy sensor positions
    for (int i = 0; i < JointData::numOfJoint; i++)
    {
      getMotorJointData().position[i] = getSensorJointData().position[i];
    }

    return;
  }
  else if( isStopped() ) // executed the first time
  {
    // store hardness
    for (int i = 0; i < JointData::numOfJoint; i++)
    {
      oldStiffness[i] = getSensorJointData().stiffness[i];
    }
  }

  // set joint free
  setStiffness(getMotorJointData(), getSensorJointData(), freeStiffness, 10);

  setCurrentState(motion::running);
}//end execute
{'fraction_non_alphanumeric': 0.15071283095723015, 'fraction_numerical': 0.008146639511201629, 'mean_word_length': 3.554868624420402, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3748790', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1009, 'n_words': 211}