How do I modify the robot entity

Requests regarding how to set up experiments in ARGoS.
Net
Posts: 4
Joined: Thu Dec 10, 2015 7:11 pm

How do I modify the robot entity

Postby Net » Mon Dec 14, 2015 10:56 pm

Hello,

I'm really new to all this, and I'm having trouble doing things beyond the examples.
In the long run I would like to implement my own robot model, but for know I want to edit and modify existing robots, specifically the sensors on the e-puck.

I'm currently testing different coverage algorithms and would benefit from having longer sensor ranges.
I saw that this is possible to edit from the epuck_entity.cpp file. However I can't seem to find this file.

I installed argos following the user manual instructions for mac. It seems to me that parts of argos are located in different places. The important parts seem to be mainly in /usr/local/Cellar and the experiments seem to be in a folder on my desktop. It seems to me that the epuck_entity.cpp should be in /usr/local/Cellar/argos3/3.0.0-beta39/include/argos3/plugins/robots/e-puck/simulator but I only see the .h file.

I've downloaded the source from the github, in hopes that I could run the simulation with all the files, but I haven't been able to.

Any help is appreciated.

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

Re: How do I modify the robot entity

Postby pincy » Tue Dec 15, 2015 1:12 am

Hi,

When you install a program, you only get the header files (if necessary) and the binaries. Never the sources, because they're not necessary. This is true for any piece of software, including ARGoS. So, it's normal that installing ARGoS through HomeBrew does not include the sources.

If you want to make your own robot, you don't need to modify the ARGoS sources. You can download them for reference (it's a good idea!) or you could read the relevant files on GitHub. Anyway, no modification is necessary.

To make your own robot, you need to make three classes for it: an entity class (which says how a robot is structured), a physics model (which says how a robot interacts with the environment), and a qt-open model (which says how to draw the robot). If you have special needs, you might need to add new classes to model new devices that ARGoS does not support.

You could use as a starting point the classes of the e-puck. Copy the e-puck files that you find in the ARGoS sources (argos3/src/plugins/robots/e-puck/) somewhere. It could be in a new, dedicated project that you create from scratch, or as a subdirectory of the examples (easier). Then, make the necessary changes: for instance, change the name of the classes (e.g., "CMyEPuck"), change the parameters you want to change, and fix the REGISTER_* statements at the end of the .cpp files to match your new class name.

For instance, if your EXAMPLEDIR is the folder in which you have your ARGoS examples and ARGOSDIR the folder in which you downloaded the ARGoS sources from GitHub, you could execute the following commands in a Bash shell:
  1. Set the environment variables EXAMPLEDIR and ARGOSDIR. They must be full paths for the subsequent commands to work. Fix these paths to match your configuration.

    Code: Select all

    export EXAMPLEDIR=/Users/myuser/argos3-examples

    Code: Select all

    export ARGOSDIR=/Users/myuser/argos3
  2. Copy the files of the e-puck into the folder

    Code: Select all

    cp -a $ARGOSDIR/src/plugins/robots/e-puck $EXAMPLEDIR/myepuck

    Code: Select all

    rm -f $EXAMPLEDIR/myepuck/simulator/*physx*
  3. Fix the file $EXAMPLEDIR/CMakeLists.txt:

    Code: Select all

    echo 'add_subdirectory(myepuck)' >> $EXAMPLEDIR/CMakeLists.txt
  4. Then, change the filenames and the class names to reflect your new robot:

    Code: Select all

    find $EXAMPLEDIR/myepuck \( -name '*.h' -o -name '*.cpp' \) -print0 | xargs -0 -I{} sed -i.old -e 's/EPuck/MyEPuck/g' -e 's/e-puck/my_e-puck/g' -e 's/epuck/myepuck/g' -e 's/EPUCK/MYEPUCK/g' -e 's|argos3/plugins/robots/my_e-puck|myepuck|g' {}

    Code: Select all

    find $EXAMPLEDIR/myepuck -name '*.old' -exec rm {} \;

    Code: Select all

    for F in `find $EXAMPLEDIR/myepuck \( -name '*.h' -o -name '*.cpp' \)`; do G=`basename $F | sed 's/epuck/myepuck/g'`; mv $F `dirname $F`/$G; done

    Code: Select all

    cat <<EOF > $EXAMPLEDIR/myepuck/CMakeLists.txt add_library(argos3plugin_simulator_myepuck SHARED simulator/dynamics2d_myepuck_model.cpp simulator/dynamics2d_myepuck_model.h simulator/myepuck_entity.cpp simulator/myepuck_entity.h simulator/qtopengl_myepuck.cpp simulator/qtopengl_myepuck.h) target_link_libraries(argos3plugin_simulator_myepuck argos3core_simulator argos3plugin_simulator_dynamics2d argos3plugin_simulator_entities argos3plugin_simulator_genericrobot argos3plugin_simulator_media) if(ARGOS_COMPILE_QTOPENGL) target_link_libraries(argos3plugin_simulator_myepuck argos3plugin_simulator_qtopengl \${QT_LIBRARIES} \${GLUT_LIBRARY} \${OPENGL_LIBRARY}) endif(ARGOS_COMPILE_QTOPENGL) EOF
  5. Compile the code

    Code: Select all

    cd $EXAMPLEDIR

    Code: Select all

    rm -rf build

    Code: Select all

    mkdir build

    Code: Select all

    cd build

    Code: Select all

    cmake -DCMAKE_BUILD_TYPE=Debug ..

    Code: Select all

    make
  6. Tell ARGoS to go look for your robot as a new plugin

    Code: Select all

    export ARGOS_PLUGIN_PATH=$EXAMPLEDIR/build/myepuck
  7. Make sure ARGoS has correctly seen your robot:

    Code: Select all

    argos3 -q entities
    This should show the name of your robot. If so, ARGoS is ready to use it!
  8. You're good to go. You can put my_e-puck in your .argos file and make all the modifications you want to the code in the directory my_e-puck.
To have ARGoS always remember to look into your example build dir to find your robot (after you close the terminal), execute the following command:

Code: Select all

echo "export ARGOS_PLUGIN_PATH=$EXAMPLEDIR/build/myepuck" >> $HOME/.bashrc
Finally, an important thing: make sure that you either have installed ARGoS through HomeBrew (recommended) or that you have installed ARGoS through the source code. Do not install ARGoS twice, nor execute ARGoS from the sources while having another version of ARGoS installed through HomeBrew. That's important because otherwise ARGoS' plugin systems will get confused and load plugins multiple times, which will create memory corruptions.

Cheers,
Carlo
I made ARGoS.

Net
Posts: 4
Joined: Thu Dec 10, 2015 7:11 pm

Re: How do I modify the robot entity

Postby Net » Tue Dec 15, 2015 5:35 am

Thank you for the quick response Carlo.

I did everything you described and created the myepuck entity.
However somewhere along the way a ran into some trouble. I started getting some errors that I can't seem to recreate when attempting to run the experiment with the new entity. Then I couldn't even run the example experiments. In frustration I attempted to uninstall ARGoS and reinstall it. The uninstall didn't seem to work, so I reinstalled Homebrew in hope that it would fix my problem. I then tried to instal ARGoS once again.

I followed the instructions as if I were doing everything for the first time and got the following error when attempting to setup the configuration with

Code: Select all

cmake ..
$ cmake ..
CMake Error at CMakeLists.txt:17 (include):
include could not find load file:

ARGoSCheckQTOpenGL


-- Could NOT find GALIB (missing: GALIB_LIBRARY GALIB_INCLUDE_DIR)
CMake Error at CMakeLists.txt:29 (find_package):
By not providing "FindLua52.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Lua52", but
CMake did not find one.

Could not find a package configuration file provided by "Lua52" with any of
the following names:

Lua52Config.cmake
lua52-config.cmake

Add the installation prefix of "Lua52" to CMAKE_PREFIX_PATH or set
"Lua52_DIR" to a directory containing one of the above files. If "Lua52"
provides a separate development package or SDK, be sure it has been
installed.


-- Configuring incomplete, errors occurred!
See also "/Users/argos3-examples/build/CMakeFiles/CMakeOutput.log".
See also "/Users/argos3-examples/build/CMakeFiles/CMakeError.log".
$
Is there a fix for this or a way I could actually uninstall ARGoS and start again from scratch?

Thanks,
- Net

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

Re: How do I modify the robot entity

Postby pincy » Tue Dec 15, 2015 6:59 am

  1. How did you install ARGoS?
  2. What error did you find that made you uninstall everything?
On a side note: if you have a compilation problem, before uninstalling ARGoS or blaming the computer configuration, report the problem here. It might save you lots of trouble :-)
I made ARGoS.

Net
Posts: 4
Joined: Thu Dec 10, 2015 7:11 pm

Re: How do I modify the robot entity

Postby Net » Tue Dec 15, 2015 10:24 am

Ok, so I wiped my machine (it didn't have much) and retried the whole process. I'll detail it step by step.

1. installed the latest version of xcode
2. installed homebrew from brew.sh using

Code: Select all

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
3.

Code: Select all

brew tap ilpincy/argos3
4.

Code: Select all

brew install bash-completion qt lua argos3
5.

Code: Select all

brew install cmake
6.

Code: Select all

brew install gsl
7.

Code: Select all

brew install qt
8. changed directory to my desktop where I decided to do everything

Code: Select all

cd Desktop
9. got argos3-examples from Github and changed to that directory.

Code: Select all

git clone https://github.com/ilpincy/argos3-examples

Code: Select all

cd argos3-examples
10.

Code: Select all

mkdir build
11.

Code: Select all

cd build
12.

Code: Select all

cmake ..
13.

Code: Select all

make
Then when compiling it gets to 75% before getting and error.
Here's what it looks like.
Scanning dependencies of target mpga_phototaxis_loop_functions
[ 72%] Building CXX object loop_functions/mpga_loop_functions/CMakeFiles/mpga_phototaxis_loop_functions.dir/mpga_phototaxis_loop_functions.cpp.o
[ 75%] Linking CXX shared library libmpga_phototaxis_loop_functions.dylib
ld: library not found for -lfootbot_nn
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [loop_functions/mpga_loop_functions/libmpga_phototaxis_loop_functions.dylib] Error 1
make[1]: *** [loop_functions/mpga_loop_functions/CMakeFiles/mpga_phototaxis_loop_functions.dir/all] Error 2
make: *** [all] Error 2
I'll read through the installation and the user guides to see if I can find where I went wrong.

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

Re: How do I modify the robot entity

Postby pincy » Tue Dec 15, 2015 3:13 pm

The compilation issue that you found was indeed a little problem of the ARGoS examples. It occurs when you don't have GALib installed. I fixed the issue. Do the following:

Code: Select all

cd $EXAMPLEDIR

Code: Select all

git pull

Code: Select all

rm -rf build

Code: Select all

mkdir build

Code: Select all

cd build

Code: Select all

cmake -DCMAKE_BUILD_TYPE=Release ..

Code: Select all

make
and you're good to go.

NOTE: On Mac, the latest version of CMake has a bug. In theory, if you change any CMakeLists.txt file and then try to compile with 'make', CMake should be able to recreate the Makefiles correctly. Instead, compilation crashes with an error. This is not an issue with ARGoS, but a regression of CMake that I hope will be fixed soon. To get around it, every time you change a CMakeLists.txt file, you need to do the following:

Code: Select all

cd $EXAMPLEDIR/build

Code: Select all

rm CMakeCache.txt

Code: Select all

cmake -DCMAKE_BUILD_TYPE=Release ..

Code: Select all

make
I made ARGoS.

Net
Posts: 4
Joined: Thu Dec 10, 2015 7:11 pm

Re: How do I modify the robot entity

Postby Net » Tue Dec 15, 2015 7:41 pm

Everything works now! :D
I even got the my own robot entity working.
Thank you so much Carlo. You are very patient.

Best,
Net


Return to “How to... ?”