Adding info from a external .txt file in the arena configuration

Requests regarding how to set up experiments in ARGoS.
Jazmin A Diaz
Posts: 2
Joined: Wed Sep 06, 2023 12:03 am

Adding info from a external .txt file in the arena configuration

Postby Jazmin A Diaz » Fri Sep 15, 2023 1:55 am

Hi there,
I'm creating a simulation environment that involves a really high amount of boxes, so, to not enter all manually I created them with a python program and stored them in a .txt file, I want to include it in my arena configuration, but I don't know how, I tried creating a Lua file to read the .txt:

Code: Select all

local textFile = io.open("/home/jazmin/tuttifrutti/log/Tesis/Codigos/big_walls.txt", "r") if textFile then local fileContent = textFile:read("*all") textFile:close() -- Define a local function to include the content in your Argos arena configuration local function includeTextContent() -- Start your XML element here io.write('<obstacle>') -- Insert the content of your text file io.write(fileContent) -- Close your XML element here io.write('</obstacle>') end -- Call the function includeTextContent() else print("Error: Unable to open the text file.") end
And then read it in the area like this:

Code: Select all

<lua> includeTextContent(/home/jazmin/tuttifrutti/log/Tesis/Codigos/text.lua) </lua>
But it doesn't recognize lua, it says:

[FATAL] Failed to initialize the space.
[FATAL] Symbol "lua" not found

Saw somewhere I could use obstacles? So I tried:

Code: Select all

<obstacles> <lua> includeTextContent("/path/to/your_script.lua") </lua> </obstacles>
But then I got:

[FATAL] Failed to initialize the space.
[FATAL] Symbol "obstacles" not found

Please help me, what can I do to include my .txt file in the .argos connfiguration file, especifically in the <arena> configThank you in advance for the help.

Here is the full .argos code in case it helps:

Code: Select all

<?xml version="1.0" ?> <argos-configuration> <!-- ************* --> <!-- * Framework * --> <!-- ************* --> <framework> <experiment length="400" random_seed="3" ticks_per_second="10"></experiment> <!--si 77 30 55 20 66 89 99 (no detecta timer5=100) 18 20 --> <!--no 65 25 16 33--> </framework> <!-- ****************** --> <!-- * Loop functions * --> <!-- ****************** --> <loop_functions label="tutti_tmt_loop_function" library="/home/jazmin/tuttifrutti/experiments-loop-functions/build/loop-functions/moca/libtutti_tmt_loopfunc.so"> <params build_arena="false" lenght_boxes="0.25" maximization="false" number_boxes_per_edge="3" number_edges="8" number_robots=""></params> </loop_functions> <!-- *************** --> <!-- * Controllers * --> <!-- *************** --> <controllers> <!-- TRANSMITTER --> <automode_controller id="tuttifrutti" library="/home/jazmin/tuttifrutti/AutoMoDe-tuttifrutti/build/src/libautomode.so"> <actuators> <epuck_wheels implementation="default" noise_std_dev="0.05"></epuck_wheels> <epuck_rgb_leds implementation="default" medium="leds"></epuck_rgb_leds> <epuck_range_and_bearing data_size="4" implementation="medium" medium="rab" range="0.5"></epuck_range_and_bearing> </actuators> <sensors> <epuck_proximity calibrated="true" implementation="default" noise_level="0.05" show_rays="false"></epuck_proximity> <epuck_range_and_bearing calibrated="true" data_size="4" implementation="medium" loss_probability="0.85" medium="rab" noise_std_deviation="1.5"></epuck_range_and_bearing> <epuck_light calibrated="true" implementation="default" noise_level="0.05" show_rays="false"></epuck_light> <epuck_ground calibrated="true" implementation="rot_z_only" noise_level="0.05"></epuck_ground> <epuck_omnidirectional_camera implementation="rot_z_only" medium="leds" show_rays="false"></epuck_omnidirectional_camera> </sensors> <params fsm-config=" --nstates 4 --s0 8 --vel0 1.2 --cle0 0 --clr0 2 --n0 3 --n0x0 0 --c0x0 7 --p0x0 1 --l0x0 1 --n0x1 1 --c0x1 7 --p0x1 0.15 --l0x1 3 --n0x2 2 --c0x2 2 --p0x2 1 --s1 9 --vel1 1.2 --cle1 0 --clr1 1 --n1 3 --n1x0 0 --c1x0 7 --p1x0 1 --l1x0 2 --n1x1 1 --c1x1 7 --p1x1 1 --l1x1 3 --n1x2 2 --c1x2 2 --p1x2 1 --s2 9 --vel2 1.2 --cle2 4 --clr2 3 --n2 2 --n2x0 0 --c2x0 7 --p2x0 1 --l2x0 2 --n2x1 1 --c2x1 7 --p2x1 1 --l2x1 1 --s3 1 --cle3 3 --n3 1 --n3x0 2 --c3x0 7 --p3x0 1 --l3x0 3" history="false" readable="true"></params> <!-- From sa -> n0x0 sb = n0x0 sb+1, (a < b) --> <!-- From sa -> n0x0 sb = n0x0 sb , (a > b)--> </automode_controller> </controllers> <!-- ********* --> <!-- * Arena * --> <!-- ********* --> <arena center="0,0,0.075" size="10, 10, 0.25"> <!-- Change the floor here --> <floor id="floor" pixels_per_meter="300" source="loop_functions"></floor> <!-- Change the light here --> <!-- Please note that this light has an intensity equal to 0 --> <!-- and therefore does not affect the experiment. --> <!-- ARGoS requires at least one light when using the light sensor --> <light color="black" id="light" intensity="0.0" medium="leds" orientation="0,0,0" position="1.5,1.5,0.10"></light> <!-- ********** --> <!-- * E-Puck * --> <!-- ********** --> <distribute> <position max="0.4,0.4,0" method="uniform" min="-1,-1,0"></position> <orientation mean="0,0,0" method="gaussian" std_dev="360,0,0"></orientation> <entity max_trials="100" quantity="6"> <e-puck id="epuck"> <controller config="tuttifrutti"></controller> </e-puck> </entity> </distribute> <!-- * Arena * --> <lua> includeTextContent(/home/jazmin/tuttifrutti/log/Tesis/Codigos/text.lua) </lua> </arena> <!-- ******************* --> <!-- * Physics engines * --> <!-- ******************* --> <physics_engines> <dynamics2d id="dyn2d"></dynamics2d> </physics_engines> <!-- ********* --> <!-- * Media * --> <!-- ********* --> <media> <led grid_size="20,20,1" id="leds"></led> <range_and_bearing grid_size="20,20,1" id="rab"></range_and_bearing> </media> <!-- ***************** --> <!-- * Visualization * --> <!-- ***************** --> <visualization> <qt-opengl> <camera> <placement idx="0" lens_focal_length="30" look_at="0,0,0" position="0,0,2.7"></placement> </camera> </qt-opengl> </visualization> </argos-configuration>

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

Re: Adding info from a external .txt file in the arena configuration

Postby pincy » Wed Sep 20, 2023 4:16 pm

I think that the easiest and fastest way to do this would be to use the Loop Functions, instead of using the .argos file. You could input your box positions and orientations, and then add them in your Init() method. Have a look at the custom distributions example and adapt the code in there to your needs.

The specific error you're encountering is that ARGoS has no object called "obstacle". You can get a list of recognized objects by typing: argos3 -q entities. You'll notice none of the objects is called "obstacle".
I made ARGoS.

Jazmin A Diaz
Posts: 2
Joined: Wed Sep 06, 2023 12:03 am

Re: Adding info from a external .txt file in the arena configuration

Postby Jazmin A Diaz » Tue Sep 26, 2023 1:25 am

Thanks, at the end I just used copy and paste, I was running out of time, but thank you in anyway!!


Return to “How to... ?”