Leg Kinematics
A robot leg is a small arm that pushes on the ground. Its controller decides where each foot should be, and inverse kinematics turns that into hip and knee angles. For two joints there are two answers, knee forward or knee backward, and the robot picks one and sticks to it.
Turn walking off, then drag the foot.
Two-joint leg inverse kinematics
With thigh length \(L_1\), shank length \(L_2\), and the foot at \((x, z)\) relative to the hip, the knee angle comes from the law of cosines, with a sign choice for the two knee directions:
What to notice
The foot path has two parts. In stance, the foot is on the ground and moves backward in a straight line, pushing the body forward. In swing, it lifts and moves forward through the air. Make the step longer and the leg nearly straightens at each end, close to a singularity, where the knee angle changes fast. Many legged robots, such as quadrupeds, mix knee directions between front and back legs. The faint leg shows the other solution, which is just as valid but would flip the knee.