Step 4
Rotations in 3-D
Build rotation matrices about x, y and z, compose them, and aim the gripper by reading one column.
Rotation matrices
In 3-D an orientation is a rotation matrix : a 3×3 array whose columns are a turned frame's , and axes, written in world coordinates. Multiplying a vector by rotates it.
The three basic rotations turn by an angle about one axis and leave that axis alone:
Each is the 2-D rotation matrix placed in the two axes that turn. In the minus sign sits lower left, because turning about carries towards .
Order matters
Two rotations in a row multiply: . Unlike ordinary numbers, in general. Tip a book forwards and then spin it, or spin it and then tip it: it ends up facing different ways.
The gripper's orientation
The gripper has its own tool frame: runs along the fingers, is the direction they close, and completes the set. The base angle turns it about the vertical, and the shoulder, elbow and wrist angles , , all tilt it about the same horizontal axis, so they simply add up:
Its third column is where the gripper points: . With it points straight down.
Other ways to store a rotation
A rotation has three degrees of freedom, so nine numbers are more than it needs. Euler angles store three angles about set axes; they're compact, but at some orientations two of the axes line up and one angle stops mattering (gimbal lock). Axis–angle stores an axis and how far to turn about it. Quaternions use four numbers and are what most robot software passes around. All of them convert to the same .
Pick & Place, step 6 makes to keep the gripper pointing down.
Your task
- Implement
rot_x,rot_y,rot_zandtool_rotation(q). The starter draws your tool frame on the gripper at three poses; blue () should run along the fingers. - Point the gripper along
POINT = [0.48, 0.64, -0.6], with the shoulder at 0.4 rad and the elbow at 1.2 rad. Work out the base and wrist angles from the third column. - Compare the two orders the starter prints and draws.