skuleguy

Hi everyone,
I would like to be able to obtain the axle speed of one of my simulated wheel entity. Say, I set it to spin at a desired speed x rad/s in the update() method, now I want to know what the actual speed of the wheel is, to observe how it's getting to the desired speed.
Thanks a lot, everyone.


Re: Microsoft Robotics - Simulation Wheel's current angular speed, is there an easy way ?

skuleguy

Wow,
It seems like there isnt an easy way to do that.
Could you guys give me some suggestions on how to do it
Thanks again, guys




Re: Microsoft Robotics - Simulation Wheel's current angular speed, is there an easy way ?

KyleJ - MSFT

In your entity's Update method, which is called every frame, you can call WheelEntity.PhysicsEntity.UpdateState() to update the wheel entity pose from the physics engine.

If you are using version 1.5 of MSRS (not one of the CTPs, but the final bits) then you can simply read the angular velocity from the entity state after you call UpdateState(). (This field in the state was not updated by UpdateState() prior to version 1.5).

If you are using something earlier than 1.5 you can convert the pose of the wheel entity to three euler angles using

UIMath.QuaternionToEuler(State.Pose.Orientation).

Then you can calculate the angular velocity using angleDelta / timeDelta.

-Kyle





Re: Microsoft Robotics - Simulation Wheel's current angular speed, is there an easy way ?

skuleguy

Hi,

Thanks for your reply, and I'm very excited to hear that now MSRS is equipped with AngularVelocity property.

I have tried to put WheelEntity.PhysicsEntity.UpdateState() in my Update method. But it seems like the UpdateState() method needs to take a boolean argument.

So I tried putting either true or false. It still doesn't not work. (Object reference not set to an instance of an object)

Here's the part of my code where I tried to get the AngularSpeed of my wheel

Code Snippet

public override void Update(FrameUpdate update)

{

_wheel.PhysicsEntity.UpdateState();

//_wheel.PhysicsEntity.UpdateState(false);

//_wheel.PhysicsEntity.UpdateState(true);

angularVelocity = _wheel.State.AngularVelocity;

float squaredMagnitude = angularVelocity.X * angularVelocity.X +

angularVelocity.Y * angularVelocity.Y + angularVelocity.Z * angularVelocity.Z;

wheelCurrentAxleSpeed = (float)Math.Sqrt(squaredMagnitude);

}

Thanks,





Re: Microsoft Robotics - Simulation Wheel's current angular speed, is there an easy way ?

KyleJ - MSFT

You're right. I made some assumptions in my answer that aren't true. In the DifferentialDrive entities, the wheels are not really treated as complete entities with their own PhysicsEntity. Their wheelshape is added to the shapes of their parent.

Fortunately, you can always query the axle speed (rotational speed at the axis) with _wheel.Wheel.AxleSpeed. The Ageia docs don't specify the units for this value but I assume it is radians/second. I will have to do some more experimentation to verify, though.

Code Snippet

float leftRotationSpeed = _leftWheel.Wheel.AxleSpeed;

-Kyle