1

Robot controller uses RRT to generate a set of nodes (x,y) taking it from start to finish. If possible I would like for these nodes to somehow show in the environment.

Edit:

root = supervisor.getRoot() 
root_children_field = root.getField("children") root_children_field.importMFNode(-1,"tree_node.wbo") 
node = root_children_field.getMFNode(-1) 
field = node.getField("translation") 
location = [-1, 0.5, 0] # location of path node 
field.setSFVec3f(location)
nightman
  • 11
  • 2

1 Answers1

1

You can use the Supervisor to import/modify/change/move/remove nodes (such as visual nodes) at runtime in the environment: https://www.cyberbotics.com/doc/reference/supervisor

You will find some example simulations using the Supervisor here:

David Mansolino
  • 1,713
  • 7
  • 13
  • Thank you! I decided on importing and placing nodes at the coordinates I wanted to mark (shown in edit of OP). However, when I want to remove that node by just adding root_children_field2.removeMF(-1) Webots freezes (not responding). Do you have any idea what I'm doing wrong? – nightman Apr 30 '20 at 13:25
  • Do you have there same behaviour if you use Node.remove() instead (https://cyberbotics.com/doc/reference/supervisor?tab-language=python#wb_supervisor_node_remove) ? – David Mansolino May 01 '20 at 05:26
  • 1
    I might've made a big mistake by not putting the remove line in the while loop. First it was in the beginning where everything is initialized, using Node.remove() here caused Webots to freeze as well. Using Node.remove() in the loop worked for me and I guess using root_children_field2.removeMF(-1) there would work too. Thanks for your help! – nightman May 01 '20 at 09:24