Retrieving/calculating object coordinates

Greetings,

I’m having some difficulty figuring out how to find coordinates for a particular point I wish to draw. What I have is an implementation of a ‘room’ space, within which is placed a robot with an arm that has several points of articulation. At the end of the arm is a dispenser, where I would like to spawn (draw) new objects.

My robot class is defined hierarchically, with shifts to new local coordinate systems to define each successive sub-section of arm. A pseudocode approximation:

class Room {
... // code to move the floor, camera, etc goes here
positionRobot(positioning_vector);
...
Robot.getDispenserPosition(&object_spawnpoint_vector);
dispenseObject(object_spawnpoint_vector);
}

class Robot {
...
getDispenserPosition(&object_spawnpoint_vector) {
// return data destructively
}
draw() {
glPushMatrix();
// move to starting position in room-space, begin drawing
...
// a series of affine transformations go here to move the local coordinates
drawSubunit1();
glPopMatrix();
}

drawSubunit1() {
glPushMatrix();
// draw
...
// a series of affine transformations go here to move the local coordinates
drawSubunit2(); // etc
glPopMatrix();
}

}

I’m not having any trouble with the hierarchy of drawing/positioning the robot itself or its interaction with the static room, only with dynamically calculating the spawn point of the object. For unrelated reasons, I can’t make the spawn method part of the robot class, so I need to have some way of saving these coordinates.

Ideally, I’d like to store the position of my desired spawn point at the end of my nested draw method. This would be efficient in terms of both computing and coding, but it’s probably possible to calculate this again by hand within getDispenserPosition.

Is there any feasible way to do this without a rework of the structure of the room-space?

Thanks in advance for any and all assistance.

Best, Edward