-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Edit the robot look or behavour | ||
|
||
The behaviour of your robot is described in a configuration file that tells: | ||
* its list of actuators (motors) | ||
* its list of sensors | ||
|
||
If you need to customize your robot (e.g. add a new motor) you will need to edit this configuraiton file so that Pypot knows your change and allows you to take control over your new component. | ||
|
||
This is an advanced technique and may break your robot software, be careful (fortunately you can always go back). | ||
|
||
First open the configuration file: | ||
|
||
### If your robot is running a Raspberry Pi | ||
Connect to your robot through SSH and open the configuration file of your robot: | ||
|
||
```bash | ||
ssh [email protected] # Use password "poppy" | ||
nano ~/dev/poppy_ergo_jr/poppy_ergo_jr.py | ||
``` | ||
|
||
You can now edit it (see below). | ||
|
||
### If your robot is connected to your computer in USB | ||
In that case your own computer is driving the motors, in that case you can either: | ||
* provide a new configuration file by using `r = pypot.from_json("path/to/my/configuration/file.json")` instead of `r = PoppyTorso()` (only for Python users) | ||
* edit the configuration file of the Python library of your robot. This path is different according to the way you installed the software. Some Linux users may find it in `~/.local/lib/python3.9/site-packages/poppy_ergo_jr/configuration/poppy_ergo_jr.json` | ||
|
||
## Add a new motor | ||
|
||
Add the following fields and customize the name, model, id, and limits of your added motor: | ||
|
||
```json | ||
"motors": { | ||
"my_custom_motor": { | ||
"offset": 0.0, | ||
"type": "XL-320", | ||
"id": 90, | ||
"angle_limit": [ | ||
-150.0, | ||
150.0 | ||
], | ||
"orientation": "direct" | ||
}, | ||
"m1": { | ||
[...] | ||
``` | ||
|
||
Make sure you do not make any syntax error and save your file. Then your new motor will be controlled as any other motor in pypot. | ||
|
||
## Add a sensor | ||
|
||
Here, we are showing how to enable **human face detection** via the primitive `face_detector` that is already implemented in your robot but not enabled by default (because it uses CPU): | ||
|
||
```json | ||
"sensors": { | ||
"face_detector": { | ||
"type": "FaceDetector", | ||
"cameras": ["camera"], | ||
"freq": 1.0, | ||
"cascade": "/home/poppy/pyenv/lib/python3.7/site-packages/cv2/data/haarcascade_frontalface_alt.xml", | ||
"need_robot" : true | ||
}, | ||
"marker_detector": { | ||
[..] | ||
``` | ||
|
||
Then restart your robot. The primitive is now usable in Python via `poppy.face_detector` like any other primitive. | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Changer le look ou le comportement du robot | ||
|
||
Le comportement de votre robot est décrit dans un fichier de configuration qui indique : | ||
* La liste de ses actuateurs (moteurs) | ||
* La liste de ses capteurs | ||
|
||
Si vous avez besaoin de personnaliser votre robot vous devrez modifier ce fichier de configuration pour que Pypot ait connaissance de votre modification et vous permettre d'accéder à votre nouveau composant, tel qu'un nouveau moteur. | ||
|
||
C'est une technique avancée et cela pourrait mettre en panne votre logiciel de robot, donc faites attention. Heureusement vous povuez toujours revenir en arrière. | ||
|
||
D'abord ouvrez le fichier de configuration : | ||
|
||
### Si votre robot fonctionne avec une Raspberry Pi | ||
Connectez-vous au robot via SSH et ouvrez le fichier : | ||
|
||
```bash | ||
ssh [email protected] # Utilisez le mot de passe "poppy" | ||
nano ~/dev/poppy_ergo_jr/poppy_ergo_jr.py | ||
``` | ||
|
||
Vous pouvez maintenant l'éditer (voir ci-dessous) | ||
|
||
### Si votre robot est connecté à votre ordinateur en USB | ||
Dans ce cas vous pouvez soit: | ||
* fournir un fichier de configuration en Python avec `r = pypot.from_json("path/to/my/configuration/file.json")` au lieu de l'habituel `r = PoppyTorso()` | ||
* changer le fichier de configuraiton qui se trouve sur votre ordinateur. Son chemin est différent selon la façon dont vous avez installé votre logiciel. Certains utilisateurs Linux pourraient le trouver ici par exemple : `~/.local/lib/python3.9/site-packages/poppy_ergo_jr/configuration/poppy_ergo_jr.json` | ||
|
||
## Ajouter un nouveau moteur | ||
|
||
Ajoutez les champs suivants à votre fichier de configuration : nom, modèle, identifiant et limites (en dégrés) de votre nouveau moteur : | ||
|
||
```json | ||
"motors": { | ||
"my_custom_motor": { | ||
"offset": 0.0, | ||
"type": "XL-320", | ||
"id": 90, | ||
"angle_limit": [ | ||
-150.0, | ||
150.0 | ||
], | ||
"orientation": "direct" | ||
}, | ||
"m1": { | ||
[...] | ||
``` | ||
|
||
Attention à ne pas faire d'erreur de syntaxe, puis enregistrez le fichier. Ensuite votre moteur sera accessible comme n'importe quel autre dans pypot. | ||
|
||
## Ajouter un capteur | ||
|
||
Ici, nous vous montrons comment activer la **détection de visage humain** via la primitive `face_detector` qui existe déjà dans votre robot mais jamais activée par défaut (car elle consomme beaucoup de CPU) : | ||
|
||
```json | ||
"sensors": { | ||
"face_detector": { | ||
"type": "FaceDetector", | ||
"cameras": ["camera"], | ||
"freq": 1.0, | ||
"cascade": "/home/poppy/pyenv/lib/python3.7/site-packages/cv2/data/haarcascade_frontalface_alt.xml", | ||
"need_robot" : true | ||
}, | ||
"marker_detector": { | ||
[..] | ||
``` | ||
|
||
Ensuite redémarrez votre robot. La primitive est maintenant utilisable en Python via `poppy.face_detector` comme n'importe quelle autre primitive. | ||
|
||
|
||
|
||
|