====== Humanoid robot programming ====== The first part of the subject aims to get you acquainted with programming of a humanoid robot. We will use a [[https://github.com/rustlluk/pycub|Python simulator]] of humanoid robot [[https://icub.iit.it|iCub]]. ===== Gaze ===== The exercise is to make the robot move to look at the ball using the information about the mutual angle of head-ball and gaze vectors. The exercise is constrained to be in "2D" by moving the neck pitch so that the gaze vector and vector from ball to head are in the same plane. It can be solved by moving one joint only. Template and config can be downloaded here: {{ :courses:hro:tutorials:gaze.zip |}}. PyBullet documentation can be useful and can be found [[https://docs.google.com/document/d/10sXEhzFRSnvFcl3XxNGhnD4N2SedqwdAvK3dsihxVUA/edit?pli=1#heading=h.2ye70wns7io3|here.]] ===== iCub Kinematics ===== This picture shows the joints of iCub with their names and indexes that can be used to control the robot in joint space in the PyCub simulator. {{ :courses:hro:tutorials:icub_joints.png?direct&600 |}} ===== PyCub ===== The simulator is written in Python3 and uses PyBullet as a physics engine and Open3D for visualization. It should run without problem on any system with Python3 (it is tested in Python3.11; anything over 3.8 should be fine; the theoretical limit is 3.6 because of f-strings). The whole documentation can be found [[https://lukasrustler.cz/pycub|here]]. A presentation with a description of basic functionality can be found [[https://lukasrustler.cz/pycub/pyCub_presentation.pdf|here]]. ==== Installation ==== Installation instructions can be found on [[https://github.com/rustlluk/pycub|Github]] or this [[https://lukasrustler.cz/pycub/pyCub_presentation.pdf|presentation]]. But basically, you need to clone the [[https://github.com/rustlluk/pycub|repository]] and install dependencies: numpy, scipy, pybullet, open3d (and their dependencies). ==== Alternative installation (Docker) ==== You can also use a Docker container with all dependencies installed. You can use instruction on [[https://github.com/rustlluk/pycub|Github]] for PyCub specific docker, or you can use our [[courses:hro:tutorials:docker|HRO Docker]]. Our HRO Docker contains all you will need during the semester. ==== Alternative installation (Gitpod) ==== If you want to use cloud-based solution, you can easily open [[https://gitpod.io/#github.com/rustlluk/B3M33HRO-gitpod|this link]]. You will get a cloud version of our Docker, that is ready to use in your browser. ==== Alternative installation (Lab computers) ==== === Python only === * clone the repository to your home directory ''git clone https://github.com/rustlluk/pycub'' * create venv and install dependencies ''cd pyCub && mkdir venv && cd venv && virtualenv . && source bin/activate && pip3 install numpy scipy pybullet open3d'' * add ''export PYTHONPATH=$PYTHONPATH:/home.nfs/your_ctu_username/pyCub/icub_pybullet'' to ~/.bashrc You will need to run ''source /home.nfs/your_ctu_username/pyCub/venv/bin/activate'' every time you open new terminal === Docker (bit of a workaround, but should work)=== * clone the repository to your home directory ''git clone https://github.com/rustlluk/pycub'' * create new file set_env.bash in your home directory with this inside (with new line between each command): '' #!/bin/bash unset LD_LIBRARY_PATH export GRASPIT=/home/docker/.graspit source /home/docker/ros_ws/devel/setup.bash export PYTHONPATH=$PYTHONPATH:/home.nfs/your_ctu_username/pyCub/icub_pybullet'' * make it executable ''chmod +x /home.nfs/your_ctu_username/set_env.bash'' * ssh to one of our GPU servers ''ssh your_ctu_username@taylor.felk.cvut.cz'' * pull the image using singularity ''singularity pull docker:/ /b3m33hro/labs:local'' **There should not be a space between the two / /** * exit the ssh connection ''exit'' * run the container ''singularity run --nv labs-local.img'' (there are two - - without a space before nv) * run ''/home.nfs/your_ctu_username/set_env.bash'' * you will have to run this everytime you open a new signularity terminal (probably)