Page 4 of 4

Re: Create multiple boxes with LED on top

Posted: Mon Jun 11, 2018 12:11 pm
by pincy
If you give me some code I can try to reproduce the error, I'll check it.

Re: Create multiple boxes with LED on top

Posted: Mon Jun 11, 2018 12:32 pm
by mbt925
Here is the code.

The source of segfault is the following line.

Code: Select all

m_pcCamera->Enable();

Re: Create multiple boxes with LED on top

Posted: Sun Jun 17, 2018 7:16 am
by mbt925
Is there any problem in my code? :?:

Re: Create multiple boxes with LED on top

Posted: Tue Jun 19, 2018 8:25 pm
by pincy
I don't understand what you're trying to accomplish. The code you gave me has a number of issues.
  1. In the loop functions, you have a loop over all the epuck. Within this loop, you erase all of the boxes. Why? Looping once over the boxes is enough.
  2. The way you erase the boxes does not work. You can iterate over a container and erase elements at the same time - this creates a memory corruption.
  3. The code is in the PreStep() method. This means that you add the boxes in Init(), allow ARGoS to take note of them, and then remove them before ARGoS has the possibility to update anything. This creates a memory corruption, which leads to the specific problem you're encountering.
Again, I'm not sure what you're trying to accomplish here, but if you want to delete stuff, do it in PostStep() and not in PreStep().

Re: Create multiple boxes with LED on top

Posted: Wed Jun 20, 2018 6:15 am
by mbt925
I don't understand what you're trying to accomplish. The code you gave me has a number of issues.
This is a sample project. I tried to recreate the issue of my main project in it.
  1. In the loop functions, you have a loop over all the epuck. Within this loop, you erase all of the boxes. Why? Looping once over the boxes is enough.
  2. The way you erase the boxes does not work. You can iterate over a container and erase elements at the same time - this creates a memory corruption.
  3. The code is in the PreStep() method. This means that you add the boxes in Init(), allow ARGoS to take note of them, and then remove them before ARGoS has the possibility to update anything. This creates a memory corruption, which leads to the specific problem you're encountering.
Again, I'm not sure what you're trying to accomplish here, but if you want to delete stuff, do it in PostStep() and not in PreStep().

1. My main project is a foraging task. Each epuck picks up a food. In PostStep!, we detect the food and remove it. So it needs two FOR loops.

2. After each deletion, we break from the inner loop.

3. You're right. After replacing PreStep with PostStep, the issue is gone.

Thank you very much.

Re: Create multiple boxes with LED on top

Posted: Thu Aug 09, 2018 6:28 pm
by kylenickerson
I had some problems with the example of setting it up in the code. I was getting this error

Code: Select all

error: 'argos::CLEDMedium' is an incomplete type
But I realized that I was missing an include. I got it to work with:

Code: Select all

#include <argos3/plugins/simulator/media/led_medium.h>

Re: Create multiple boxes with LED on top

Posted: Mon Aug 13, 2018 8:46 am
by pincy
That's the correct solution!