pyCub Documentation
pyCub is iCub humanoid robot simulator written in Python. It uses PyBullet for simulation and Open3D for visualization.
Installation
Requires python3.10 to 3.12
newer python versions are now not supported due to incompatible with some dependencies
We recommend using virtual environment when installing from PyPi or from source
python3 -m venv pycub_venv source pycub_venv/bin/activate OTHER_COMMANDS
(Recommended) Install from PyPi
python3 -m pip install icub_pybullet
Install from source
Pull this repository
cd PATH_TO_THE_REPOSITORY/icub_pybullet python3 -m pip install --upgrade pip python3 -m pip install .
Native Docker (GNU/Linux only)
see Docker Native Version section
VNC Docker
see Docker VNC Version section
Gitpod
open https://gitpod.io/#github.com/rustlluk/pycub and log in with GitHub account
Examples
push_the_ball_pure_joints.py contains an example that shows how to control the robot in joint space
push_the_ball_cartesian.py contains an example that shows how to control the robot in Cartesian space
skin_test.py contains an example with balls falling the robot and skin should turn green on the places where contact occurs. You may want to slow the simulation a little bit to see that :)
Information
documentation can be found at https://lukasrustler.cz/pyCub/documentation or in pycub.pdf
presentation with description of functionality can be found at pycub presentation
simulator code is in pycub.py
it uses PyBullet for simulation and provides high-level interface
visualization code in visualizer.py
it uses Open3D for visualization as it is much more customizable than PyBullet default GUI
FAQ
You get some kind of error with the visualization, e.g., segmentation fault.
Try to check graphics mesa/opengl/nvidia drivers as those are the most common source of problems for the openGL visualization
Try Native Docker
In given config your load set in GUI standard=False; web=True to enable web visualization
Try VNC Docker
Try Gitpod Docker
You get import errors, e.g. cannot load pycub from icub_pybullet
Install from pip with
python3 -m pip install icub_pybulletInstall the package correctly with
python3 -m pip install .from icub_pybullet directory of this repositoryput icub_pybullet directory to your PYTHONPATH
Docker
Native Version
version with native GUI; useful when you have problems with OpenGL (e.g., usually some driver issues)
only for GNU/Linux systems (Ubuntu, Mint, Arch, etc.)
install docker-engine (DO NOT INSTALL DOCKER DESKTOP)
perform post-installation steps
Build/Pull the Docker Image
clone this repository
cd SOME_PATH git clone https://github.com/rustlluk/pyCub.git
pull the docker image (see Parameters for more parameters)
cd SPATH_TO_THE_REPOSITORY/Docker ./deploy.py -p PATH_TO_THE_REPOSITORY -c pycub -pu
or, build the docker (see Parameters for more parameters)
cd SOME_PATH/pycub_ws/Docker ./deploy.py -p PATH_TO_THE_REPOSITORY -c pycub -b
after you pull or build the container, you can run it next time as
./deploy.py -c pycub -e
if you want to open new terminal in existing container, run
./deploy.py -c pycub -t
VNC Version
this version works also on Windows and MacOS because it uses VNC server to show the GUI, i.e., the output will be shown on http://localhost:6080
Install docker-engine (GNU/Linux only) or docker-desktop (all systems)
perform post-installation steps
The same as for Native Version, but use
-vncoption, e.g., to pull and run the imagecd PATH_TO_THE_REPOSITORY/Docker ./deploy.py -p PATH_TO_THE_REPOSITORY -c pycub -pu -vnc
run
start-vnc-sessions.shscript in the container
Docker + PyCharm
Native Version:
You have two option:
Either run pycharm from docker
Open your pycharm on your host machine:
add ssh interpreter
user docker
ip can be localhost or ip where you run the docker
port 2222
uncheck automatic upload to remote folder
change remote path to /home/docker/pycub_ws
#### VNC/Gitpod version
open pycharm from inside the container
Deploy Parameters
cdto folder with Dockerfile./deploy.py-bor--buildwhen buildingdefault: False
-eif you just want to run existing docker without buildingdefault: False
-por--pathwith path to current folderdefault: “”
-puor--pullto pull the image from dockerhubdefault: False
-cor--containerwith desired name of the new, created containerdefault: my_new_docker
-tor--terminalto run new terminal in running docker sessiondefault: False
-pvor--python-versionto specify addition python version to installdefault: 3.11
-pcvor--pycharm-versionto specify version of pycharm to usedefault: 2023.2.3
-bior--base-imageto specify base image that will be useddefault: ubuntu:20.04
other can be found at hub.docker.com
Do this on computer where you will run the code. If you have a server you have to run it on the server over SSH to make things work properly.
Docker FAQ
you get error of not being in sudo group when running image
check output of
id -ucommand. If the output is not 1000 you have to build the image by yourself and can not pull itthis happens when your account is not the first one created on your computer
``sudo apt install something`` does not work
you need to run
sudo apt updatefirst after you run the container for the first timeapt things are removed in Dockerfile, so it does not take unnecessary space in the image
Known bugs
visualization with skin dies after ~65k steps
License
` .. image:: https://img.shields.io/badge/License-CC%20BY%204.0-lightgrey.svg
- target:
https://img.shields.io/badge/License-CC%20BY%204.0-lightgrey.svg
- alt:
CC BY 4.0
This work is licensed under a Creative Commons Attribution 4.0 International License.
` .. image:: https://i.creativecommons.org/l/by/4.0/88x31.png
- target:
- alt:
CC BY 4.0
Exercises
icub_pybullet
- pyCub
EndEffectorJointLinkpyCubpyCub.bbox_overlap()pyCub.compute_jacobian()pyCub.compute_skin()pyCub.contactPointspyCub.create_urdf()pyCub.dynamicsInfopyCub.find_joint_id()pyCub.find_link_id()pyCub.find_processes_by_name()pyCub.get_camera_depthimages()pyCub.get_cameraimages()pyCub.get_chains()pyCub.get_joint_state()pyCub.init_robot()pyCub.init_urdfs()pyCub.is_alive()pyCub.jointInfopyCub.jointStatespyCub.kill_open3d()pyCub.linkInfopyCub.motion_done()pyCub.move_cartesian()pyCub.move_position()pyCub.move_velocity()pyCub.prepare_log()pyCub.print_collision_info()pyCub.run_vhacd()pyCub.scale_bbox()pyCub.stop_robot()pyCub.toggle_gravity()pyCub.update_simulation()pyCub.visualShapeDatapyCub.wait_motion_done()
- utils
- visualizer
VisualizerVisualizer.EyeWindowVisualizer.EyeWindow.MENU_IDSVisualizer.EyeWindow.POSITIONSVisualizer.EyeWindow.get_depth_image()Visualizer.EyeWindow.get_image()Visualizer.EyeWindow.on_close()Visualizer.EyeWindow.on_mouse()Visualizer.EyeWindow.save_depth_image()Visualizer.EyeWindow.save_image()Visualizer.EyeWindow.saveimages()Visualizer.EyeWindow.unproject()
Visualizer.MenuCallbackVisualizer.find_xyz_rpy()Visualizer.read_info()Visualizer.render()Visualizer.show_first()Visualizer.show_mesh()