Create multiple boxes with LED on top

Requests regarding how to set up experiments in ARGoS.
pincy
Site Admin
Posts: 296
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: Create multiple boxes with LED on top

Postby pincy » Mon Jun 11, 2018 12:11 pm

If you give me some code I can try to reproduce the error, I'll check it.
I made ARGoS.

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

Re: Create multiple boxes with LED on top

Postby mbt925 » Mon Jun 11, 2018 12:32 pm

Here is the code.

The source of segfault is the following line.

Code: Select all

m_pcCamera->Enable();

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

Re: Create multiple boxes with LED on top

Postby mbt925 » Sun Jun 17, 2018 7:16 am

Is there any problem in my code? :?:

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

Re: Create multiple boxes with LED on top

Postby pincy » Tue Jun 19, 2018 8:25 pm

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().
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 20, 2018 6:15 am

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.


Return to “How to... ?”



cron