====== 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]]. ==== Lab 1 ==== PyBullet documentation can be useful and can be found [[https://docs.google.com/document/d/10sXEhzFRSnvFcl3XxNGhnD4N2SedqwdAvK3dsihxVUA/edit?pli=1#heading=h.2ye70wns7io3|here.]] === Installation === * Using venv is suggested: ''python3 -m venv pycub_venv && source pycub_venv/bin/activate'' and then * On Linux (and possibly windows) the best way is probably to just do: ''python3 -m pip install icub_pybullet'' * Alternatively, ''git clone https://github.com/rustlluk/pyCub.git'', ''cd pyCub/icub_pybullet'' and ''python3 -m pip install .'' * In theory, you do not need to install it. All HWs should work without installation, if you run then from the correct folder. You need to install dependencies by hand, though * MACs with ARM procesors may have problems with installing open3d. You can either: * Install open3d from source. Check [[https://github.com/rustlluk/pyCub/blob/master/Docker/Dockerfile|https://github.com/rustlluk/pyCub/blob/master/Docker/Dockerfile]] and [[https://www.open3d.org/docs/release/arm.html|https://www.open3d.org/docs/release/arm.html]] * Use VNC Docker[[https://github.com/rustlluk/pyCub/tree/master?tab=readme-ov-file#vnc-version|VNC Docker]] * Use Gitpod (ONA). Use gitpod. Open https://app.gitpod.io/#https://github.com/rustlluk/pycub (you will need github account). The first run can take some time, but after that you should see an environment inside a virtualized system. The performance is not great, but if you change simulation speed (in client.update_simulation(time)) it is fine. t = 0.025 seems to work okay. The code is already downloaded and installed in /home/gitpod/pycub * you will be asked to select web interface or to open using plugins to vscode or PyCharm * Use lab computers With python3.8 (and maybe 3.9) you need to call ''python3 -m pip install --upgrade pip'' and ''python3 -m pip install -U --trusted-host www.open3d.org -f http://www.open3d.org/docs/latest/getting_started.html open3d'' before running pip install. Copying from this tends to change two dashes (-) after each other as a long dash, update it in the terminal then. More info can be found on [[https://github.com/rustlluk/pycub|Github]] or this [[https://lukasrustler.cz/pycub/pyCub_presentation.pdf|presentation]]. If you have errors with "Index out of range" on windows, please reinstall the library. To test whether everything works fine run ''python3 -m icub_pybullet.examples.push_the_ball_cartesian'' and you should see robot hitting a ball from a table. The first run can take a long time because of VHACD meshes creation. == Lab Computers == The computers in the lab should be powerful enough to run the code. You can install the same way (create venv, install icub_pybullet from pip). When turning on the lab computers you need to select Linux Bookworm (13133, ...) and then log in with CTU username and password === Running bugs solutions === * Use Python 3.8-3.12 * if you are using conda (or similar) install the packages using 'conda install ...' and not 'python -m pip install ...'. These two are not the even though it may look like it * do not use conda (use python venv or install into global environment). Be sure to do 'conda deactivate' first * if you use IDE (pycharm, vscode) try to run it also in normal terminal outside the IDE. IDEs sometimes replace system variables which can cause problems with graphical things * use open3D web visualizer. Set gui.web in config to True (and gui.standard to False) === 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 lower limit is 3.6 because of f-strings and upper limit 3.12 because some dependencies). 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/documentation/pycub_presentation.pdf|here]].