Skip to content

Commit

Permalink
bunch of compiler erro making an unreal plugin (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioJerez committed Sep 8, 2024
1 parent d0854b5 commit 7b1e6cc
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 50 deletions.
Binary file added newton-4.00/applications/media/newtonIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -526,28 +526,25 @@ namespace ndAdvancedRobot
ndFloat32 dy = m_targetLocation.m_y - currenPosit.m_y;
ndFloat32 dAzimuth = ndAnglesSub(m_targetLocation.m_azimuth, azimuth);

ndFloat32 azimuth2 = dAzimuth * dAzimuth;
ndFloat32 positError2 = dx * dx + dy * dy;
//ndFloat32 azimuth2 = dAzimuth * dAzimuth;
//ndFloat32 positError2 = dx * dx + dy * dy;

#ifdef ND_USE_EULERS
ndVector euler1;
ndVector euler(effectorMatrix.CalcPitchYawRoll(euler1));
ndFloat32 deltaYaw = ndAnglesSub(euler.m_y, m_targetLocation.m_yaw);
ndFloat32 deltaRoll = ndAnglesSub(euler.m_z, m_targetLocation.m_roll);
ndFloat32 deltaPitch = ndAnglesSub(euler.m_x, m_targetLocation.m_pitch);
//ndFloat32 angleError2 = deltaYaw * deltaYaw + deltaRoll * deltaRoll + deltaPitch * deltaPitch;

ndFloat32 positReward = ndExp(-100.0f * positError2);
ndFloat32 azimuthReward = ndExp(-100.0f * azimuth2);
ndFloat32 posit_xReward = ndExp(-100.0f * dx * dx);
ndFloat32 posit_yReward = ndExp(-100.0f * dy * dy);
ndFloat32 azimuthReward = ndExp(-100.0f * dAzimuth * dAzimuth);
ndFloat32 yawReward = ndExp(-100.0f * deltaYaw * deltaYaw);
ndFloat32 rollReward = ndExp(-100.0f * deltaRoll * deltaRoll);
ndFloat32 pitchReward = ndExp(-100.0f * deltaPitch * deltaPitch);

ndFloat32 rotatWeight = 0.7f;
ndFloat32 positWeight = 0.3f;

return positWeight * (positReward * 0.4f + azimuthReward * 0.6f) +
rotatWeight * (yawReward * 0.34f + rollReward * 0.33f + pitchReward * 0.33f);
ndFloat32 rewardWeight = 1.0 / 6.0f;
return rewardWeight * (posit_xReward + posit_yReward + azimuthReward + yawReward + rollReward + pitchReward);

#else
ndQuaternion effectorRotation(effectorMatrix);
Expand Down Expand Up @@ -1054,8 +1051,8 @@ namespace ndAdvancedRobot
,m_maxScore(ndFloat32(-1.0e10f))
,m_discountFactor(0.99f)
,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor))
,m_lastEpisode(-1)
,m_stopTraining(2000 * 1000000)
,m_lastEpisode(0xffffffff)
,m_stopTraining(ndUnsigned32(4000) * ndUnsigned32(1000000))
,m_modelIsTrained(false)
{
m_outFile = fopen("robotArmReach-vpg.csv", "wb");
Expand Down Expand Up @@ -1189,10 +1186,10 @@ namespace ndAdvancedRobot

virtual void Update(ndDemoEntityManager* const manager, ndFloat32)
{
ndInt32 stopTraining = m_master->GetFramesCount();
ndUnsigned32 stopTraining = m_master->GetFramesCount();
if (stopTraining <= m_stopTraining)
{
ndInt32 episodeCount = m_master->GetEposideCount();
ndUnsigned32 episodeCount = m_master->GetEposideCount();
m_master->OptimizeStep();

episodeCount -= m_master->GetEposideCount();
Expand Down Expand Up @@ -1242,8 +1239,8 @@ namespace ndAdvancedRobot
ndFloat32 m_maxScore;
ndFloat32 m_discountFactor;
ndFloat32 m_horizon;
ndInt32 m_lastEpisode;
ndInt32 m_stopTraining;
ndUnsigned32 m_lastEpisode;
ndUnsigned32 m_stopTraining;
bool m_modelIsTrained;
};
}
Expand Down
10 changes: 5 additions & 5 deletions newton-4.00/applications/ndSandbox/demos/ndCartpoleContinue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ namespace ndCarpole_1
,m_maxScore(ndFloat32(-1.0e10f))
,m_discountFactor(0.99f)
,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor))
,m_lastEpisode(-1)
,m_lastEpisode(0xfffffff)
,m_stopTraining(100 * 1000000)
,m_modelIsTrained(false)
{
Expand Down Expand Up @@ -448,10 +448,10 @@ namespace ndCarpole_1

virtual void Update(ndDemoEntityManager* const manager, ndFloat32)
{
ndInt32 stopTraining = m_master->GetFramesCount();
ndUnsigned32 stopTraining = m_master->GetFramesCount();
if (stopTraining <= m_stopTraining)
{
ndInt32 episodeCount = m_master->GetEposideCount();
ndUnsigned32 episodeCount = m_master->GetEposideCount();
m_master->OptimizeStep();

episodeCount -= m_master->GetEposideCount();
Expand Down Expand Up @@ -503,8 +503,8 @@ namespace ndCarpole_1
ndFloat32 m_maxScore;
ndFloat32 m_discountFactor;
ndFloat32 m_horizon;
ndInt32 m_lastEpisode;
ndInt32 m_stopTraining;
ndUnsigned32 m_lastEpisode;
ndUnsigned32 m_stopTraining;
bool m_modelIsTrained;
};
}
Expand Down
10 changes: 5 additions & 5 deletions newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ namespace ndQuadruped_1
,m_maxScore(ndFloat32(-1.0e10f))
,m_discountFactor(0.995f)
,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor))
,m_lastEpisode(-1)
,m_lastEpisode(0xffffffff)
,m_stopTraining(500 * 1000000)
,m_modelIsTrained(false)
{
Expand Down Expand Up @@ -1399,10 +1399,10 @@ namespace ndQuadruped_1

virtual void Update(ndDemoEntityManager* const manager, ndFloat32)
{
ndInt32 stopTraining = m_master->GetFramesCount();
ndUnsigned32 stopTraining = m_master->GetFramesCount();
if (stopTraining <= m_stopTraining)
{
ndInt32 episodeCount = m_master->GetEposideCount();
ndUnsigned32 episodeCount = m_master->GetEposideCount();
m_master->OptimizeStep();

episodeCount -= m_master->GetEposideCount();
Expand Down Expand Up @@ -1452,8 +1452,8 @@ namespace ndQuadruped_1
ndFloat32 m_maxScore;
ndFloat32 m_discountFactor;
ndFloat32 m_horizon;
ndInt32 m_lastEpisode;
ndInt32 m_stopTraining;
ndUnsigned32 m_lastEpisode;
ndUnsigned32 m_stopTraining;
bool m_modelIsTrained;
};
}
Expand Down
10 changes: 5 additions & 5 deletions newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ namespace ndQuadruped_2
,m_maxScore(ndFloat32(-1.0e10f))
,m_discountFactor(0.995f)
,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor))
,m_lastEpisode(-1)
,m_lastEpisode(0xffffffff)
,m_stopTraining(300 * 1000000)
,m_modelIsTrained(false)
{
Expand Down Expand Up @@ -1541,10 +1541,10 @@ namespace ndQuadruped_2

virtual void Update(ndDemoEntityManager* const manager, ndFloat32)
{
ndInt32 stopTraining = m_master->GetFramesCount();
ndUnsigned32 stopTraining = m_master->GetFramesCount();
if (stopTraining <= m_stopTraining)
{
ndInt32 episodeCount = m_master->GetEposideCount();
ndUnsigned32 episodeCount = m_master->GetEposideCount();
m_master->OptimizeStep();

episodeCount -= m_master->GetEposideCount();
Expand Down Expand Up @@ -1594,8 +1594,8 @@ namespace ndQuadruped_2
ndFloat32 m_maxScore;
ndFloat32 m_discountFactor;
ndFloat32 m_horizon;
ndInt32 m_lastEpisode;
ndInt32 m_stopTraining;
ndUnsigned32 m_lastEpisode;
ndUnsigned32 m_stopTraining;
bool m_modelIsTrained;
};
}
Expand Down
10 changes: 5 additions & 5 deletions newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ namespace ndQuadruped_3
,m_maxScore(ndFloat32(-1.0e10f))
,m_discountFactor(0.99f)
,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor))
,m_lastEpisode(-1)
,m_lastEpisode(0xffffffff)
,m_stopTraining(500 * 1000000)
,m_modelIsTrained(false)
{
Expand Down Expand Up @@ -1485,10 +1485,10 @@ namespace ndQuadruped_3

virtual void Update(ndDemoEntityManager* const manager, ndFloat32)
{
ndInt32 stopTraining = m_master->GetFramesCount();
ndUnsigned32 stopTraining = m_master->GetFramesCount();
if (stopTraining <= m_stopTraining)
{
ndInt32 episodeCount = m_master->GetEposideCount();
ndUnsigned32 episodeCount = m_master->GetEposideCount();
m_master->OptimizeStep();

episodeCount -= m_master->GetEposideCount();
Expand Down Expand Up @@ -1539,8 +1539,8 @@ namespace ndQuadruped_3
ndFloat32 m_maxScore;
ndFloat32 m_discountFactor;
ndFloat32 m_horizon;
ndInt32 m_lastEpisode;
ndInt32 m_stopTraining;
ndUnsigned32 m_lastEpisode;
ndUnsigned32 m_stopTraining;
bool m_modelIsTrained;
};
#else
Expand Down
10 changes: 5 additions & 5 deletions newton-4.00/applications/ndSandbox/demos/ndUnicycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ namespace ndUnicycle
,m_maxScore(ndFloat32(-1.0e10f))
,m_discountFactor(0.99f)
,m_horizon(ndFloat32(1.0f) / (ndFloat32(1.0f) - m_discountFactor))
,m_lastEpisode(-1)
,m_lastEpisode(0xffffffff)
,m_stopTraining(200 * 1000000)
,m_modelIsTrained(false)
{
Expand Down Expand Up @@ -637,10 +637,10 @@ namespace ndUnicycle

virtual void Update(ndDemoEntityManager* const manager, ndFloat32)
{
ndInt32 stopTraining = m_master->GetFramesCount();
ndUnsigned32 stopTraining = m_master->GetFramesCount();
if (stopTraining <= m_stopTraining)
{
ndInt32 episodeCount = m_master->GetEposideCount();
ndUnsigned32 episodeCount = m_master->GetEposideCount();
m_master->OptimizeStep();

episodeCount -= m_master->GetEposideCount();
Expand Down Expand Up @@ -690,8 +690,8 @@ namespace ndUnicycle
ndFloat32 m_maxScore;
ndFloat32 m_discountFactor;
ndFloat32 m_horizon;
ndInt32 m_lastEpisode;
ndInt32 m_stopTraining;
ndUnsigned32 m_lastEpisode;
ndUnsigned32 m_stopTraining;
bool m_modelIsTrained;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ ndBrainAgentContinuePolicyGradient_TrainerMaster::ndBrainAgentContinuePolicyGrad
,m_criticLearnRate(hyperParameters.m_criticLearnRate)
,m_numberOfActions(hyperParameters.m_numberOfActions)
,m_numberOfObservations(hyperParameters.m_numberOfObservations)
,m_frameCount(0)
,m_framesAlive(0)
,m_frameCount(0)
,m_eposideCount(0)
,m_bashBufferSize(hyperParameters.m_bashBufferSize)
,m_maxTrajectorySteps(hyperParameters.m_maxTrajectorySteps)
Expand Down Expand Up @@ -499,7 +499,7 @@ ndBrainAgentContinuePolicyGradient_Trainer::ndRandomGenerator* ndBrainAgentConti
return &m_randomGenerator[m_randomSeed];
}

ndInt32 ndBrainAgentContinuePolicyGradient_TrainerMaster::GetFramesCount() const
ndUnsigned32 ndBrainAgentContinuePolicyGradient_TrainerMaster::GetFramesCount() const
{
return m_frameCount;
}
Expand All @@ -509,7 +509,7 @@ bool ndBrainAgentContinuePolicyGradient_TrainerMaster::IsSampling() const
return false;
}

ndInt32 ndBrainAgentContinuePolicyGradient_TrainerMaster::GetEposideCount() const
ndUnsigned32 ndBrainAgentContinuePolicyGradient_TrainerMaster::GetEposideCount() const
{
return m_eposideCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class ndBrainAgentContinuePolicyGradient_TrainerMaster : public ndBrainThreadPoo
const ndString& GetName() const;
void SetName(const ndString& name);

ndInt32 GetFramesCount() const;
ndInt32 GetEposideCount() const;
ndUnsigned32 GetFramesCount() const;
ndUnsigned32 GetEposideCount() const;

bool IsSampling() const;
ndFloat32 GetAverageScore() const;
Expand Down Expand Up @@ -181,9 +181,9 @@ class ndBrainAgentContinuePolicyGradient_TrainerMaster : public ndBrainThreadPoo
ndBrainFloat m_criticLearnRate;
ndInt32 m_numberOfActions;
ndInt32 m_numberOfObservations;
ndInt32 m_frameCount;
ndInt32 m_framesAlive;
ndInt32 m_eposideCount;
ndUnsigned32 m_frameCount;
ndUnsigned32 m_eposideCount;
ndInt32 m_bashBufferSize;
ndInt32 m_maxTrajectorySteps;
ndInt32 m_extraTrajectorySteps;
Expand Down
2 changes: 1 addition & 1 deletion newton-4.00/sdk/dCollision/ndMeshEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class ndMeshEffect: public ndPolyhedra
,m_opacity(ndFloat32(1.0f))
,m_shiness(ndFloat32 (60.0f))
{
strcpy(m_textureName, "default.png");
strcpy_s(m_textureName, sizeof(m_textureName), "default.png");
}

ndVector m_ambient;
Expand Down
2 changes: 1 addition & 1 deletion newton-4.00/sdk/dCore/ndThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ndThreadName
public:
ndThreadName()
{
strcpy(m_name, "newtonWorker");
strcpy_s(m_name, sizeof(m_name), "newtonWorker");
}
char m_name[32];
};
Expand Down

0 comments on commit 7b1e6cc

Please sign in to comment.