icub_pybullet.pycub
The main class and utils for pyCub simulator
- Author:
Lukas Rustler
Classes
Container describing a movable PyBullet robot joint and its active control target. |
|
Container mapping a robot link name to its PyBullet and URDF indices. |
|
Client class which inherits from BulletClient and contains the whole simulation functionality |
|
Helper representing the configured end-effector link of the robot. |
Functions
|
Register a custom visualizer factory (e.g. EmbeddedVisualizerProxy in the standalone desktop app). |
|
Return the currently registered custom visualizer factory, or |
|
Register an optional status callback receiving (stage, message) updates (e.g. during dynamic VHACD). |
Module Contents
- icub_pybullet.pycub.set_visualizer_factory(factory: Callable[[pyCub], Any] | None) None
Register a custom visualizer factory (e.g. EmbeddedVisualizerProxy in the standalone desktop app).
- icub_pybullet.pycub.get_visualizer_factory() Callable[[pyCub], Any] | None
Return the currently registered custom visualizer factory, or
None.
- icub_pybullet.pycub.set_status_callback(callback: Callable[[str, str], None] | None) None
Register an optional status callback receiving (stage, message) updates (e.g. during dynamic VHACD).
- class icub_pybullet.pycub.Joint(name: str, robot_joint_id: int, joints_id: int, lower_limit: float, upper_limit: float, max_force: float, max_velocity: float)
Container describing a movable PyBullet robot joint and its active control target.
- name
- robot_joint_id
- joints_id
- lower_limit
- upper_limit
- max_force
- max_velocity
- set_point = None
- start_time = None
- timeout = None
- class icub_pybullet.pycub.Link(name: str, robot_link_id: int, urdf_link: int)
Container mapping a robot link name to its PyBullet and URDF indices.
- name
- robot_link_id
- urdf_link
- class icub_pybullet.pycub.pyCub(config: str | None = 'default.yaml')
Client class which inherits from BulletClient and contains the whole simulation functionality
- jointInfo
- jointStates
- linkInfo
- contactPoints
- dynamicsInfo
- visualShapeData
- parent_name
- file_dir
- config_path = b'.'
- config_dir
- config
- logger
- gravity = False
- urdf_path = b'.'
- urdfs
- other_objects = []
- free_objects = []
- IK_config
- end_effector
- last_step
- last_log
- joint_tolerance
- neighbour_links
- collision_during_motion = False
- steps_done = 0
- precomputed_link_ids
- property rtb_robot
Lazily constructed Robotics Toolbox
Robotmodel used for Jacobian queries.
- static get_chains() Tuple[dict, dict]
Return link and joint definitions for each kinematic chain on iCub.
- compute_jacobian(chain: icub_pybullet.utils.CHAINS, start: str | None = None, end: str | None = None) Tuple[numpy.array, numpy.array]
Compute the base-frame geometric Jacobian and active joint names for a kinematic chain.
- Parameters:
chain – Kinematic chain identifier (e.g.
"right_arm").start – Optional base link name; defaults to the first link in
chain.end – Optional tip link name; defaults to the last link in
chain.
- get_camera_images(eyes: str | List[str] | None = None) dict
Return the latest RGB arrays keyed by eye name. Omit eyes for all open eye views.
- get_camera_depth_images(eyes: str | List[str] | None = None) dict
Return the latest depth arrays keyed by eye name. Omit eyes for all open eye views.
- find_processes_by_name() List[int]
Return the current process ID (legacy helper preserved for compatibility).
- kill_open3d() None
Cleanly terminate only the current process if Open3D hangs on exit, never parent/sibling processes.
- init_robot() Tuple[int, List[Joint], List[Link]]
Load the iCub URDF into PyBullet and build
JointandLinklists.
- init_urdfs() None
Load URDFs / .obj files of scene objects (supports both built-in meshes and user custom meshes).
- is_alive() bool
Return True while the PyBullet client (and GUI, if enabled) remain active.
- update_simulation(sleep_duration: float | None | None = -1) None
Advance physics when the interval in seconds has elapsed and refresh the visualizer.
Use -1 for the configured step interval or None to step on every call.
- toggle_gravity() None
Toggle simulated gravity between Earth standard (-9.81 m/s^2) and zero-G.
- static scale_bbox(bbox: list, scale: float) Tuple[numpy.array, numpy.array]
Scale an axis-aligned bounding box
(min, max)about its center.
- static bbox_overlap(b1_min: list, b1_max: list, b2_min: list, b2_max: list) bool
Return True when two axis-aligned 3D bounding boxes overlap.
- compute_skin() None
Update simulated tactile skin taxel activations from current PyBullet contacts.
- prepare_log() str
Serialize current timestamp, step count, joint angles, and skin state into a CSV row.
- move_position(joints: icub_pybullet.utils.JOINTS | List[icub_pybullet.utils.JOINTS] | icub_pybullet.utils.JOINTS_IDS | List[icub_pybullet.utils.JOINTS_IDS], positions: float | List[float], wait: bool | None = True, velocity: float | None = 1, set_col_state: bool | None = True, check_collision: bool | None = True, timeout: float | None = None) None
Move one joint or a list of joints to target angles in radians.
- Parameters:
joints – Joint name or ID, or a list of joints to move together.
positions – Target angle in radians for each joint, in the same order.
wait – Step the simulation until the movement finishes.
velocity – Maximum joint speed in radians per second.
set_col_state – Clear the collision flag at the start of this move.
check_collision – Check for collisions while waiting for the move.
timeout – Maximum motion time in seconds, or None for no time limit.
- move_velocity(joints: icub_pybullet.utils.JOINTS | List[icub_pybullet.utils.JOINTS] | icub_pybullet.utils.JOINTS_IDS | List[icub_pybullet.utils.JOINTS_IDS], velocities: float | List[float]) None
Command one or more joint velocities in radians per second, in joint order.
- get_joint_state(joints: icub_pybullet.utils.JOINTS | List[icub_pybullet.utils.JOINTS] | icub_pybullet.utils.JOINTS_IDS | List[icub_pybullet.utils.JOINTS_IDS] | None = None, allow_error: bool | None = False) List[list]
Read positions in radians in the requested order, defaulting to all joints.
- motion_done(joints: icub_pybullet.utils.JOINTS | List[icub_pybullet.utils.JOINTS] | icub_pybullet.utils.JOINTS_IDS | List[icub_pybullet.utils.JOINTS_IDS] | None = None, check_collision=True) bool
Return True when all specified joints reached their targets, timed out, or hit a collision.
- Parameters:
joints – Joint name/ID or list of joints to check; defaults to all robot joints.
check_collision – Abort and return True if an unexpected contact occurs.
- wait_motion_done(sleep_duration: float | None = 0.01, check_collision: bool | None = True) None
Block while stepping the simulation until
motion_donereturns True.
- stop_robot(joints: icub_pybullet.utils.JOINTS | List[icub_pybullet.utils.JOINTS] | icub_pybullet.utils.JOINTS_IDS | List[icub_pybullet.utils.JOINTS_IDS] | None = None) None
Halt active position or velocity commands for
joints(or all joints).
- move_cartesian(pose: icub_pybullet.utils.Pose, wait: bool | None = True, velocity: float | None = 1, check_collision: bool | None = True, timeout: float | None = None) None
Move the end effector to a pose using inverse kinematics.
Velocity limits joint speed in radians per second. With wait=False, call update_simulation to advance the motion.
- find_joint_id(joint_name: icub_pybullet.utils.JOINTS | icub_pybullet.utils.JOINTS_IDS) Tuple[int, int]
Resolve a joint name or index to
(pybullet_joint_id, joints_list_index).
- find_link_id(mesh_name: str, robot: int | None = None, urdf_name: str | None = 'robot') int
Find the PyBullet link index whose collision shape uses
mesh_name.
- run_vhacd(robot: bool | None = True) None
Run VHACD on loaded URDF objects using pre-baked meshes when present, or writing newly generated collision meshes and patched URDFs into the writable user cache directory.
- create_urdf(object_path: str, fixed: bool, color: List[float], suffix: str | None = '', obj_name: str | None = None) str
Create a URDF for a given .obj file inside the writable user cache directory (safe on read-only installs and safe under concurrent multi-instance execution).
- print_collision_info(c: list | None = None)
Log details for a single PyBullet contact record or all active robot contacts.