GazeController package
GazeController.lookat module
lookat.py
This script controls the gaze movement of the iCub humanoid robot. It demonstrates how to direct the robot’s gaze to a specific 3D point and then reset its gaze to an absolute angle.
Usage:
Run this script to move the iCub’s gaze to a fixation point and then reset it to a neutral position.
- GazeController.lookat.look_at_fixation_point(x: float = -1.0, y: float = -0.5, z: float = 1.0)
Directs the iCub’s gaze to a specific 3D fixation point in space.
Parameters
- xfloat, optional
The x-coordinate of the fixation point (default: -1.0).
- yfloat, optional
The y-coordinate of the fixation point (default: -0.5).
- zfloat, optional
The z-coordinate of the fixation point (default: 1.0).
Example
>>> look_at_fixation_point(-1.0, -0.5, 1.0)
Notes
The fixation point is specified in 3D coordinates.
This function is useful for directing the robot’s attention to a specific location.
- GazeController.lookat.reset_gaze_to_neutral()
Resets the iCub’s gaze to the absolute neutral angles.
Example
>>> reset_gaze_to_neutral()
Notes
The gaze is reset by setting the azimuth (azi), elevation (ele), and vergence (ver) angles to zero.
This function is useful for returning the gaze to a predefined reference position.
GazeController.lookat_timeout module
lookat_timeout.py
This script controls the gaze movement of the iCub humanoid robot with a timeout feature. It demonstrates how to direct the robot’s gaze to absolute angles while enforcing a timeout constraint on specific gaze operations.
Usage:
Run this script to move the iCub’s gaze through a sequence of absolute angles while ensuring that one of the movements respects a timeout limit.
- GazeController.lookat_timeout.set_gaze_absolute(azi: float, ele: float, ver: float, timeout: float = None)
Moves the iCub’s gaze to the specified absolute angles.
Parameters
- azifloat
The azimuth angle in degrees (left/right movement).
- elefloat
The elevation angle in degrees (up/down movement).
- verfloat
The vergence angle in degrees (eye convergence).
- timeoutfloat, optional
The maximum time allowed (in seconds) for the motion to complete. If None, the motion executes without a timeout (default: None).
Example
>>> set_gaze_absolute(10.0, 0.0, 0.0, timeout=1.0)
Notes
If timeout is specified, the gaze movement must complete within the given duration.
This function is useful for controlling gaze operations in time-sensitive scenarios.
- GazeController.lookat_timeout.execute_gaze_sequence()
Executes a sequence of gaze movements, including a timeout-constrained operation.
Steps
Moves the gaze to a neutral position (azi=0.0, ele=0.0, ver=0.0).
Moves the gaze to (azi=10.0, ele=0.0, ver=0.0) with a timeout of 1 second.
Moves the gaze to (azi=-10.0, ele=0.0, ver=0.0) without a timeout.
Resets the gaze back to the neutral position.
Example
>>> execute_gaze_sequence()
Notes
The timeout ensures that one of the gaze movements does not exceed the allowed time limit.
The function ensures a controlled, sequential execution of gaze motions.
GazeController.lookat_events module
lookat_events.py
This script controls the gaze movement of the iCub humanoid robot with event-based motion monitoring. It demonstrates how to direct the robot’s gaze to a specific point, detect the motion onset, wait for the motion to complete, and reset the gaze.
Usage:
Run this script to move the iCub’s gaze while detecting when the movement starts and ends.
- GazeController.lookat_events.look_at_fixation_point_with_events(x: float = -1.0, y: float = -0.5, z: float = 1.0)
Moves the iCub’s gaze to a specific 3D fixation point and monitors the motion onset and completion.
Parameters
- xfloat, optional
The x-coordinate of the fixation point (default: -1.0).
- yfloat, optional
The y-coordinate of the fixation point (default: -0.5).
- zfloat, optional
The z-coordinate of the fixation point (default: 1.0).
Steps
Starts the gaze movement towards the given fixation point.
Does not wait for motion completion (waitMotionDone=False).
Waits for the motion onset (waitMotionOnset()).
Prints a confirmation message.
Waits for the motion to complete (waitMotionDone()).
Prints another confirmation message.
Example
>>> look_at_fixation_point_with_events(-1.0, -0.5, 1.0)
Notes
This function provides real-time feedback on gaze motion events.
It is useful for synchronizing gaze movement with other robot actions.
- GazeController.lookat_events.reset_gaze_to_neutral()
Resets the iCub’s gaze to the absolute neutral angles.
Example
>>> reset_gaze_to_neutral()
Notes
The gaze is reset by setting the azimuth (azi), elevation (ele), and vergence (ver) angles to zero.
This function is useful for returning the gaze to a predefined reference position.
GazeController.lookat_portmonitor module
lookat_portmonitor.py
This script controls the gaze movement of the iCub humanoid robot using YARP port monitoring. It demonstrates how to monitor gaze angles and trigger specific actions when the gaze reaches a predefined position.
Usage:
Run this script to move the iCub’s gaze while monitoring its movement and triggering events based on detected positions.
- GazeController.lookat_portmonitor.af1(values)
Activation function for port monitoring.
This function checks if the iCub’s gaze is close to the ZERO position.
Parameters
- valueslist
A list of strings representing the last read values from the monitored YARP port.
Returns
- bool
True if the gaze is close to ZERO, otherwise False.
Example
>>> af1(["0.0 -0.5 3.0"]) True
- GazeController.lookat_portmonitor.cb1()
Callback function triggered when the iCub’s gaze reaches the ZERO position.
Example
>>> cb1() Watching at ZERO detected!
- GazeController.lookat_portmonitor.monitor_gaze()
Monitors the iCub’s gaze and triggers an event when it reaches the ZERO position.
Steps
Initializes an instance of the iCub robot.
Sets up a YARP port monitor on the gaze control output.
Moves the gaze to the UP position.
Alternates between DOWN and UP positions three times.
Resets the gaze to ZERO.
Closes the YARP connection.
Example
>>> monitor_gaze()
Notes
The YARP port monitor continuously checks gaze positions.
The cb1 callback is executed when the gaze is near ZERO.
This function ensures dynamic event-based gaze monitoring.