icub_pybullet.kid_api
High-level beginner-friendly Python API for pyCub (“Kid Programming” & “Scratch” Blockly runtime).
Allows students to control iCub with intuitive one-line commands without writing simulation loops or radian conversions, both inside the standalone desktop app (Modes 2 & 3) and when executed directly as a standard .py script.
Exceptions
Raised cooperatively to stop a running Kid Scratch / Kid Programming script immediately. |
Classes
Controller binding kid_api functions either to a managed step-callback (inside the |
Functions
|
Return the active KidRobot controller (lazily starting with_ball.yaml if run standalone). |
|
Wave using the left or right arm. |
|
Wave using the left arm. |
|
Wave using the right arm. |
|
Raise both arms to their preset positions. |
|
Lower both arms to their preset positions. |
|
Center the neck joints. |
|
Return the torso to its neutral position. |
|
Return the robot to its starting pose. |
|
Stop current joint movements. |
|
Raise the selected shoulder. |
|
Lower the selected shoulder. |
|
Move the selected arm away from the torso. |
|
Move the selected arm toward the torso. |
|
Rotate the selected upper arm. |
|
Bend the selected elbow. |
|
Extend the selected elbow. |
|
Rotate the selected wrist. |
|
Turn the head about the neck yaw axis. |
|
Tilt the head upward. |
|
Tilt the head downward. |
|
Tilt the head to the side. |
|
Rotate the torso about its yaw axis. |
|
Bend the torso forward. |
|
Bend the torso backward. |
|
Tilt the torso to the side. |
|
Move a joint to an absolute angle. |
|
Move a joint relative to its current angle. |
|
Read the current joint angle in degrees. |
|
Pause the program for the given number of seconds while the simulation runs. |
|
Read the distance between the ball and the table in centimetres. |
|
Read whether the robot has touched the ball. |
|
Read the ball hit count from the active controller. |
|
Read whether any enabled skin sensor is registering contact. |
Module Contents
- exception icub_pybullet.kid_api.KidScriptStopped
Raised cooperatively to stop a running Kid Scratch / Kid Programming script immediately.
- class icub_pybullet.kid_api.KidRobot(client, step_fn: Callable[[], None] | None = None, stop_event: threading.Event | None = None, highlight_cb: Callable[[str], None] | None = None, telemetry_getter: Callable[[], Dict[str, object]] | None = None)
Controller binding kid_api functions either to a managed step-callback (inside the interactive simulation worker) or to a standalone pyCub client instance.
- client
- check_stop() None
Raise
KidScriptStoppedwhen cancellation is requested or the simulator closes.
- highlight_block(block_id: str) None
Notify the Blockly editor which block is executing and yield briefly.
- move_joint(joint_name: str, target_degrees: float, speed: float = 1.5) None
Move a named joint to an absolute angle in degrees.
- jog_joint(joint_name: str, delta_degrees: float, speed: float = 1.5) None
Move a named joint relatively by delta_degrees.
- get_joint(joint_name: str) float
Return the current angle of joint_name in degrees.
- wave(side: str = 'right') None
Wave with the ‘right’ or ‘left’ arm.
- both_arms_up() None
Raise both arms to their preset positions.
- both_arms_down() None
Lower both arms to their preset positions.
- look_center() None
Center the neck joints.
- stand_straight() None
Return the torso to its neutral upright posture.
- reset_pose() None
Return all body joints to their configured initial angles.
- stop() None
Stop all current joint movements.
- shoulder_up(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Raise the selected shoulder by
degrees.
- shoulder_down(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Lower the selected shoulder by
degrees.
- shoulder_out(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Move the selected arm away from the torso by
degrees.
- shoulder_in(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Move the selected arm toward the torso by
degrees.
- rotate_arm(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Rotate the selected upper arm by
degrees.
- bend_elbow(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Bend the selected elbow by
degrees.
- straighten_elbow(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Extend the selected elbow by
degrees.
- rotate_wrist(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Rotate the selected wrist by
degrees.
- turn_head(degrees: float = 15.0, speed: float = 1.5) None
Turn the head about the neck yaw axis by
degrees.
- look_up(degrees: float = 15.0, speed: float = 1.5) None
Tilt the head upward by
degrees.
- look_down(degrees: float = 15.0, speed: float = 1.5) None
Tilt the head downward by
degrees.
- tilt_head(degrees: float = 15.0, speed: float = 1.5) None
Tilt the head sideways by
degrees.
- turn_body(degrees: float = 15.0, speed: float = 1.5) None
Rotate the torso about its yaw axis by
degrees.
- bend_forward(degrees: float = 15.0, speed: float = 1.5) None
Bend the torso forward by
degrees.
- bend_back(degrees: float = 15.0, speed: float = 1.5) None
Bend the torso backward by
degrees.
- bend_sideways(degrees: float = 15.0, speed: float = 1.5) None
Tilt the torso sideways by
degrees.
- wait(seconds: float = 1.0) None
Pause script execution for seconds while keeping physics running.
- ball_distance() float
Distance of the ball from the table in cm (0.0 if on table or no ball).
- ball_touched() bool
True if the robot has touched the ball in the current run.
- ball_hits() int
Number of times the robot hit the ball in the current run.
- skin_touched() bool
True if tactile skin is enabled and currently registering contact.
- icub_pybullet.kid_api.get_robot() KidRobot
Return the active KidRobot controller (lazily starting with_ball.yaml if run standalone).
- icub_pybullet.kid_api.wave(side: str = 'right') None
Wave using the left or right arm.
- Parameters:
side – Arm to use (“left” or “right”).
- icub_pybullet.kid_api.left_wave() None
Wave using the left arm.
- icub_pybullet.kid_api.right_wave() None
Wave using the right arm.
- icub_pybullet.kid_api.both_arms_up() None
Raise both arms to their preset positions.
- icub_pybullet.kid_api.both_arms_down() None
Lower both arms to their preset positions.
- icub_pybullet.kid_api.look_center() None
Center the neck joints.
- icub_pybullet.kid_api.stand_straight() None
Return the torso to its neutral position.
- icub_pybullet.kid_api.reset_pose() None
Return the robot to its starting pose.
- icub_pybullet.kid_api.stop() None
Stop current joint movements.
- icub_pybullet.kid_api.shoulder_up(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Raise the selected shoulder.
- Parameters:
side – Arm to use (“left” or “right”).
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.shoulder_down(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Lower the selected shoulder.
- Parameters:
side – Arm to use (“left” or “right”).
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.shoulder_out(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Move the selected arm away from the torso.
- Parameters:
side – Arm to use (“left” or “right”).
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.shoulder_in(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Move the selected arm toward the torso.
- Parameters:
side – Arm to use (“left” or “right”).
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.rotate_arm(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Rotate the selected upper arm.
- Parameters:
side – Arm to use (“left” or “right”).
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.bend_elbow(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Bend the selected elbow.
- Parameters:
side – Arm to use (“left” or “right”).
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.straighten_elbow(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Extend the selected elbow.
- Parameters:
side – Arm to use (“left” or “right”).
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.rotate_wrist(side: str = 'right', degrees: float = 15.0, speed: float = 1.5) None
Rotate the selected wrist.
- Parameters:
side – Arm to use (“left” or “right”).
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.turn_head(degrees: float = 15.0, speed: float = 1.5) None
Turn the head about the neck yaw axis.
- Parameters:
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.look_up(degrees: float = 15.0, speed: float = 1.5) None
Tilt the head upward.
- Parameters:
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.look_down(degrees: float = 15.0, speed: float = 1.5) None
Tilt the head downward.
- Parameters:
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.tilt_head(degrees: float = 15.0, speed: float = 1.5) None
Tilt the head to the side.
- Parameters:
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.turn_body(degrees: float = 15.0, speed: float = 1.5) None
Rotate the torso about its yaw axis.
- Parameters:
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.bend_forward(degrees: float = 15.0, speed: float = 1.5) None
Bend the torso forward.
- Parameters:
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.bend_back(degrees: float = 15.0, speed: float = 1.5) None
Bend the torso backward.
- Parameters:
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.bend_sideways(degrees: float = 15.0, speed: float = 1.5) None
Tilt the torso to the side.
- Parameters:
degrees – Change from the current angle, in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.move_joint(joint_name: str, target_degrees: float, speed: float = 1.5) None
Move a joint to an absolute angle.
- Parameters:
joint_name – Simulator joint name, such as neck_pitch.
target_degrees – Absolute target angle in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.jog_joint(joint_name: str, delta_degrees: float, speed: float = 1.5) None
Move a joint relative to its current angle.
- Parameters:
joint_name – Simulator joint name, such as neck_pitch.
delta_degrees – Signed change in degrees.
speed – Maximum joint speed in radians per second.
- icub_pybullet.kid_api.get_joint(joint_name: str) float
Read the current joint angle in degrees.
- Parameters:
joint_name – Simulator joint name, such as neck_pitch.
- icub_pybullet.kid_api.wait(seconds: float = 1.0) None
Pause the program for the given number of seconds while the simulation runs.
- icub_pybullet.kid_api.ball_distance() float
Read the distance between the ball and the table in centimetres.
- icub_pybullet.kid_api.ball_touched() bool
Read whether the robot has touched the ball.
- icub_pybullet.kid_api.ball_hits() int
Read the ball hit count from the active controller.
- icub_pybullet.kid_api.skin_touched() bool
Read whether any enabled skin sensor is registering contact.