PositionController package
PositionController.move_head module
move_head.py
This script controls the head movement of the iCub humanoid robot. It demonstrates how to retrieve the position controller for the head, define joint poses, and execute basic head movements.
Usage:
Run this script to move the iCub’s head to an “up” position and then return it to the “home” position.
- PositionController.move_head.move_head()
Moves the iCub’s head to the “up” position and then back to the “home” position.
Steps:
Move the head to the up position.
Move the head back to the home position.
Example:
>>> move_head()
Notes:
The head’s movement is managed by a position controller.
The function uses predefined JointPose objects to specify joint configurations.
This script is useful for verifying that the head position controller is functioning correctly.
PositionController.move_head_timeout module
move_head_timeout.py
This script controls the head movement of the iCub humanoid robot with a timeout feature. It demonstrates how to retrieve the position controller for the head, define joint poses, and execute timed head movements with a specified timeout.
Usage:
Run this script to move the iCub’s head to an “up” position and then return it to the “home” position within a specific timeout period.
- PositionController.move_head_timeout.move_head_with_timeout(req_time: float = 1.0, timeout: float = 0.5)
Moves the iCub’s head to the “up” position and then back to the “home” position within a specified timeout.
Parameters
- req_timefloat, optional
The requested time (in seconds) for the motion to complete. Default is 1.0 seconds.
- timeoutfloat, optional
The maximum time allowed (in seconds) for the motion to complete before timeout occurs. Default is 0.5 seconds.
Steps
Move the head to the up position within the requested time.
If the movement does not complete within the timeout period, it stops.
Move the head back to the home position with the same timeout settings.
Example
>>> move_head_with_timeout(req_time=1.0, timeout=0.5)
Notes
The timeout ensures that the robot does not get stuck in an unfinished movement.
The req_time is the expected duration for the motion to complete.
If timeout is exceeded, the motion is forcefully stopped.
PositionController.move_parallel module
move_parallel.py
This script controls both the head and torso movements of the iCub humanoid robot simultaneously. It demonstrates how to retrieve position controllers for multiple parts, define joint poses, and execute parallel motion with synchronized execution.
Usage:
Run this script to move the iCub’s head and torso simultaneously to predefined positions and then return them to their initial positions.
- PositionController.move_parallel.move_head_and_torso_parallel(req_time_head: float = 1.0, req_time_torso: float = 5.0, timeout: float = 10.0)
Moves the iCub’s head and torso simultaneously to predefined positions and then back to their initial positions.
Parameters
- req_time_headfloat, optional
The requested time (in seconds) for the head motion to complete. Default is 1.0 seconds.
- req_time_torsofloat, optional
The requested time (in seconds) for the torso motion to complete. Default is 5.0 seconds.
- timeoutfloat, optional
The maximum time allowed (in seconds) for the motion to complete before timeout occurs. Default is 10.0 seconds.
Steps
Move both the head and torso to their “home” positions.
Move the head to the “up” position and the torso to the “down” position simultaneously.
Wait for both motions to complete.
Move both the head and torso back to their “home” positions.
Example
>>> move_head_and_torso_parallel(req_time_head=1.0, req_time_torso=5.0, timeout=10.0)
Notes
The movements of the head and torso are executed in parallel.
The function ensures that both motions are completed before proceeding.
The timeout prevents the robot from remaining in an unfinished movement state.
PositionController.move_part module
move_part.py
This script controls the movement of the iCub humanoid robot’s head and eyes. It demonstrates how to define motion trajectories using multiple joint poses and execute them sequentially.
Usage:
Run this script to move the iCub’s head through a series of predefined positions and coordinate the movement of its eyes.
- PositionController.move_part.move_head_and_eyes()
Moves the iCub’s head and eyes through predefined motion sequences.
Steps
Moves the head through a sequence: “Up” -> “Down” -> “Home”.
Moves the eyes through a sequence: “Left” -> “Right” -> “Home”.
Example
>>> move_head_and_eyes()
Notes
The function sequentially executes predefined motion trajectories.
LimbMotion objects store multiple poses for smooth transitions.
The iCub executes head and eye movements independently.
PositionController.move_request module
move_request.py
This script controls the movement of the iCub humanoid robot’s head and torso using a structured full-body step motion. It integrates motion planning and execution while retrieving motion requests.
Usage:
Run this script to execute a predefined movement sequence for the iCub’s head and torso and retrieve motion requests.
- class PositionController.move_request.HeadTorsoStep(offset_ms=None, name=None, JSON_dict=None, JSON_file=None)
Bases:
iCubFullbodyStep
Defines a full-body step for the iCub humanoid robot involving both head and torso movements.
This class groups multiple limb motions into a single step, ensuring synchronization between different body parts.
Methods
- prepare()
Initializes the step by creating limb motion trajectories for the head and torso.
- PositionController.move_request.execute_fullbody_step_with_request()
Executes a predefined full-body step for the iCub’s head and torso and retrieves motion requests.
Steps
Initializes an iCub instance.
Creates and prepares a HeadTorsoStep motion sequence.
Executes the movement step on the iCub.
Retrieves the motion requests for debugging and monitoring.
Returns
- list
A list of motion requests containing information about the executed movements.
Example
>>> requests = execute_fullbody_step_with_request() >>> print(requests)
Notes
The step is structured using iCubFullbodyStep for better modularity.
Motion requests provide insights into the robot’s behavior during execution.
The function ensures that both head and torso movements are synchronized.
PositionController.move_step module
move_step.py
This script controls the movement of the iCub humanoid robot’s head and torso using a full-body step motion. It demonstrates how to create limb motion sequences, define a structured step, and execute synchronized movements.
Usage:
Run this script to execute a predefined movement sequence for the iCub’s head and torso.
- class PositionController.move_step.HeadTorsoStep(offset_ms=None, name=None, JSON_dict=None, JSON_file=None)
Bases:
iCubFullbodyStep
Defines a full-body step for the iCub humanoid robot involving both head and torso movements.
This class groups multiple limb motions into a single step, ensuring synchronization between different body parts.
Methods
- prepare()
Initializes the step by creating limb motion trajectories for the head and torso.
- PositionController.move_step.execute_fullbody_step()
Executes a predefined full-body step for the iCub’s head and torso.
Steps
Initializes an iCub instance.
Creates and prepares a HeadTorsoStep motion sequence.
Executes the movement step on the iCub.
Example
>>> execute_fullbody_step()
Notes
The step is structured using iCubFullbodyStep for better modularity.
Head and torso movements are executed in a synchronized manner.