A robot which can also move after being flipped?

I try to simulate a real robot which is able to flip, thanks to its symmetric shape. Unfortuneately, once the robot is flipped in simulation it does not move anymore. The wheels of the physics entity can be seen moving in the simulator, so I assume it has to do with the wheels contact vector, which points now up into the sky.
A possible solution might be to reset this pointer to the ground once I detect the flipped robot, but I haven't found a way to change this pointer back to the ground.
Any suggestions?
[527 byte] By [ThorDe] at [2008-1-8]
# 1
It is the wheel's contact vector. When I create the WheelEntity I can set the contact vector by setting the LocalPose.Orientation of the WheelEntity. But now, when I try to change the LocalPose.Orientation at runtime this does not work:
public override void Update(FrameUpdate update)
{
...
_leftWheel.WheelShape.WheelState.LocalPose.Orientation = Quaternion.FromAxisAngle(1f,0f,0f,(float) Math.PI);

//PhysicsEntity.UpdateState(true);
_leftWheel.Update(update);
_rightWheel.Update(update);
base.Update(update);

}

ThorDe at 2007-10-2 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Simulation...
# 2

The LocalPose in the state is only used to initialize the shape. Once the entity has been initialized, you must call PhysicsEntity.SetShapeLocalPose to change the pose of a shape. Please reply and let me know if this solves your problem. We haven't done an implementation of a flipping robot, yet.

-Kyle

KyleJ-MSFT at 2007-10-2 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Simulation...
# 3
Hi it does solve the problem.

The Flip condition is not too nice yet, but works:

public override void Update(FrameUpdate update)
{

...
xna.Vector3 vector = UIMath.QuaternionToEuler(base.State.Pose.Orientation);

if(Math.Abs(vector.X) > 100 && !_isFlipped)
{
Pose leftWheelCurPos = _leftWheel.WheelShape.WheelState.LocalPose;
Pose rightWheelCurPos = _rightWheel.WheelShape.WheelState.LocalPose;

leftWheelCurPos.Orientation = Quaternion.FromAxisAngle(1f,0f,0f,(float) Math.PI);
rightWheelCurPos.Orientation = Quaternion.FromAxisAngle(1f,0f,0f, (float) Math.PI);

PhysicsEntity.SetShapeLocalPose(_leftWheel.WheelShape, leftWheelCurPos);
PhysicsEntity.SetShapeLocalPose(_rightWheel.WheelShape, rightWheelCurPos);

_isFlipped = true;

} else if(_isFlipped && Math.Abs(vector.X) <= 100) {
Pose leftWheelCurPos = _leftWheel.WheelShape.WheelState.LocalPose;
Pose rightWheelCurPos = _rightWheel.WheelShape.WheelState.LocalPose;

leftWheelCurPos.Orientation = Quaternion.FromAxisAngle(1f,0f,0f,0f);
rightWheelCurPos.Orientation = Quaternion.FromAxisAngle(1f,0f,0f,0f);

PhysicsEntity.SetShapeLocalPose(_leftWheel.WheelShape, leftWheelCurPos);
PhysicsEntity.SetShapeLocalPose(_rightWheel.WheelShape, rightWheelCurPos);

_isFlipped = false;
}
...
}


The flip control is implemented in the body to which the two wheels are attached to. I also tried to insert the PhysicsEntity.SetShapeLocalPose in the WheelEntity class, though this returned a nullpointer on PhysicsEntity.

The two conditions cover flip and backflip.
Only changing the Orientation of each wheel - not Position.

If anyone wonders why flipping a body with two wheels: the whole robot consists of two similar body parts - so there will be four wheels in total.

Thx
Tom

ThorDe at 2007-10-2 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Simulation...

Microsoft Robotics Studio

Site Classified