ARM LAB / STUDY / LEVEL 4 OF 8

Robot coordinates,
VR coordinates.

The tables describe the robot in its own world: metres, origin at the centre of the base, and z pointing up, as robotics software does. The VR scene has y pointing up, its origin on the floor under the player, and the model drawn at twice life size so it is easy to see. The same point therefore has two different sets of numbers. One matrix, on the base node, translates between them, and it sets exactly one trap: distances measured in the scene are twice the real ones.

scale(2)applied first: the whole robot, twice as big
→
turnX(−90°)robot z (up) becomes scene y (up); robot y becomes scene −z
→
move(0, 1.0, −0.8)onto a table in front of the player
→
every jointhangs under this node, so all of them get it

The same arm, two worlds

the purple dot is the gripper frame in both

Robot frame: x across, z up, metres

VR scene: x across, y up; floor at 0, player at x = 0

pointrobot frame (m)VR scene (m)

Build the base matrix

armLab.js line 39

Untick "stand the robot up" and watch the VR view: the arm lies flat on the table, pointing away from you, because robot z is now scene z.

The real code

armLab.js

One node, three calls. Everything the robot is made of is added under it. Reading a position back goes the other way: the engine's global matrix is converted into the scene's frame with the inverse of the scene's own matrix, so a label can be placed next to a joint whatever the room alignment is.


      

The trap

armLab.js

A distance between two scene points is in scene metres, which are two real centimetres per scene centimetre here. The scene divides by SCALE before telling the operator anything. The display can be any size; the numbers must be the real robot's.


      
Full file: armLab.js ↗ · the course's SO101.js ↗ uses the same turnX on its base

What you should be able to explain

  1. Two conventions. Robotics and CAD use z up; most graphics engines, including this one, use y up. Neither is wrong; a 90° turn about x converts between them.
  2. One matrix fixes it for everything. Because every joint node is a child of the base node, the base's matrix is multiplied into every part automatically. No table value was edited.
  3. Which numbers are which. Values in the tables are robot-frame metres (third component = height). Values from getGlobalMatrix() are scene metres (second component = height). Mixing them up puts a label in the wrong place.
  4. Scaled displays lie about distance. Any length read from the scene must be divided by the model's scale before it is shown as a real measurement.

Exercises: ① With everything ticked, the gripper frame's robot z is about 0.23 and its scene y about 1.45. Show the arithmetic. ② Untick only scale(2): what changes in the scene column and what does not? ③ If the model were drawn at life size, which line of the scene would still be needed and which would become a no-op?