Create multiple boxes with LED on top

Requests regarding how to set up experiments in ARGoS.
mbt925
Posts: 36
Joined: Mon Aug 07, 2017 12:21 pm

Re: Create multiple boxes with LED on top

Postby mbt925 » Thu May 24, 2018 1:41 pm

You can compile it and see the full error message.

pincy
Site Admin
Posts: 301
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: Create multiple boxes with LED on top

Postby pincy » Sat May 26, 2018 1:35 am

I fixed a few files.
Attachments
epuck_aggregation.zip
(100.73 KiB) Downloaded 13 times
I made ARGoS.

mbt925
Posts: 36
Joined: Mon Aug 07, 2017 12:21 pm

Re: Create multiple boxes with LED on top

Postby mbt925 » Sat May 26, 2018 6:16 am

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.

mbt925
Posts: 36
Joined: Mon Aug 07, 2017 12:21 pm

Re: Create multiple boxes with LED on top

Postby mbt925 » Tue Jun 05, 2018 11:27 am

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.

mbt925
Posts: 36
Joined: Mon Aug 07, 2017 12:21 pm

Re: Create multiple boxes with LED on top

Postby mbt925 » Tue Jun 05, 2018 12:06 pm

How can I set a color for a box? Other than using a LED.

mbt925
Posts: 36
Joined: Mon Aug 07, 2017 12:21 pm

Re: Add entities programatically into a prototype

Postby mbt925 » Wed Jun 06, 2018 11:52 am

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);

pincy
Site Admin
Posts: 301
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: Add entities programatically into a prototype

Postby pincy » Wed Jun 06, 2018 2:46 pm

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 made ARGoS.

pincy
Site Admin
Posts: 301
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: Create multiple boxes with LED on top

Postby pincy » Wed Jun 06, 2018 2:46 pm

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 made ARGoS.

mbt925
Posts: 36
Joined: Mon Aug 07, 2017 12:21 pm

Re: Create multiple boxes with LED on top

Postby mbt925 » Wed Jun 06, 2018 4:33 pm

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.

mbt925
Posts: 36
Joined: Mon Aug 07, 2017 12:21 pm

Re: Add entities programatically into a prototype

Postby mbt925 » Wed Jun 06, 2018 4:35 pm

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.


Return to “How to... ?”



cron