Skip to content
Snippets Groups Projects
Commit ef405548 authored by Hugo Roussel's avatar Hugo Roussel
Browse files

Update documentation

parent f14bb865
No related branches found
No related tags found
2 merge requests!3Merge masters,!2Merge dev into develop
documentation/GUI_description_1.jpg

58.1 KiB

documentation/GUI_description_2.jpg

37.8 KiB

# GUI description
![Main VUI](GUI_description_1.jpg)
![Save Explorer](GUI_description_2.jpg)
\ No newline at end of file
# Using Py4j
[Py4j](https://www.py4j.org/) is a Python/Java tool allowing control java code with python.
Demos are available in the [py4j_demo](py4j_demo) directory.
A minimalistic main is provided at `py4j.Main.java`. Please note that py4j use socket, so only one process of that main can be executed at a given time. You can have multiple amoeba on a same process, but only one GUI on the same process. If you need to launch multiple amoebas with GUI at a same time, check py4j official documentation on how to change sockets.
To compile AMOEBA as an executable jar with this main, do :
```
mvn clean compile assembly:single -Dmain.class=py4j.Main
```
\ No newline at end of file
# Install :
Install python dependencies :
```
pip3 install requirements.txt
```
Optional : check [openai gym](https://gym.openai.com/) documentation for a full install.
Run the setup script [setup.sh](setup.sh) (linux only)
You're good to go, check that py4j is correctly working with [basic_demo.py](basic_demo.py) :
```
python3 basic_demo.py
```
You should get the classic amoeba's GUI, and random context appearing.
Then you can look at some actual learning, inside [learn_gym.py](learn_gym.py).
# Optional : Ros2Learn
[Ros2Learn](https://github.com/AcutronicRobotics/ros2learn) provide some tools for machine learning on robots, using Ros2, openAI gym, and gazebo.
Install Ros2 and Ros2learn, follow Ros2Learn instruction. Make sure your version of gazebo is at least 9.9.
In your python script, import gym_gazebo2. Before running your python code make sure that you properly loaded Ros2 and Ros2learn environment using their provision scripts.
You can now use gym environment provided by Ros2learn as regular gym environment.
```Python
env = gym.make('MARA-v0')
```
import os import os
import gym import gym
import gym_gazebo2 #import gym_gazebo2
import subprocess import subprocess
import time import time
import math import math
......
#The Save System
The save system is composed of two main elements, and some GUI elements :
## The Backup System :
Found in `kernel.backup`.
A backup system is an object responsible for reading/writing the state of amoeba from/to a file. It implement the interface `IBackupSystem`. The implementation provided is `BackupSystem` and use xml to store data.
Usage :
```Java
AMOEBA amoeba = new AMOEBA()
IBackupSystem backupSystem = new BackupSystem(amoeba);
backupSystem.load(new File("path/to/a/save.xml"));
// do some learning with the amoeba ...
backupSystem.save(new File("path/to/a/new/file.xml"))
```
## The Save Helper :
Found in `kernel.backup`.
A save helper is an object that provide additional functionality over a BackupSystem for the user or other components. Most importantly it :
- Create a temporary directory for saves
- Allow automatic saving during amoeba execution
- Add the options to save/load on the GUI
- Add functionality used by the SaveExplorer.
See `ISaveHelper` for more.
Two implementation are provided : the fully functioning `SaveHelperImpl` and `SaveHelperDummy` that do nothing. The dummy is used to deactivate ALL automatic saving, giving a HUGE performance boost.
Each amoeba has a save helper, available with `amoeba.saver`
```Java
AMOEBA amoeba = new AMOEBA();
// This constructor initialize the amoeba's saver with a dummy, meaning :
amoeba.saver.save("this_does_not_save");
// will do nothing
// or ...
AMOEBA amoeba = new AMOEBA("path/to/save.xml", null);
// This constructor create and use a SaveHelperImpl to initilize the amoeba
amoeba.saver.save("a/valid/path/save.xml");
// will create a save, and
amoeba.saver.autosave();
// will create a save in the temporary directory creates by the save helper, located in
System.out.println(SaveHelperImpl.dir)
```
If amoeba crash, the save files will not be automatically deleted, you may have to manually clean the save directory.
## The Save Explorer
Found in `gui.saveExplorer`.
The save explorer read saves from an amoeba's SaveHelper and offer some graphical tool, most importantly the ability to preview a save and quickly cycle trough saves. Allowing to visually play back the execution of an amoeba.
See the [GUI description](gui.md) for more detail on the GUI.
...@@ -16,7 +16,7 @@ Depending on your problem, determine what AMOEBA should learn, and from what. Bu ...@@ -16,7 +16,7 @@ Depending on your problem, determine what AMOEBA should learn, and from what. Bu
A config file is a xml file used to initialize your amoeba. Most importantly it contain the list of percepts. A config file is a xml file used to initialize your amoeba. Most importantly it contain the list of percepts.
You can use `utils/genFiles.py` to generate your xml file based on a list of percept. `python genFiles.py MySystem false px py` will create `MySystem.xml` (and `MySystem.msg`, but ignore it if you don't use [AMOEBA and ROS](rosbridge.md)) containing something looking like the following example : You can use `utils/genFiles.py` to generate your xml file based on a list of percept. `python genFiles.py MySystem false px py` will create `MySystem.xml` (and `MySystem.msg`, but ignore it if you don't use [AMOEBA and ROS](rosbridge.md)) containing something looking like the following example :
(if you don't want to use python, a java class doing the same job is available at `utils.XmlConfigGenerator`)
```xml ```xml
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<System> <System>
...@@ -144,6 +144,6 @@ public static void main(String[] args) { ...@@ -144,6 +144,6 @@ public static void main(String[] args) {
} }
} }
``` ```
We can ask amoeba how well it performed on the last prediction with `amoeba.getHeads().get(0).getCriticity()`. We can ask amoeba how well it performed on the last prediction with `amoeba.getHeadAgent().getCriticity()`.
For more example on how to use amoeba, check `AdvancedMain.java`, `MinimalMain.java`, and `Main.java` in the `experiments` package. For more example on how to use amoeba, check `AdvancedMain.java`, `MinimalMain.java`, and `Main.java` in the `experiments` package.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment