Kinematics is the study of motion without considering the cause of the motion, such as forces and torques. Inverse kinematics (IK) is the use of kinematic equations to determine the motion of a robot to reach a desired position. For example, to perform automated apple picking, a robotic arm needs precise motion from an initial position to a desired position between apples and manufacturing machines. The grasping end of a robot arm is designated as the end-effector. The robot configuration is a list of segments positions that are within the position limits of the robot model and do not violate any constraints the robot has.
Given the desired robot’s end-effector positions, inverse kinematics can determine an appropriate segment configuration for which the end-effectors move to the target pose.
Addapted from MathWorks
For each Segment of the Tentacle do :
- make Segment point towards the target
- set Point a so that Point b is on the target
- set Point b based on Point a
- set Point a to be the target for next segment
In the end, if there is a base, shift the hole Tentacle back to its base and proceed to the next frame of animation.
All the code is written using the Engine library and a personnal Vector class. The Tentacle object is basically an array of Segment. The Ball object is just a fancy target for the tentacle class. As always, the main file contains the core draw loop.