1

I'm trying to simulate an assembly factory. In which, several robots gather the necessary parts (objects A & B) and drop them off on the assembly table. Once A & B are both on the assembly table, I want an event to trigger which converts A & B into a third object C. This event can either be automatic or triggered via keyboard input. Objects A & B should disappear and object C should spawn at a specific coordinate.

I currently have ground & arm robots which transports objects A & B to the assembly table, but that's all I have right now. The ground robot is remotely controlled (Webot's Khepera 1 TCP/IP model), so timing will always be different.

My main question: How do I remove objects A & B and spawn object C based on an event during simulation?

A side question: How can the assembly table automatically detect when both objects A & B are on the table?

1 Answers1

0

To achieve this, the best way is probably use a Supervisor controller that monitors the simulation. It will track the positions of objects A and B and determine from their X, Y, Z coordinates if they are on the table or not. To understand how to track the position of an object, you can follow this tutorial.

Then, you have two possibilities, the first one being more realistic and the second one being easier to implement and faster to execute.

  1. When objects A and B are close enough to each other and/or some event happens, you can have the supervisor process delete objects A and B. To delete them, you should first get the root node of the scene using wb_supervisor_node_get_root, get its children field using wb_supervisor_node_get_field and then wb_supervisor_field_remove_mf to remove the A and B nodes from the list of children of the root node. Then, you will have to insert the C object at the location of A and B. To achieve this, you should use the wb_supervisor_field_import_mf_node_from_string and pass a string containing the description of node C (which could be a PROTO).

  2. Instead of deleting and inserting objects A, B and C, it may be simpler and more efficient to move them around. Moving an object is very simple and explained in this other tutorial. From the beginning, your scene should include objects A, B and C, but C should be initially very far away (like several kilometers away), so that it won't be visible. When you need to turn A and B into C, simply move A and B very far away, so that they are not visible any more, and move C at the previous location of A and B.

Olivier Michel
  • 755
  • 6
  • 10
  • @adiga: sorry for this. My affiliation is clearly set in my profile and I thought it was sufficient. But I am happy to edit this post to make it even clearer. I am pointing to some existing tutorial because I believe it is not a good idea to copy/paste some existing tutorial. Otherwise, we should maintain them at several places, which is error prone and time consuming. – Olivier Michel Dec 09 '22 at 08:51
  • I didn't realize the tag and question were related to Cyberbotics company. My bad. You don't need to add a disclaimer if it is a link to the documentation the question is related to. – adiga Dec 12 '22 at 12:14