whack_a_mole.camera module
- class whack_a_mole.camera.Camera
Bases:
Node
Camera node that detects the color of the object and broadcasts the frame.
- Parameters:
clipping_distance (int): The clipping distance for the depth image box_start_x (int): The starting x coordinate for the bounding box box_end_x (int): The ending x coordinate for the bounding box box_start_y (int): The starting y coordinate for the bounding box box_end_y (int): The ending y coordinate for the bounding box
- Publisher:
filtered_image (Image): The filtered image
- Subscriber:
/camera/camera/aligned_depth_to_color/image_raw (Image): The depth image /camera/camera/color/image_raw (Image): The color image /camera/camera/color/camera_info (CameraInfo): The camera info
- Service:
toggle_tf_publish (Empty): Toggles the update_colors variable
- broadcast_color(lower_HSV, higher_HSV, color: str)
Broadcasts the color frame based on HSV range.
- Parameters:
lower_HSV (numpy.array) – The lower HSV range.
higher_HSV (numpy.array) – The higher HSV range.
color (str) – The name of the color of the object.
- broadcast_color_frame(base_frame, child_frame, x_c, y_c)
Broadcasts the transform for a detected color frame.
- Parameters:
base_frame (str) – The base frame’s name.
child_frame (str) – The child frame’s name.
x_c (int) – The x-coordinate of the detected color’s centroid in the image.
y_c (int) – The y-coordinate of the detected color’s centroid in the image.
- camera_info_callback(msg)
Publish new camera hardware info.
- Parameters:
msg (CameraInfo) – The CameraInfo message containing intrinsic parameters.
- find_color_centroid(lower_HSV: array, higher_HSV: array)
Find the pixel indices of the centroid of a color defined in the given HSV range.
- Parameters:
lower_HSV (numpy.array) – The lower HSV range for the color.
higher_HSV (numpy.array) – The higher HSV range for the color.
- Returns:
The (x, y) centroid of the color.
- Return type:
tuple(int, int)
- get_color_info(msg: Image)
Publish new camera color info.
- Parameters:
msg (Image) – The color image message.
- get_depth_info(msg: Image)
Publish new camera depth info.
- Parameters:
msg (Image) – The depth image message.
- log(*message)
Log custom messages.
- Parameters:
message (str) – The message(s) to log.
- timer_callback()
Timer callback that detects the color of the object and broadcasts the frame.
- Parameters:
None (NoneType) – No arguments required for this function.
- toggle_tf_publish(request, response)
Toggles the update_colors variable to start/stop publishing the color frames.
- Parameters:
request (Empty.Request) – Empty request.
response (Empty.Response) – Empty response.
- Returns:
Returns the response.
- Return type:
Empty.Response
- whack_a_mole.camera.entry(args=None)
Entry point for starting the ROS2 Camera node.
- Parameters:
args (list or NoneType) – The arguments passed for initialization.