Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
simulators [2019/02/12 13:06] mgp3212019 |
simulators [2019/02/14 10:17] mai git code |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | **Simulateur Gazebo** | + | {{tag> software simulator project}} |
- | **Prérequis :** | + | Common API for reinforcement learning using the simulators : |
- | Environnement Linux : Ubuntu 18.04 | + | * Gym : http://wiki-robot.enstb.org/doku.php?id=simulatorGym |
- | ** ** | + | * Gazebo : http://wiki-robot.enstb.org/doku.php?id=simulatorGazebo (branch sheng) |
- | **Installation du ROS Melodic :** | + | * Vrep : http://wiki-robot.enstb.org/doku.php?id=simulatorVrep (branch dev-Flavien_STEFFEN) |
- | ** ** | + | Code is onhttps://github.com/Pikalchemist/lems/tree/livrable_FIP (branch livrable_FIP) |
- | + | ||
- | **Modification du "sources.list":** | + | |
- | + | ||
- | sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb\_release -sc) main" \> /etc/apt/sources.list.d/ros-latest.list' | + | |
- | + | ||
- | **Mettre en place les clés :** | + | |
- | + | ||
- | sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 | + | |
- | + | ||
- | **Installation :** | + | |
- | + | ||
- | sudo apt update | + | |
- | + | ||
- | sudo apt install ros-melodic-desktop-full | + | |
- | + | ||
- | ** ** | + | |
- | + | ||
- | **Initialisation rosdep :** | + | |
- | + | ||
- | sudo rosdep init | + | |
- | + | ||
- | rosdep update | + | |
- | + | ||
- | **Configuration environnement :** | + | |
- | + | ||
- | echo "source /opt/ros/melodic/setup.bash" \>\> ~/.bashrc | + | |
- | + | ||
- | source ~/.bashrc | + | |
- | + | ||
- | **Installation des packages dépendants :** | + | |
- | + | ||
- | sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential | + | |
- | + | ||
- | + | ||
- | + | ||
- | [Explication porvenant de : [http://wiki.ros.org/melodic/Installation/Ubuntu](http://wiki.ros.org/melodic/Installation/Ubuntu)] | + | |
- | + | ||
- | + | ||
- | + | ||
- | **Intégration Turtlebot3:** | + | |
- | + | ||
- | **Création des répertoires:** | + | |
- | + | ||
- | mkdir ~/catkin\_ws | + | |
- | + | ||
- | mkdir ~/catkin\_ws/src | + | |
- | + | ||
- | **Télécharger des codes sources de Turtlebot3:** | + | |
- | + | ||
- | cd ~/catkin\_ws/src/ | + | |
- | + | ||
- | git clone https://github.com/ROBOTIS-GIT/turtlebot3\_simulations.git | + | |
- | + | ||
- | git clone https://github.com/ROBOTIS-GIT/turtlebot3\_msgs.git | + | |
- | + | ||
- | git clone https://github.com/ROBOTIS-GIT/turtlebot3.git | + | |
- | + | ||
- | **Installation:** | + | |
- | + | ||
- | cd ~/catkin\_ws && catkin\_make | + | |
- | + | ||
- | **Configuration environnement:** | + | |
- | + | ||
- | Ajouter les lignes suivantes dans le fichier "~/.bashrc": | + | |
- | + | ||
- | source ~/catkin\_ws/devel/setup.bash | + | |
- | + | ||
- | export TURTLEBOT3\_MODEL=burger | + | |
- | + | ||
- | [Explication porvenant de : [http://emanual.robotis.com/docs/en/platform/turtlebot3/simulation/](http://emanual.robotis.com/docs/en/platform/turtlebot3/simulation/)] | + | |
- | + | ||
- | + | ||
- | + | ||
- | **Utilisation des codes sources pour la partie Gazebo :** | + | |
- | + | ||
- | Les codes sources contiennent deux fichier "gazeboEntity.py" et "simGazebo.py" qui se situent dans le répertoire "program\_gazebo" sur la branche "dev-Yao\_ZHAO". | + | |
- | + | ||
- | **Le fichier** **gazeboEntity.py** **contient les méthodes suivantes:** | + | |
- | + | ||
- | - **●●**** \_\_init\_\_ :** | + | |
- | + | ||
- | La méthode de construction, deux paramètes "model\_name" et "relative\_entity\_name" sont nécessaires. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | model = GazeboEntity("turtlebot3\_burger","world") | + | |
- | + | ||
- | - **●●**** pre\_get\_model\_state :** | + | |
- | + | ||
- | Initialisation des paramètres pour utiliser le service "/gazebo/get\_model\_state", ceci est appelée dans les méthodes get\_position,get\_orientation,get\_linear et get\_angular. | + | |
- | + | ||
- | - **●●**** get\_position :** | + | |
- | + | ||
- | Permet de récupérer la position d'un objet. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | model = GazeboEntity("turtlebot3\_burger","world") | + | |
- | + | ||
- | model.get\_position() | + | |
- | + | ||
- | - **●●**** get\_orientation :** | + | |
- | + | ||
- | Permet de récupérer l'orientation d'un objet. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | model = GazeboEntity("turtlebot3\_burger","world") | + | |
- | + | ||
- | model.get\_orientation() | + | |
- | + | ||
- | - **●●**** get\_linear :** | + | |
- | + | ||
- | Permet de récupérer la vitesse linéaire. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | model = GazeboEntity("turtlebot3\_burger","world") | + | |
- | + | ||
- | model.get\_linear() | + | |
- | + | ||
- | - **●●**** get\_angular :** | + | |
- | + | ||
- | Permet de récupérer la vitesse angulaire. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | model = GazeboEntity("turtlebot3\_burger","world") | + | |
- | + | ||
- | model.get\_angular() | + | |
- | + | ||
- | - **●●**** remove\_entity :** | + | |
- | + | ||
- | Permet de supprimer un objet. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | model = GazeboEntity("turtlebot3\_burger","world") | + | |
- | + | ||
- | model.remove\_entity() | + | |
- | + | ||
- | - **●●**** set\_model\_position :** | + | |
- | + | ||
- | Permet de modifier la position d'un objet, trois paramètres les positions x,y,z sont nécessaires. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | model = GazeboEntity("turtlebot3\_burger","world") | + | |
- | + | ||
- | model.set\_model\_position(2,2,0) | + | |
- | + | ||
- | - **●●**** set\_model\_orientation :** | + | |
- | + | ||
- | Permet de modifier l'orientation d'un objet, trois paramètres les orientations x,y,z sont nécessaires. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | model = GazeboEntity("turtlebot3\_burger","world") | + | |
- | + | ||
- | model.set\_model\_orientation(0,0,-1) | + | |
- | + | ||
- | - **●●**** move\_robot :** | + | |
- | + | ||
- | Permet de faire avancer le turtlebot, une liste contenant une vitesse linéaire et une vitesse angulaire est nécessaire. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | model = GazeboEntity("turtlebot3\_burger","world") | + | |
- | + | ||
- | try: | + | |
- | + | ||
- | model.move\_robot(list) | + | |
- | + | ||
- | except rospy.ROSInterruptException: | + | |
- | + | ||
- | pass | + | |
- | + | ||
- | + | ||
- | + | ||
- | **Le fichier** **simGazebo.py** **contient les méthodes suivantes:** | + | |
- | + | ||
- | - **start :** | + | |
- | + | ||
- | Permet de démarrer une simulation. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | simulateur.start() | + | |
- | + | ||
- | - **●●**** enPause :** | + | |
- | + | ||
- | Permet de mettre en pause la simulation. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | simulateur.enPause() | + | |
- | + | ||
- | - **●●**** resetSimulation :** | + | |
- | + | ||
- | Permet de réinitialiser la simuation (timing, les positions des objets...) | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | simulateur.resetSimulation() | + | |
- | + | ||
- | - **●●**** resetWorld :** | + | |
- | + | ||
- | Permet de réinitialiser le world. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | simulateur.resetWorld() | + | |
- | + | ||
- | - **●●**** getListModel :** | + | |
- | + | ||
- | Permet de récupérer la liste des objet dans le world. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | simulateur.getListModel() | + | |
- | + | ||
- | - **●●**** getSimTime :** | + | |
- | + | ||
- | Permet de récupérer le temps de simulation. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | simulateur.getSimTime() | + | |
- | + | ||
- | - **●●**** loadWorld :** | + | |
- | + | ||
- | Permet de charger un world, une paramètre d'une liste des ficher launcher est nécessaire. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | list = ['/home/yao/catkin\_ws/src/turtlebot3\_simulations/turtlebot3\_gazebo/launch/turtlebot3\_stage\_1.launch'] | + | |
- | + | ||
- | simulateur.loadWorld(list) | + | |
- | + | ||
- | - **●●**** callbackAllProperties :** | + | |
- | + | ||
- | Fonction callback appelé par la fonction _getAllProperties_. | + | |
- | + | ||
- | - **●●**** callbackListModel :** | + | |
- | + | ||
- | Fonction callback appelé par la fonction _getListModelBySuscriber_. | + | |
- | + | ||
- | - **●●**** callbackPose :** | + | |
- | + | ||
- | Fonction callback appelé par la fonction _getAllPose_. | + | |
- | + | ||
- | - **●●**** callbackTwist :** | + | |
- | + | ||
- | Fonction callback appelé par la fonction _getAllTwist_. | + | |
- | + | ||
- | - **●●**** getAllProperties :** | + | |
- | + | ||
- | Permet de récupérer tous les properties de tous les objets de type Suscriber. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | simulateur.getAllProperties() | + | |
- | + | ||
- | - **●●**** getListModelBySuscriber :** | + | |
- | + | ||
- | Permet de récupérer une liste des objets dans le world de type Suscriber. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | simulateur.getListModelBySuscriber() | + | |
- | + | ||
- | - **●●**** getAllPose :** | + | |
- | + | ||
- | Permet de récupérer les positions et les orientations des objets dans le world de type Suscriber. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | simulateur.getAllPose() | + | |
- | + | ||
- | - **●●**** getAllTwist :** | + | |
- | + | ||
- | Permet de récupérer les vitesse des objets dans le world de type Suscriber. | + | |
- | + | ||
- | Exemple d'utilisation: | + | |
- | + | ||
- | simulateur = Simulator() | + | |
- | + | ||
- | simulateur.getAllTwist() | + |