Can't get bone to stop flipping

Hello, I am trying to animate my caveboy to do a simple dive. For some reason when I raise his right arm the forearm bone flips. I can’t seem to keep it from flipping. Is there a solution to this mess that I am missing.

Thanks… here is the animation, you will see it when he raises his arms.

Small file size - about 100kb

it could be something to do with the rest position of the IK chain

Please elaborate. I noticed the axes on the right side are 180 degrees different than the left side. Do you think that could be the problem?

I would guess that axis orientation is the issue. I also had trouble with bones on either side being 180deg opposed and it took some effort to fix it (OSX).

Before doing too much messing around, select all bones in POSE mode and do an ALT-R, ALT-G to be sure the bones are resting properly - you may have rotated one to an awkward angle. Also not that IK chains sometime misbehave if it has trouble finding a “solution”.

If this isn’t the problem then the first thing to try is to recalculate the roll angles (you’ve probably done it anyway). Select the armature, enter Edit mode, (Turn on “show axis”), Front view (num1), select all bones then CTRL-N (Recalc Roll Angles). Hopefully all your bones will shift into a logical alignment and your problems are solved.

If not, you might try aligning groups of bones so they aren’t bent (like horizontal all hand/arm bones) - select the bones then S-Y-0 (zero) & S-Z-0 then CTRL-N again. Then do the same with vertical bones.

If not, then the solution I found is messy but it got me there. I selected in Object mode, CTRL-A (apply size rot). Go back into edit mode and try CTRL-N again. If it still doesn’t work sit down and take a deep breath. Select all bones, go to side view (Num3) and rotate the whole armature 90deg so the armature lies on its “back”. Then CTRL-N again. Chances are, the bones will rotate and look sensible. Then rotate it all back to a standing position and they should remain aligned with Z up (the axis will rotate before your eyes).

Hopefully this will fix it but you may need to select one or two naughty bones and manually align them. I think I used the number panel for this (N Key) and entered 0.000 in the rot panel. You may need to rotate them manually.

You might find your mesh has messed up as a result. Unparent it (or remove modifier) and redo the parenting/modifier. If some bits are twisted you will need to manually rotate the bone (in EDIT mode, not Pose mode) and check the result. If this works, you should be able to shift arm and leg bones to give elbow/knee bends if that’s how you want them.

(***Everything above assumes armature is standing, facing front view)

Hopefully someone has a better solution. If not, you may need to post a blend.

in my very newbie experience you cant rotate a bone 180 degrees if it has a ikhandle, and that is it. i could be wrong though, if i am someone please correct me.Something that you can do when in pose mode is to have your mouse far from the selected bone while you rotate it so you dont make a movement that your rig setup dont allow this way you can minimize it.