adeline.paiement

Hi,

I created a robot with several joints. These joints have one degree of freedom and their drive mode are Velocity or Position.

I try to use Set AngularDriveVelocity and SetAngularDriveOrientation, and it works sometimes, but not always. I often get the error message :

PhysicsErrorStream: Error code 2 reported. MessageStick out tonguehysicsSDK: NpActor::wakeUp: WriteLock is still acquired. Procedure call skipped to avoid a deadlock!

PhysicsErrorStream: Error code 2 reported. MessageStick out tonguehysicsSDK: NpD6Joint:Tongue TiedetDriveAngularVelocity: WriteLock is still acquired. Procedure call skipped to avoid a deadlock!

I tried to use the command

System.Threading.Thread.Sleep(5000);

before using these functions, but it didn't solve the problem.



Re: Microsoft Robotics - Simulation Cannot use SetAngularDriveVelocity and SetAngularDriveOrientation

KyleJ - MSFT

These functions should only be called while no physics simulation is underway. A safe place to call them is in the update method of an entity. If you create a new entity, you can override the update method and call these methods from there.

You can also schedule a task to execute in the update method without overriding the it. The following code taken from the KukaLBR3Entity in samples\entities\entities.cs shows how to do this. You can call SetJointTargetOrientation at any time and SetJointTargetOrientationInternal will execute during the update method of the entity.

Code Snippet

/// <summary>

/// Sets orientation only for angular drives

/// </summary>

/// <param name="j"></param>

/// <param name="axisAngle"></param>

public void SetJointTargetOrientation(Joint j, AxisAngle axisAngle)

{

Task<Joint, AxisAngle> deferredTask = new Task<Joint, AxisAngle>(j, axisAngle, SetJointTargetOrientationInternal);

yourEntity.DeferredTaskQueue.Post(deferredTask);

}

void SetJointTargetOrientationInternal(Joint j, AxisAngle axisAngle)

{

if (j.State.Angular != null)

{

Quaternion target =

TypeConversion.FromXNA(

xna.Quaternion.CreateFromAxisAngle(TypeConversion.ToXNA(axisAngle.Axis), axisAngle.Angle)

);

((PhysicsJoint)j).SetAngularDriveOrientation(target);

}

}





Re: Microsoft Robotics - Simulation Cannot use SetAngularDriveVelocity and SetAngularDriveOrientation

adeline.paiement

Thanks a lot ! Now it works perfectly ! Smile