Camera¶
FrameGrabber¶
robot_environment.camera.framegrabber.FrameGrabber
¶
Bases: ABC
An abstract class that provides the abstract method get_current_frame() to be implemented by classes inheriting from this one. The FrameGrabber grabs frames from the camera and provides them.
Source code in robot_environment/camera/framegrabber.py
Functions¶
__init__(environment, verbose=False)
¶
Initialize the FrameGrabber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
Environment
|
Environment object this FrameGrabber is installed in. |
required |
verbose
|
bool
|
Enable verbose logging. |
False
|
Source code in robot_environment/camera/framegrabber.py
current_frame()
¶
Returns current frame.
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: Current frame. |
environment()
¶
Returns the environment object.
Returns:
| Name | Type | Description |
|---|---|---|
Environment |
Environment
|
The environment instance. |
get_current_frame()
abstractmethod
¶
Captures an image of the robot's workspace, ensuring proper undistortion in RGB.
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: Raw image captured from the robot's camera. |
Source code in robot_environment/camera/framegrabber.py
get_current_frame_shape()
¶
Return the shape of the current frame.
Returns:
| Type | Description |
|---|---|
tuple[int, ...]
|
tuple[int, ...]: Shape of the frame. |
get_current_frame_width_height()
¶
Returns width and height of current frame in pixels.
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
width and height of current frame in pixels. |
Source code in robot_environment/camera/framegrabber.py
verbose()
¶
Returns the verbosity status.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if verbose is on, else False. |
NiryoFrameGrabber¶
robot_environment.camera.niryo_framegrabber.NiryoFrameGrabber
¶
Bases: FrameGrabber
A class implementing a framegrabber for Niryo Ned2 robot arm
Source code in robot_environment/camera/niryo_framegrabber.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
Functions¶
__init__(environment, stream_name='robot_camera', verbose=False)
¶
Initialize the Niryo framegrabber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
Environment
|
Environment object this FrameGrabber is installed in. |
required |
stream_name
|
str
|
Name of the Redis stream for image publishing. |
'robot_camera'
|
verbose
|
bool
|
Enable verbose logging. |
False
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If the robot controller is not an instance of NiryoRobotController. |
Source code in robot_environment/camera/niryo_framegrabber.py
camera_dist_coeff()
¶
Returns the camera distortion coefficients.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Distortion coefficients. |
camera_matrix()
¶
Returns the camera intrinsic matrix.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: 3x3 intrinsic matrix. |
get_current_frame()
¶
Captures an image of the robot's workspace, ensuring proper undistortion in BGR.
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: Raw image captured from the robot's camera. |
Source code in robot_environment/camera/niryo_framegrabber.py
is_point_visible(world_point, camera_to_gripper_transform=np.eye(4))
¶
Determines whether a given world point is visible in the camera's field of view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
world_point
|
array
|
A 3D point in world coordinates as a NumPy array of shape (3,). |
required |
camera_to_gripper_transform
|
array
|
A 4x4 transformation matrix that defines the relationship between the camera and the gripper frame. Defaults to the identity matrix. |
eye(4)
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the point is visible in the camera's view, False otherwise. |
Explanation
- Transforms the
world_pointfrom world coordinates to the gripper frame using the gripper's pose transformation matrix. - Transforms the point to the camera frame using the provided camera-to-gripper transformation.
- Projects the point onto the image plane using the camera's intrinsic matrix.
- Checks if the projected point lies within the camera's image bounds (640x480 pixels).
- Optionally undistorts the projected point to account for lens distortion.
Notes
- This method assumes the camera intrinsic matrix (
self._mtx) and distortion coefficients (self._dist) are precomputed and valid for a resolution of 640x480 pixels. - Points behind the camera (with z <= 0 in the camera frame) are not visible.
Source code in robot_environment/camera/niryo_framegrabber.py
publish_workspace_image(image, workspace_id, robot_pose=None)
¶
Publish workspace image with robot context via Redis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
ndarray
|
The image to publish. |
required |
workspace_id
|
str
|
ID of the workspace shown in the image. |
required |
robot_pose
|
Optional[Dict[str, float]]
|
Optional robot pose metadata. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The Redis stream ID of the published image. |
Source code in robot_environment/camera/niryo_framegrabber.py
WidowXFrameGrabber¶
robot_environment.camera.widowx_framegrabber.WidowXFrameGrabber
¶
Bases: FrameGrabber
A class implementing a framegrabber for WidowX robot arm - here Intel RealSense camera as third person camera
Source code in robot_environment/camera/widowx_framegrabber.py
Functions¶
__init__(environment, verbose=False)
¶
Initialize the WidowX framegrabber.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
Environment
|
Environment object this FrameGrabber is installed in. |
required |
verbose
|
bool
|
Enable verbose logging. |
False
|
Source code in robot_environment/camera/widowx_framegrabber.py
get_current_frame()
¶
Captures an image of the robot's workspace, ensuring proper undistortion in BGR.
Args:
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: Raw image captured from the robot's camera. |