Skip to content

Commit

Permalink
trying different anim sequence, but not luck
Browse files Browse the repository at this point in the history
  • Loading branch information
Julio Jerez committed Mar 2, 2024
1 parent 98d498f commit 35118db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
26 changes: 11 additions & 15 deletions newton-4.00/applications/ndSandbox/demos/ndQuadrupedTest_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace ndQuadruped_1
{
//#define ND_TRAIN_MODEL
#define ND_TRAIN_MODEL

#define CONTROLLER_NAME "ndQuadruped_1VPG.dnn"

Expand All @@ -38,7 +38,7 @@ namespace ndQuadruped_1

enum ndActionSpace
{
m_move_x,
//m_move_x,
m_move_z,
m_actionsSize
};
Expand Down Expand Up @@ -329,9 +329,6 @@ namespace ndQuadruped_1
for (ndInt32 i = 0; i < m_model->m_animPose.GetCount(); ++i)
{
const ndAnimKeyframe& keyFrame = m_model->m_animPose[i];
//ndEffectorInfo* const info = (ndEffectorInfo*)keyFrame.m_userData;
//ndIkSwivelPositionEffector* const effector = (ndIkSwivelPositionEffector*)*info->m_effector;

if (!keyFrame.m_userParamInt)
{
ndContact* const contact = m_model->FindContact(i);
Expand Down Expand Up @@ -560,7 +557,7 @@ namespace ndQuadruped_1
}
else if (desiredSupportPoint.GetCount() == 2)
{
ndAssert(0);
ndTrace(("xxxxxxxxxx\n"));
context.DrawLine(desiredSupportPoint[0], desiredSupportPoint[1], supportColor);
//ndBigVector p0Out;
//ndBigVector p1Out;
Expand Down Expand Up @@ -644,13 +641,13 @@ namespace ndQuadruped_1
//m_control->m_animSpeed = 2.0f;
//m_control->m_animSpeed = 1.0f;
//m_control->m_animSpeed = 0.5f;
//m_control->m_animSpeed = 0.25f;
m_control->m_animSpeed = 0.1f;
m_control->m_enableController = 0;
m_control->m_animSpeed = 0.25f;
//m_control->m_animSpeed = 0.1f;

//m_control->m_enableController = 0;
if (m_control->m_enableController)
{
m_control->m_x = ndClamp(ndReal(m_control->m_x + actions[m_move_x] * D_SWING_STEP), -D_MAX_SWING_DIST_X, D_MAX_SWING_DIST_X);
//m_control->m_x = ndClamp(ndReal(m_control->m_x + actions[m_move_x] * D_SWING_STEP), -D_MAX_SWING_DIST_X, D_MAX_SWING_DIST_X);
m_control->m_z = ndClamp(ndReal(m_control->m_z + actions[m_move_z] * D_SWING_STEP), -D_MAX_SWING_DIST_Z, D_MAX_SWING_DIST_Z);
}
UpdatePose(m_timestep);
Expand Down Expand Up @@ -680,7 +677,7 @@ namespace ndQuadruped_1
}

ndBrainFloat* const input = &observation[m_legObservationsSize * 4];
input[m_move_x] = m_control->m_x;
//input[m_move_x] = m_control->m_x;
input[m_move_z] = m_control->m_z;
}

Expand Down Expand Up @@ -867,10 +864,9 @@ namespace ndQuadruped_1

ndFloat32 angles[] = { 300.0f, 240.0f, 120.0f, 60.0f };
ndFloat32 offset[] = { -0.3f, 0.3f, -0.3f, 0.3f };
////ndFloat32 phase[] = { 0.0f, 0.5f, 0.0f, 0.5f};
////ndSharedPtr<ndAnimationSequence> sequence(new ndRobot::ndPoseGenerator(0.47f, phase));

ndFloat32 phase[] = { 0.0f, 0.5f, 0.25f, 0.75f };
//ndFloat32 phase[] = { 0.0f, 0.75f, 0.25f, 0.5f };
ndFloat32 phase[] = { 0.0f, 0.25f, 0.5f, 0.75f };
ndSharedPtr<ndAnimationSequence> sequence(new ndRobot::ndPoseGenerator(0.24f, phase));

model->m_poseGenerator = new ndAnimationSequencePlayer(sequence);
Expand Down Expand Up @@ -1033,7 +1029,7 @@ void ndQuadrupedTest_1(ndDemoEntityManager* const scene)
world->AddModel(model);

ndSharedPtr<ndJointBilateralConstraint> fixJoint(new ndJointFix6dof(model->GetAsModelArticulation()->GetRoot()->m_body->GetMatrix(), model->GetAsModelArticulation()->GetRoot()->m_body->GetAsBodyKinematic(), world->GetSentinelBody()));
world->AddJoint(fixJoint);
//world->AddJoint(fixJoint);

ndSharedPtr<ndUIEntity> quadrupedUI (new ndModelUI(scene, model));
scene->Set2DDisplayRenderFunction(quadrupedUI);
Expand Down
6 changes: 3 additions & 3 deletions newton-4.00/applications/ndSandbox/ndDemoEntityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ ndDemoEntityManager::ndDemoEntityManager()
// initialized the physics world for the new scene
//m_showUI = false;
//m_showAABB = true;
//m_hideVisualMeshes = true;
m_hideVisualMeshes = true;
//m_showScene = true;
//m_showConcaveEdge = true;
//m_showMeshSkeleton = true;
Expand All @@ -457,12 +457,12 @@ ndDemoEntityManager::ndDemoEntityManager()
//m_showRaycastHit = true;
//m_showCenterOfMass = false;
m_showNormalForces = true;
//m_showContactPoints = true;
m_showContactPoints = true;
//m_showJointDebugInfo = true;
m_showModelsDebugInfo = true;
//m_collisionDisplayMode = 1;
//m_collisionDisplayMode = 2;
//m_collisionDisplayMode = 3; // solid wire frame
m_collisionDisplayMode = 3; // solid wire frame
m_synchronousPhysicsUpdate = true;
m_synchronousParticlesUpdate = true;

Expand Down

0 comments on commit 35118db

Please sign in to comment.