|
| 1 | +# coffee_machine_control_msgs |
| 2 | + |
| 3 | +A ROS2 package providing message and service definitions for coffee machine control and monitoring. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This package contains the interface definitions (messages and services) used to communicate with and control coffee machines in the Coffee Buddy robot system. It provides standardized message types for machine status reporting and command execution. |
| 8 | + |
| 9 | +## Package Information |
| 10 | + |
| 11 | +- **Version**: 0.0.1 |
| 12 | +- **License**: TODO: License declaration |
| 13 | +- **Build Type**: ament_cmake |
| 14 | +- **Dependencies**: rosidl_default_generators, rosidl_default_runtime |
| 15 | + |
| 16 | +## Messages |
| 17 | + |
| 18 | +### MachineStatus.msg |
| 19 | + |
| 20 | +Represents the current status and configuration of a coffee machine. |
| 21 | + |
| 22 | +```msg |
| 23 | +string device_name |
| 24 | +string model |
| 25 | +string status |
| 26 | +string steam_nozzle |
| 27 | +string current_beverage |
| 28 | +bool cup_light |
| 29 | +bool energy_save |
| 30 | +bool sound_enabled |
| 31 | +``` |
| 32 | + |
| 33 | +**Fields:** |
| 34 | +- `device_name`: Name/identifier of the coffee machine device |
| 35 | +- `model`: Model name of the coffee machine |
| 36 | +- `status`: Current operational status (e.g., "ready", "brewing", "error") |
| 37 | +- `steam_nozzle`: Status of the steam nozzle |
| 38 | +- `current_beverage`: Currently selected or brewing beverage type |
| 39 | +- `cup_light`: Whether the cup light is enabled |
| 40 | +- `energy_save`: Whether energy saving mode is active |
| 41 | +- `sound_enabled`: Whether sound notifications are enabled |
| 42 | + |
| 43 | +### FunctionCall.msg |
| 44 | + |
| 45 | +Represents a function call or action to be performed on the coffee machine. |
| 46 | + |
| 47 | +```msg |
| 48 | +string name # e.g., "make_coffee", "turn_cuplight_on", "cancel_brewing" |
| 49 | +string parameter # Optional parameter like "espresso" or "on" |
| 50 | +``` |
| 51 | + |
| 52 | +**Fields:** |
| 53 | +- `name`: Name of the function/action to execute |
| 54 | +- `parameter`: Optional parameter for the function (e.g., beverage type, on/off state) |
| 55 | + |
| 56 | +**Example function names:** |
| 57 | +- `make_coffee`: Brew coffee with optional beverage type parameter |
| 58 | +- `turn_cuplight_on`/`turn_cuplight_off`: Control cup light |
| 59 | +- `cancel_brewing`: Cancel current brewing operation |
| 60 | + |
| 61 | +## Services |
| 62 | + |
| 63 | +### MachineStatusRequest.srv |
| 64 | + |
| 65 | +Service to request the current status of the coffee machine. |
| 66 | + |
| 67 | +```srv |
| 68 | +# Empty request |
| 69 | +--- |
| 70 | +string device_name |
| 71 | +string model |
| 72 | +string status |
| 73 | +string steam_nozzle |
| 74 | +string current_beverage |
| 75 | +bool cup_light |
| 76 | +bool energy_save |
| 77 | +bool sound_enabled |
| 78 | +``` |
| 79 | + |
| 80 | +**Request**: Empty (no parameters required) |
| 81 | + |
| 82 | +**Response**: Returns a complete `MachineStatus` with all current machine information. |
| 83 | + |
| 84 | +### CoffeeCommand.srv |
| 85 | + |
| 86 | +Service to send commands to the coffee machine and receive execution results. |
| 87 | + |
| 88 | +```srv |
| 89 | +# Request |
| 90 | +string action # "make", "cancel", "cuplight", "sound", "energy_save" |
| 91 | +string parameter # Parameter depending on action (e.g., "espresso", "on", "off") |
| 92 | +--- |
| 93 | +# Response |
| 94 | +bool success |
| 95 | +string message |
| 96 | +``` |
| 97 | + |
| 98 | +**Request:** |
| 99 | +- `action`: The action to perform on the machine |
| 100 | +- `parameter`: Action-specific parameter |
| 101 | + |
| 102 | +**Response:** |
| 103 | +- `success`: Whether the command was executed successfully |
| 104 | +- `message`: Human-readable result or error message |
| 105 | + |
| 106 | +**Supported Actions:** |
| 107 | +- `make`: Start brewing with parameter specifying beverage type |
| 108 | +- `cancel`: Cancel current operation |
| 109 | +- `cuplight`: Control cup light (parameter: "on"/"off") |
| 110 | +- `sound`: Control sound notifications (parameter: "on"/"off") |
| 111 | +- `energy_save`: Control energy saving mode (parameter: "on"/"off") |
| 112 | + |
| 113 | +## Usage Examples |
| 114 | + |
| 115 | +### Python Examples |
| 116 | + |
| 117 | +#### Requesting Machine Status |
| 118 | + |
| 119 | +```python |
| 120 | +import rclpy |
| 121 | +from rclpy.node import Node |
| 122 | +from coffee_machine_control_msgs.srv import MachineStatusRequest |
| 123 | + |
| 124 | +class StatusClient(Node): |
| 125 | + def __init__(self): |
| 126 | + super().__init__('status_client') |
| 127 | + self.client = self.create_client(MachineStatusRequest, 'coffee_machine_status') |
| 128 | + |
| 129 | + def get_status(self): |
| 130 | + request = MachineStatusRequest.Request() |
| 131 | + future = self.client.call_async(request) |
| 132 | + # Handle response... |
| 133 | +``` |
| 134 | + |
| 135 | +#### Sending Coffee Commands |
| 136 | + |
| 137 | +```python |
| 138 | +import rclpy |
| 139 | +from rclpy.node import Node |
| 140 | +from coffee_machine_control_msgs.srv import CoffeeCommand |
| 141 | + |
| 142 | +class CommandClient(Node): |
| 143 | + def __init__(self): |
| 144 | + super().__init__('command_client') |
| 145 | + self.client = self.create_client(CoffeeCommand, 'coffee_machine_command') |
| 146 | + |
| 147 | + def make_espresso(self): |
| 148 | + request = CoffeeCommand.Request() |
| 149 | + request.action = "make" |
| 150 | + request.parameter = "espresso" |
| 151 | + future = self.client.call_async(request) |
| 152 | + # Handle response... |
| 153 | +``` |
| 154 | + |
| 155 | +#### Publishing Function Calls |
| 156 | + |
| 157 | +```python |
| 158 | +import rclpy |
| 159 | +from rclpy.node import Node |
| 160 | +from coffee_machine_control_msgs.msg import FunctionCall |
| 161 | + |
| 162 | +class FunctionPublisher(Node): |
| 163 | + def __init__(self): |
| 164 | + super().__init__('function_publisher') |
| 165 | + self.publisher = self.create_publisher(FunctionCall, 'coffee_function_calls', 10) |
| 166 | + |
| 167 | + def publish_function_call(self, name, parameter=""): |
| 168 | + msg = FunctionCall() |
| 169 | + msg.name = name |
| 170 | + msg.parameter = parameter |
| 171 | + self.publisher.publish(msg) |
| 172 | +``` |
| 173 | + |
| 174 | +## Building |
| 175 | + |
| 176 | +This package uses the standard ROS2 build system: |
| 177 | + |
| 178 | +```bash |
| 179 | +# From your workspace root |
| 180 | +colcon build --packages-select coffee_machine_control_msgs |
| 181 | +``` |
| 182 | + |
| 183 | +## Dependencies |
| 184 | + |
| 185 | +- ROS2 (tested with Humble/Iron) |
| 186 | +- rosidl_default_generators (build dependency) |
| 187 | +- rosidl_default_runtime (runtime dependency) |
| 188 | + |
| 189 | +## Integration |
| 190 | + |
| 191 | +This package is designed to work with: |
| 192 | +- `coffee_machine_control`: Main coffee machine control node |
| 193 | +- Other coffee buddy system packages that need to interact with coffee machines |
0 commit comments