Building a Gongfu Tea Robot: Embedded Development Guide and Sample Code
This article presents a step‑by‑step guide to designing and building a Gongfu tea‑making robot, covering embedded development basics, hardware modularization, controller design, platform comparisons, power supply considerations, and complete Python code for servo control and action sequencing.
The article introduces a unique Gongfu tea robot created by three fourth‑grade students under teacher guidance, which can respond to voice commands and perform a full tea‑making routine including heating, rinsing, brewing, and serving.
1. Embedded Development Introduction explains the difference between software‑only programming and hardware development, outlines the typical stages of hardware design, and highlights the relevance of Linux for embedded systems.
2. Hardware Modularity discusses the shift from discrete components to modular hardware such as infrared sensors, ultrasonic ranging modules, Bluetooth/Wi‑Fi modules, and the benefits of interchangeable modules for maintenance and development.
3. Controller Overview describes how controllers interface with sensors and actuators, using a simple robotic arm as an example, and compares the complexity of the Internet to that of a controller.
4. Hardware Platform Comparison compares MCU‑based boards (e.g., C51), Arduino, Raspberry Pi, and other platforms, noting their CPU architecture, memory size, OS requirements, and suitability for different tasks.
5. Mechanical Design details the construction of the robot’s mechanical arm, servo selection (MG995), cup holders, chassis, and power modules, including diagrams of servo pulse‑width mapping and voltage regulation.
5.5 Software Design explains that the system communicates via serial commands over USB, and provides the complete Python class used to control the robot. The code is shown below:
class Tea(object):
'''
Initialize USB connection object
heavy sets the counterweight; servo IDs:
arm joints: 0,2,4,6
cup cover: 8
cups: 10,12,14
'''
def __init__(self):
self.se = serial.Serial("/dev/ttyUSB0", 115200, timeout=1.0)
self.heavy = 100
def instr(self, data, t=1000, delay=1):
s = ''
for d in data:
s += '#%d P%d' % (d[0], d[1])
self.se.write('#%d P%d' % (d[0], d[1]))
s += 'T%d' % (t)
self.se.write('T%d\r' % (t))
time.sleep(delay)
def reset_arm(self):
self.instr([
(0, 750),
(2, 1350),
(4, 750),
(6, 2500),
])
def reset_cup(self):
self.instr([
(10, 2500),
(12, 2500),
(14, 2500),
])
def revert_cup(self):
self.instr([
(10, 1000),
(12, 1000),
(14, 1000),
])
def to_cup_1(self):
self.instr([
(0, 1350),
(2, 1450),
], 400, 1)
def pour(self):
self.instr([
(4, 950 - self.heavy),
(6, 1500),
], 200)
def suite(self):
self.revert_cup()
self.reset_cup()
self.cover_close()
self.to_cup_1_slow()
self.pour()
# ... (remaining sequence omitted for brevity)Additional snippets illustrate simple motion commands using pseudo‑code:
machine1.set_pos(90);
machine2.set_pos(45);
action_parallel();The robot’s actions are orchestrated by setting initial servo positions, moving to cup locations, pouring, and performing shaking motions, all driven by timed serial commands.
5.6 Overall Demonstration shows system diagrams, photos of the assembled robot, power modules, and a touchscreen interface running on a Raspberry Pi that allows users to trigger the tea‑making sequence.
NetEase Game Operations Platform
The NetEase Game Automated Operations Platform delivers stable services for thousands of NetEase titles, focusing on efficient ops workflows, intelligent monitoring, and virtualization.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.