whack_a_mole.game module
- class whack_a_mole.game.Game
Bases:
Node
ROS2 Game Node for controlling Franka to interact with a target in a game.
The node: - Calculates poses for the robotic arm based on TF transforms. - Interacts with various ROS2 services and actions for robot motion control. - Handles game-specific functionality like moving to specific color targets.
Services: - play (TargetFrame): Starts the game and moves the robot to the target frame. - go_home (Empty): Sends the robotic arm to the default home position.
Clients: - pick (PickPose): Calls a service to move the robot to the provided goal pose. - swing_hammer (ActuateServo): An action client to actuate the hammer motion.
TF Transformations: - Sets up a static transformation from base_tag to base.
Constants: - READ! This node uses specific offsets for hammer and tag positions. - Make sure to change these values based on your setup.
- async go_home_callback(request, response)
Service callback to send the robot back to its home position.
- Parameters:
request (Empty.Request) – An empty service request.
response (Empty.Response) – An empty service response.
- Returns:
The response to the service caller.
- Return type:
Empty.Response
- Raises:
Exception – If there is an error during the motion to the home position.
- async play_game(request, response)
Move the hammer to the target frame.
This service is called with a target frame. The robot moves to the target, calculates the appropriate pose based on TF transformations, and executes the required motion.
- Parameters:
request (TargetFrame.Request) – The service request containing the target color frame.
response (TargetFrame.Response) – The service response.
- Returns:
The response to the service caller.
- Return type:
TargetFrame.Response
- Raises:
Exception – If there is an error in TF lookup or motion execution.
- whack_a_mole.game.main(args=None)
Entry point to start the Game node.
This function initializes the ROS2 system, creates the Game node, and keeps it spinning.
- Parameters:
args (list or NoneType) – Optional command-line arguments passed to the ROS2 system.