Skip to content

Scene graphs

Peter Corke edited this page Feb 7, 2022 · 4 revisions

Some thoughts regarding more formal scene graphs as part of RTB, rather than Swift.

A motivating scenario

We have a scene comprising:

  • a Panda robot, carrying a tray on which there are 2 glasses and with a camera attached to its shoulder
  • a table with two plates, each plate has 3 cakes

The plates can be moved around on the table, and the table can be moved around.

We can share references to shapes (no state) so we only need one plate, one glass and one cake instance. The state lives in the scene element/node object.

What state to we need to compute and send to Swift?

For every scene element scene we need:

  • a shape
  • a list of its children
  • a transform relative to its parent
  • an alpha value
  • some id to tie the RTB object to the Swift object, could be the .id of the RTB object

What we need to send to Swift after everything is updated is a dict containing a set of:

  • key = the scene element id
  • value = (pose with respect to world frame, alpha)

An alpha thought

It could be useful to set an alpha for a branch of the scene graph, for example we could make the table, plates and cakes translucent. Perhaps the alpha (or a special alpha) for a scene element multiplies the alpha of all its children, so simply by setting the alpha override for the table object would achieve this.

Maybe the same for color? Make a branch of the tree go blue.

Shapes

  • the usual suspects sphere, cylinder, cuboid, mesh, axes etc. based on CollisionShape with attributes like transform wrt parent, color, alpha
  • a Collection shape which is a list of primitive shapes. It has a transform and its children are all defined relative to it
  • a Robot object which represents a set of set of shapes parameterised by a vector. Each link object would contain a display Collection and a collision Collection. The Robot object has a method to update all its shapes given a configuration vector, similar to fkine_all.

To achieve our scenario:

  • we add the camera to the Collection associated with the shoulder link
  • the tray shape's parent is the EE link of the Panda, which means that the Link is a subclass of the same type as a shape, or that Link objects and shape objects are polymorphic and share key methods.

Collision handling

Every shape has a method to test collision against another shape

obj1.iscollided(obj2)

To handle tests between an object and all objects in a branch of the scene graph perhaps

obj1.iscollided(obj2, recurse=True)

or

obj1.iscollided_branch(obj2)

When the object is a Robot it implicitly includes all links of the robot. To test just a single link of the robot, that link would have to be found by finding the link object and using the iscollided method with it.

Clone this wiki locally