Create multiple boxes with LED on top

Requests regarding how to set up experiments in ARGoS.
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 5:44 pm

I removed that line from my code, but still getting the same error.
Can you share your code with me? Have you tried using gdb to see where the error occurs and why?
Logically, if we have to add a led to the led medium ourselves, then we should remove it too.
It depends on what you consider "logical". ARGoS takes ownership of everything you add, so it can optimize storage and make resetting/destroying easier.
I made ARGoS.

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

Re: Add entities programatically into a prototype

Postby mbt925 » Thu Jun 07, 2018 6:51 am

Can you share your code with me? Have you tried using gdb to see where the error occurs and why?
This is my code.
It depends on what you consider "logical". ARGoS takes ownership of everything you add, so it can optimize storage and make resetting/destroying easier.
I meant that the following line could be done automatically:

Code: Select all

cLEDMedium.AddEntity(pcBox->GetLEDEquippedEntity().GetLED(0));

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 » Fri Jun 08, 2018 1:25 pm

Can you share your code with me? Have you tried using gdb to see where the error occurs and why?
This is my code.
I'll have a look, but have you tried using gdb to hunt the issue?
It depends on what you consider "logical". ARGoS takes ownership of everything you add, so it can optimize storage and make resetting/destroying easier.
I meant that the following line could be done automatically:

Code: Select all

cLEDMedium.AddEntity(pcBox->GetLEDEquippedEntity().GetLED(0));
I can look into it, although I tried in the past to have a design in that direction and the solution I found was very inefficient. But I'll try to look at it again.
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 » Fri Jun 08, 2018 3:52 pm

I found the issue. I put the correct code in the original post, so whoever looks for an answer gets the right thing instantly.

I copy the correct code here:

Code: Select all

CMyLoopFunctions::Init(...) { // Get a reference to the LED medium // // The passed id "leds" corresponds to the id of the led_medium in // the XML file // // see https://github.com/ilpincy/argos3/blob/master/src/core/simulator/simulator.h // see https://github.com/ilpincy/argos3/blob/master/src/plugins/simulator/media/led_medium.h CLEDMedium& cLEDMedium = GetSimulator().GetMedium("leds"); // Add a new box with an LED on top // see https://github.com/ilpincy/argos3/blob/master/src/plugins/simulator/entities/box_entity.h CBoxEntity* pcBox = new CBoxEntity("box1", // id CVector3(1.0, 2.0, 0.0), // position CQuaternion(), // orientation true, // movable or not? CVector3(0.5, 0.5, 0.5), // size 1.0); // mass in kg // Add LED on top of the box pcBox->AddLED(CVector3(0.0, 0.0, 1.0), // offset CColor::RED); // color // Enable LED management for the box pcBox->EnableLEDs(cLEDMedium); // Add the box to the simulation AddEntity(*pcBox); }
Notice that the files you gave me do not compile, due to naming issues in the include files. Also, you haven't included all the changes I made in the past fixes I gave you, such as linking as follows:

Code: Select all

if(ARGOS_COMPILE_QTOPENGL) target_link_libraries(epuck_aggregation_loop_functions argos3plugin_simulator_qtopengl ${ARGOS_QTOPENGL_LIBRARIES}) endif(ARGOS_COMPILE_QTOPENGL)
In the future, please give me files that compile, to make it faster for me to reproduce issues.
I made ARGoS.

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

Re: Create multiple boxes with LED on top

Postby mbt925 » Fri Jun 08, 2018 4:27 pm

Thank you very much.I am sorry for the code. It was compiling and working just fine on my PC.

Please add the "ADDING LIGHT TO THE LED MEDIUM" part to your code too.

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

Re: Create multiple boxes with LED on top

Postby mbt925 » Sat Jun 09, 2018 7:36 am

I noticed that you changed just the order of lines. Am I right?
Last edited by mbt925 on Sat Jun 09, 2018 9:44 am, edited 1 time in total.

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

Re: Create multiple boxes with LED on top

Postby mbt925 » Sat Jun 09, 2018 9:42 am

I upgraded my sample project. Now, it creates 100 boxes with led in Init method and removes and recreates them in Reset method.

I did the following steps for getting the following segfault:

1. Run the simulation
2. Terminate it
3. Reset it
4. Repeat the whole process a couple of times

Note: without LEDs, everything works fine.

Code: Select all

[FATAL] While updating the LED grid for LED "" [FATAL] CGrid<ENTITY>::PositionToCell() : Position <4.63557e-310,inf,inf> out of bounds X -> -2.5:2.5 Y -> -2.5:2.5 Z -> 0:1

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 » Sun Jun 10, 2018 10:25 pm

The code you sent me is not a precise copy-paste of what I gave you. You added an extra line:

Code: Select all

cLEDMedium.AddEntity(pcBox->GetLEDEquippedEntity().GetLED(0));
This line should not be there, because it adds the LED again to the medium. That task is already done by

Code: Select all

pcBox->EnableLEDs(cLEDMedium);
Also, in your code I don't understand why you add 100 boxes along a diagonal. What are you trying to obtain?
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 6:48 am

Thank you for the response.
The code you sent me is not a precise copy-paste of what I gave you. You added an extra line:

Code: Select all

cLEDMedium.AddEntity(pcBox->GetLEDEquippedEntity().GetLED(0));
This line should not be there, because it adds the LED again to the medium. That task is already done by
I suggested earlier that this line should be done automatically, but you said:
I can look into it, although I tried in the past to have a design in that direction and the solution I found was very inefficient. But I'll try to look at it again.
So, I interpreted that this line has to be there.
Also, in your code I don't understand why you add 100 boxes along a diagonal. What are you trying to obtain?
It was just for test.

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 11:38 am

Adding and removing entities are OK after omitting cLEDMedium.AddEntity().
Everything was fine until I added OmnidirectionalCamera sensor to my robots. The camera is not doing anything. I just turned it on and got segfault.

Code: Select all

m_pcCamera = GetSensor<CCI_EPuckOmnidirectionalCameraSensor>("epuck_omnidirectional_camera"); m_pcCamera->Enable();
The segfault I am getting is:
Thread 1 "argos3" received signal SIGSEGV, Segmentation fault.
0x00007ffff7b41e7a in argos::CEntity::HasParent (this=0xd1)
at /home/argos3/src/argos3/core/simulator/entity/entity.h:172
172 return (m_pcParent != NULL);
(gdb) where
#0 0x00007ffff7b41e7a in argos::CEntity::HasParent (this=0xd1)
at /home/argos3/src/argos3/core/simulator/entity/entity.h:172
#1 0x00007fffe95f0757 in argos::CLEDCheckOperation::operator()(argos::CLEDEntity&) () from /usr/local/lib/argos3/libargos3plugin_simulator_epuck.so
#2 0x00007ffff144a245 in argos::CGrid<argos::CLEDEntity>::ForEntitiesInBoxRange (this=0x5555558026f0, c_center=..., c_half_size=..., c_operation=...)
at /home/argos3/src/argos3/core/simulator/space/positional_indices/grid_impl.h:273
#3 0x00007fffe95ef99f in argos::CEPuckOmnidirectionalCameraSensor::Update() ()
from /usr/local/lib/argos3/libargos3plugin_simulator_epuck.so
#4 0x00007ffff7b504d7 in argos::CControllableEntity::Sense (
this=0x55555581bdd0)
at /home/argos3/src/core/simulator/entity/controllable_entity.cpp:210
#5 0x00007ffff7b7ff52 in argos::CSpaceNoThreads::UpdateControllableEntitiesSenseStep (this=0x5555557ab460)
at /home/argos3/src/core/simulator/space/space_no_threads.cpp:57
#6 0x00007ffff7b7436a in argos::CSpace::Update (this=0x5555557ab460)
at /home/argos3/src/core/simulator/space/space.cpp:133
#7 0x00007ffff7b2f727 in argos::CSimulator::UpdateSpace (this=0x5555557a2780)
at /home/argos3/src/core/simulator/simulator.cpp:282
#8 0x00007ffff35487b3 in argos::CQTOpenGLWidget::StepExperiment (this=
0x555555b77460)
at /home/argos3/src/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.cpp:514
#9 0x00007ffff354a084 in argos::CQTOpenGLWidget::timerEvent (
this=0x555555b77460, pc_event=0x7fffffffd550)
at /home/argos3/src/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.cpp:782
#10 0x00007ffff0fe95f3 in QObject::event(QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#11 0x00007ffff2aaeb0b in QWidget::event(QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007ffff2a6735c in QApplicationPrivate::notify_helper(QObject*, QEvent*)
() from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007ffff2a6eb21 in QApplication::notify(QObject*, QEvent*) ()
from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007ffff352da3d in argos::CQTOpenGLApplication::notify (
this=0x5555558c1650, pc_receiver=0x555555b77460, pc_event=0x7fffffffd550)
---Type <return> to continue, or q <return> to quit---
at /home/argos3/src/plugins/simulator/visualizations/qt-opengl/qtopengl_application.cpp:21
#15 0x00007ffff0fbcc00 in QCoreApplication::notifyInternal2(QObject*, QEvent*)
() from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007ffff101003e in QTimerInfoList::activateTimers() ()
from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#17 0x00007ffff1010561 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#18 0x00007fffed6c8377 in g_main_context_dispatch ()
from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#19 0x00007fffed6c85e0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#20 0x00007fffed6c868c in g_main_context_iteration ()
from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#21 0x00007ffff101109f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x00007ffff0fbabea in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#23 0x00007ffff0fc333c in QCoreApplication::exec() ()
from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#24 0x00007ffff353f2ca in argos::CQTOpenGLRender::Execute (this=0x5555558c15e0)
at /home/argos3/src/plugins/simulator/visualizations/qt-opengl/qtopengl_render.cpp:65
#25 0x00007ffff7b2f6f3 in argos::CSimulator::Execute (this=0x5555557a2780)
at /home/argos3/src/core/simulator/simulator.cpp:274
#26 0x0000555555570b2c in main (n_argc=3, ppch_argv=0x7fffffffdfe8)
at /home/argos3/src/core/simulator/main.cpp:38
(gdb) finish
Run till exit from #0 0x00007ffff7b41e7a in argos::CEntity::HasParent (
this=0xd1)
at /home/argos3/src/argos3/core/simulator/entity/entity.h:172
Couldn't get registers: No such process.


Return to “How to... ?”



cron