Skip to content

Commit

Permalink
do no kill robot if it hit a limit, jut penalize the reward.
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioJerez committed Sep 28, 2024
1 parent 2ae5f62 commit fe75d2b
Showing 1 changed file with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,12 @@ namespace ndAdvancedRobot
//#pragma optimize( "", off )
void SaveTrajectory()
{
if (IsTerminal())
ndInt32 index = m_trajectory.GetCount() - 1;
if (m_trajectory.GetReward(index) == ND_DEAD_PENALTY)
{
ndInt32 index = m_trajectory.GetCount() - 1;
if (m_trajectory.GetReward(index) != ND_DEAD_PENALTY)
{
m_trajectory.SetReward(index, ND_DEAD_PENALTY);
}
m_trajectory.SetReward(index, ND_DEAD_PENALTY * 4.0f);
}

ndBrainAgentContinuePolicyGradient_Trainer::SaveTrajectory();
}

Expand Down Expand Up @@ -445,26 +443,6 @@ namespace ndAdvancedRobot
return true;
}

if (m_leftGripper->GetJointHitLimits())
{
return true;
}

if (m_rightGripper->GetJointHitLimits())
{
return true;
}

if (m_arm_0->GetJointHitLimits())
{
return true;
}

if (m_arm_1->GetJointHitLimits())
{
return true;
}

const ndModelArticulation* const model = GetModel()->GetAsModelArticulation();
for (ndModelArticulation::ndNode* node = model->GetRoot()->GetFirstIterator(); node; node = node->GetNextIterator())
{
Expand Down Expand Up @@ -520,6 +498,26 @@ namespace ndAdvancedRobot
return ND_DEAD_PENALTY;
}

if (m_leftGripper->GetJointHitLimits())
{
return ND_DEAD_PENALTY;
}

if (m_rightGripper->GetJointHitLimits())
{
return ND_DEAD_PENALTY;
}

if (m_arm_0->GetJointHitLimits())
{
return ND_DEAD_PENALTY;
}

if (m_arm_1->GetJointHitLimits())
{
return ND_DEAD_PENALTY;
}

const ndMatrix effectorMatrix(m_effectorLocalTarget * m_arm_4->GetBody0()->GetMatrix());
const ndMatrix baseMatrix(m_effectorLocalBase * m_base_rotator->GetBody1()->GetMatrix());
const ndMatrix currentEffectorMatrix(effectorMatrix * baseMatrix.OrthoInverse());
Expand Down

0 comments on commit fe75d2b

Please sign in to comment.