1

Using a Supervisor controller, is it possible to programmatically add Robot nodes to a running simulation which are defined in .proto files?

I tried using importMFNode, but it looks like it only supports .wbo or .wrl files.

sciencectn
  • 1,405
  • 1
  • 16
  • 25

1 Answers1

1

You should use importMFNodeFromString like this:

from controller import Supervisor

supervisor = Supervisor()
children = supervisor.getRoot().getField('children')
children.importMFNodeFromString(-1, 'Nao { translation 0.1 0.334 -0.2 }')

That will add a Nao robot with the specified translation at the bottom of the scene tree. You may also specify the rotation and other parameters of the Nao PROTO.

Olivier Michel
  • 755
  • 6
  • 10