Page 1 of 2
example "flocking.argos"
Posted: Tue Oct 29, 2013 7:53 pm
by alexprocopio
How can I change the example "flocking.argos" for when the robots surround the light sensor,
the light sensor can move, simulating what is a bird, and robots continue surrounding the sensor?
I am studying Brazilian has installed 10 days this simulator.
Very interesting, just need more documentation to understand it.
Hugs to all.
Alex Procopio
alex.procopio @ hotmail.com
Re: example "flocking.argos"
Posted: Wed Oct 30, 2013 12:25 pm
by pincy
Hi Alex,
You can change the position of the light using the loop functions. To understand how the loop functions work, have a look at the CLoopFunction class documentation; for an example, check the foraging experiment.
In the end, the code boils down to this:
Code: Select all
/***********************/
/* my_loop_functions.h */
/***********************/
class MyLoopFunctions : public CLoopFunctions {
public:
virtual void PostStep();
};
Code: Select all
/*************************/
/* my_loop_functions.cpp */
/*************************/
void MyLoopFunctions::PostStep() {
// Get a reference to the light
CLightEntity& cLight = dynamic_cast<CLightEntity&>(GetSpace().GetEntity("light"));
// Move the light entity to the wanted position
cLight.SetPosition(CVector3(x, y, z));
}
REGISTER_LOOP_FUNCTIONS(MyLoopFunctions, "my_loop_functions");
To use the loop functions, add this to your .argos file:
Code: Select all
/******************/
/* flocking.argos */
/******************/
<argos-configuration>
...
<loop_functions library="/PATH/TO/libmy_loop_functions.so" label="my_loop_functions" />
...
</argos-configuration>
Alternatively, if you want to have a controller dedicated to the moving object, you can add a robot playing the part of the bird and write a controller for it.
Cheers,
Carlo
Re: example "flocking.argos"
Posted: Thu Oct 31, 2013 1:57 am
by alexprocopio
On the way "argos3-examples \ loop_functions" created the directory "my_loop_functions" and created the files inside "my_loop_functions.cpp" and "my_loop_functions.h"
In "argos3-examples \ experiments" changed the file "flocking.argos" adding:
"<loop_functions library="build/loop_functions/my_loop_functions/libmy_loop_functions.so" label="my_loop_functions">
</ loop_functions> "
phaco how to compile? gotta change anything else?
went "argos3-example/build" performed:
cmake ..
make
cd ..
experiments argos3-c / flocking.argos
but the error below, anyone know what I'm doing wrong??
[INFO] Not using threads
[INFO] Using random seed = 124
[INFO] Using simulation clock tick = 0.1
[INFO] Total experiment length in clock ticks = unlimited
./build/loop_functions/my_loop_functions/libmy_loop_functions.so: cannot open shared object file: No such file or directory
/usr/lib/argos3/build/loop_functions/my_loop_functions/libmy_loop_functions.so: cannot open shared object file: No such file or directory
[FATAL] Error initializing loop functions
[FATAL] Can't load library "build/loop_functions/my_loop_functions/libmy_loop_functions.so".[/b]
Re: example "flocking.argos"
Posted: Thu Oct 31, 2013 2:17 am
by pincy
Have a closer look at the examples. You'll notice that every directory contains a file called CMakeLists.txt. Each of these files contains commands to tell CMake which files to compile and how.
First, you need to modify loop_functions/CMakeLists.txt and add a line add_subdirectory (my_loop_functions). This tells CMake to descend into that directory and execute what the CMakeLists.txt there says.
Then, you need to write a CMakeLists.txt file in loop_functions/my_loop_functions. You can take as example the foraging loop functions or the trajectory loop functions (for the latter, you need to git pull because I added the trajectory example yesterday).
Hope this helps. For more information about CMake, check the manual because it's really well done

Re: example "flocking.argos"
Posted: Sun Nov 03, 2013 9:54 pm
by alexprocopio
hello!
In the lecture notes on "Pattern Formation" mentions adding a loop in the distance and pontencial Lennard-Jones, calculating the sine and cosine. AT the end of function calculates the tangent of these angles.
In the example "footbot_flocking.cpp" I realized that idea is not implemented. It did not work the previous one?
Re: example "flocking.argos"
Posted: Sun Nov 03, 2013 10:26 pm
by pincy
I'm sorry, I don't understand the question
In the notes for the students, I put it as a challenge to extend the algorithm to form square lattices.
In the ARGoS examples I just implemented the base algorithm for explanatory purposes.
The two things are unrelated.
Re: example "flocking.argos"
Posted: Mon Nov 04, 2013 3:31 pm
by alexprocopio
Good morning! Now I get it. Was accessing beyond the examples files, other files in the simulator to find the sine and cosine functions. I realized that this is not linked with the material of lecture notes.
Thanks for your help, every day I'm enjoying more this simulator.
hugs
Re: example "flocking.argos"
Posted: Mon Nov 04, 2013 4:26 pm
by pincy
OK, nice it was solved.
Thanks for your nice words

Re: example "flocking.argos"
Posted: Tue Nov 05, 2013 6:01 pm
by alexprocopio
Hello!
I woke up early today and am studying ARGOS. But I do not understand some details of the ideas of the algorithm and how the simulator executes. I quote this simulator in my master's dissertation.
You for a case, would not have some stuff for me to read about the construction of the experiments? Their implementations? lecture notes? May be even drafts.
any help is welcome.
Re: example "flocking.argos"
Posted: Wed Nov 06, 2013 1:59 am
by pincy