Getting robots coordinates in lua

Requests regarding how to set up experiments in ARGoS.
LordJops
Posts: 4
Joined: Tue Jul 28, 2020 10:18 pm

Getting robots coordinates in lua

Postby LordJops » Fri Sep 11, 2020 1:06 am

Hello,
i'm a beginner in argos and i may have missed it, i need to collect fotbots positions (x and y coordinates) for my aggregation algorithm so i can use them to calculate the surface and other metrics
is there a way to get the positions of fotbots in lua? any other ideas are welcomed.
i have another question too, i want to use multiple light sources with different intensity and make robots aggregate around them and the higher the intensity the bigger the group will be, so how do i get the intensity value from inside the controller? also in lua.
Thanks in advance for your help.

LordJops
Posts: 4
Joined: Tue Jul 28, 2020 10:18 pm

Re: Getting robots coordinates in lua

Postby LordJops » Fri Sep 11, 2020 8:15 pm

I found the solution in an old forum post from 2015
and here is Mr pincy's answer if anyone need it in the future:
add the positioning sensor in the .argos file (check out argos3 -q positioning for details).

Then you can access the data from Lua in the tables robot.positioning.position and robot.positioning.orientation. Shift-click on a robot to see the details of these data structures

LordJops
Posts: 4
Joined: Tue Jul 28, 2020 10:18 pm

Re: Getting robots coordinates in lua

Postby LordJops » Sat Sep 12, 2020 8:41 am

i ran into a problem, when i add that line in sensors in the .argos file, i get an error saying i'm trying to index a nil value

Code: Select all

[INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_pointmass3d.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_epuck.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_prototype.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_eyebot.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_genericrobot.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_qtopengl.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_footbot.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_entities.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_dynamics3d.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_dynamics2d.so" [INFO] Loaded library "/usr/lib/argos3/libargos3core_simulator.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_media.so" [INFO] Loaded library "/usr/lib/argos3/libargos3plugin_simulator_spiri.so" PANIC: unprotected error in call to Lua API (attempt to index a nil value) Aborted (core dumped)
Any help is appreciated, thank you

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

Re: Getting robots coordinates in lua

Postby pincy » Sat Sep 12, 2020 6:49 pm

Can you share your code? It's impossible to guess what's wrong with the information you provided.
I made ARGoS.

LordJops
Posts: 4
Joined: Tue Jul 28, 2020 10:18 pm

Re: Getting robots coordinates in lua

Postby LordJops » Sat Sep 12, 2020 7:18 pm

i had my colleague run my code and he had no error, it seems i have a corrupt Lua installation or something is missing from my machine, i tried to reinstall Lua or add some feature from package manager but nothing worked, and at the current time i can't waste time reinstalling Argos from scratch.
anyway, here is my code, it should work fine (i have a linux mint 18.3 64bit version)
pos-ctrl.lua
pos-exp.argos

Thank you for your help.

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

Re: Getting robots coordinates in lua

Postby pincy » Sat Sep 12, 2020 7:38 pm

If it's a problem with your installation, it might be Anaconda. It interferes with many system libraries. If you have it installed, try commenting out its configuration from .bashrc.
I made ARGoS.


Return to “How to... ?”



cron