Page 2 of 4

Re: Create multiple boxes with LED on top

Posted: Thu May 24, 2018 1:41 pm
by mbt925
You can compile it and see the full error message.

Re: Create multiple boxes with LED on top

Posted: Sat May 26, 2018 1:35 am
by pincy
I fixed a few files.

Re: Create multiple boxes with LED on top

Posted: Sat May 26, 2018 6:16 am
by mbt925
Thank you very much.
I did try "GetMedium<CLEDMedium>", but I did not include the header. C++ warnings and errors do not help at all :D.

Re: Create multiple boxes with LED on top

Posted: Tue Jun 05, 2018 11:27 am
by mbt925
I added some boxes via the above-mentioned code with no problem. But I get the following error when I close the running simulation:

Code: Select all

[FATAL] CSpace::RemoveEntity() : Entity "box1.leds_0.led_0" has not been found in the indexes.

Re: Create multiple boxes with LED on top

Posted: Tue Jun 05, 2018 12:06 pm
by mbt925
How can I set a color for a box? Other than using a LED.

Re: Add entities programatically into a prototype

Posted: Wed Jun 06, 2018 11:52 am
by mbt925
I added some boxes via the above-mentioned code with no problem. But I get the following error when I close the running simulation:

Code: Select all

[FATAL] CSpace::RemoveEntity() : Entity "box1.leds_0.led_0" has not been found in the indexes.
What is the correct way to remove an entity which is added at runtime?
I want to add and remove entities (boxes) to the simulation at runtime. But when I remove an entity, I get a segmentation fault. I guess it's related to the LED.

Adding a new box:

Code: Select all

CLEDMedium& cLEDMedium = GetSimulator().GetMedium<CLEDMedium>("leds"); CBoxEntity* pcBox = new CBoxEntity("box1", CVector3(randomX, randomY, 0.0), CQuaternion(), true, CVector3(1.0, 1.0, 0.5), 0.5); pcBox->EnableLEDs(cLEDMedium); pcBox->AddLED(CVector3(0.0, 0.0, 0.2), CColor::RED); AddEntity(*pcBox); cLEDMedium.AddEntity(pcBox->GetLEDEquippedEntity().GetLED(0));

Removing an existing box:

Code: Select all

cLEDMedium.RemoveEntity(pcBox->GetLEDEquippedEntity().GetLED(0)); RemoveEntity(*pcBox);

Re: Add entities programatically into a prototype

Posted: Wed Jun 06, 2018 2:46 pm
by pincy
What is the correct way to remove an entity which is added at runtime?
Removing an existing box:

Code: Select all

cLEDMedium.RemoveEntity(pcBox->GetLEDEquippedEntity().GetLED(0)); RemoveEntity(*pcBox);
Do not explicitly remove the led from the medium. Once you add an LED to a box, ARGoS takes care of cleaning up. The segmentation fault you get should be a double-free issue due to the fact that ARGoS tries to delete an object that you have already manually deleted.

Re: Create multiple boxes with LED on top

Posted: Wed Jun 06, 2018 2:46 pm
by pincy
How can I set a color for a box? Other than using a LED.
Box colors are just for display, and can't be changed. They're not visible by the camera or anything.

Re: Create multiple boxes with LED on top

Posted: Wed Jun 06, 2018 4:33 pm
by mbt925
How can I set a color for a box? Other than using a LED.
Box colors are just for display, and can't be changed. They're not visible by the camera or anything.
I know. I wanted it just for illustration purposes.

Re: Add entities programatically into a prototype

Posted: Wed Jun 06, 2018 4:35 pm
by mbt925
What is the correct way to remove an entity which is added at runtime?
Removing an existing box:

Code: Select all

cLEDMedium.RemoveEntity(pcBox->GetLEDEquippedEntity().GetLED(0)); RemoveEntity(*pcBox);
Do not explicitly remove the led from the medium. Once you add an LED to a box, ARGoS takes care of cleaning up. The segmentation fault you get should be a double-free issue due to the fact that ARGoS tries to delete an object that you have already manually deleted.
I removed that line from my code, but still getting the same error.
Logically, if we have to add a led to the led medium ourselves, then we should remove it too.