작업 오케스트레이션
작업 오케스트레이션 (Task orchestration)
Gemini Robotics ER 모델은 작업을 계획하고 공간을 추론해서, 목표를 완수하기 위해 어떤 동작을 취하고 어떤 객체를 움직여야 할지 판단할 수 있어요. 이 페이지는 아이템을 그릇에 담는 작업을 오케스트레이션하기 위해 커스텀 로봇 API로 픽 앤 플레이스(pick-and-place) 동작을 구동하는 예시를 보여줘요. 이 예시는 표준 Gemini ER 2 모델을 사용하며, 스트리밍 예시는 Gemini ER 2 Streaming 가이드를 참고하세요.
전체 실행 가능 코드는 Robotics cookbook을 확인하세요.
출처: 원문
본문
커스텀 로봇 API 사용하기 (Using a custom robot API)
이 예시는 커스텀 로봇 API로 작업 오케스트레이션을 구현하는 방법을 보여줘요. 픽 앤 플레이스 작업용으로 설계된 목업(mock) API를 소개할게요. 작업은 파란 블록을 집어 주황색 그릇에 넣는 것이에요.

이 예시는 다음과 같은 목업 로봇 API를 사용해요:
def move(x, y, high):
print(f"Mock Robot: Moving to coordinates: {x}, {y}, {'high above table' if high else 'down at table level'}")
def setGripperState(opened):
print(f"Mock Robot: {'Opening gripper' if opened else 'Closing gripper'}")
robot_origin_y = 300
robot_origin_x = 500
move_function = {
"type": "function",
"name": "move",
"description": "Moves the arm to the given coordinates.",
"parameters": {
"type": "object",
"properties": {
"x": {"type": "integer", "description": "X coordinate relative to the origin"},
"y": {"type": "integer", "description": "Y coordinate relative to the origin"},
"high": {"type": "boolean", "description": "Set to True to lift the robot arm above the scene for avoiding obstacles. Set to False to place the gripper on the surface."}
},
"required": ["x", "y", "high"]
}
}
set_gripper_state_function = {
"type": "function",
"name": "setGripperState",
"description": "Opens or closes the robot's gripper.",
"parameters": {
"type": "object",
"properties": {
"opened": {"type": "boolean", "description": "True opens the gripper, False closes the gripper."}
},
"required": ["opened"]
}
}
다음 예시는 도구 정의와 함께 프롬프트와 이미지를 모델에 보내요. 그런 다음 에이전트 루프를 실행하죠. 각 모델 응답 후 요청된 함수 호출(move, setGripperState)을 실행하고, previous_interaction_id로 결과를 모델에 돌려주며, 모델이 함수 호출을 멈추거나 단계 한도에 도달할 때까지 반복해요.
prompt = (
"You are a robotic arm with six degrees-of-freedom. "
f"The origin point for calculating the moves is at normalized point y={robot_origin_y}, x={robot_origin_x}. "
"Use this as the new (0,0) for calculating moves, allowing x and y to be negative.\n\n"
"Find the blue block and the orange bowl. Calculate their coordinates relative to the origin.\n"
"Perform a pick and place operation where you pick up the blue block and place it into the orange bowl. "
"Call the appropriate sequence of functions to complete this operation."
)
# 1. Initial Interaction
interaction = client.interactions.create(
model=MODEL_ID,
input=[{"type": "user_input", "content": [
{"type": "image", "data": img_b64, "mime_type": "image/png"},
{"type": "text", "text": prompt}
]}],
tools=[move_function, set_gripper_state_function],
generation_config={"thinking_level": "low"}
)
print("\n--- Executing Orchestrated Plan ---")
max_steps = 15 # Safety limit to prevent infinite loops
step_count = 0
# 2. The Agentic Loop
while step_count < max_steps:
step_count += 1
# Check if the model wants to call any functions
tool_calls = [step for step in interaction.steps if step.type == "function_call"]
if not tool_calls:
# If no tools were called, the model is finished with the sequence
print("Sequence complete.")
if interaction.output_text:
print(f"Model Summary: {interaction.output_text}")
break
function_results = []
for step in tool_calls:
function_name = step.name
arguments = step.arguments
# Execute the mock function
if function_name == "move":
move(**arguments)
elif function_name == "setGripperState":
setGripperState(**arguments)
else:
print(f"Unknown function: {function_name}")
# 3. Create a result object to tell the model the function succeeded
function_results.append({
"type": "function_result",
"name": step.name,
"call_id": step.id,
"result": [{"type": "text", "text": '{"status": "success"}'}]
})
# 4. Send the results back to the model, passing previous_interaction_id
# so it remembers the conversation history and generates the NEXT step
interaction = client.interactions.create(
model=MODEL_ID,
previous_interaction_id=interaction.id,
tools=[move_function, set_gripper_state_function],
input=function_results
)
다음은 프롬프트와 목업 로봇 API에 기반한 모델의 가능한 출력이에요. 출력에는 모델이 순서대로 이어 붙인 로봇 함수 호출의 결과도 포함돼요.
--- Executing Orchestrated Plan ---
Mock Robot: Opening gripper
Mock Robot: Moving to coordinates: 160, 440, high above table
Mock Robot: Moving to coordinates: 160, 440, down at table level
Mock Robot: Closing gripper
Mock Robot: Moving to coordinates: 160, 440, high above table
Mock Robot: Moving to coordinates: -250, 60, high above table
Mock Robot: Moving to coordinates: -250, 60, down at table level
Mock Robot: Opening gripper
Mock Robot: Moving to coordinates: -250, 60, high above table
Sequence complete.
Model Summary: I have completed the task of picking up the blue block and placing it into the orange bowl.
다음 단계 (What's next)
- Robotics with streaming — 함수 호출이 포함된 실시간 스트리밍(Gemini Robotics ER 2 전용).
- Video understanding — 비디오로 작업 진행 상황 추적(ER 2 전용).
- Spatial reasoning — 포인팅, 추적, 바운딩 박스 예시.
더 알아보기 (Learn more)
- Robotics cookbook — 전체 실행 가능 코드.
- 커스텀 로봇 API 호출 — 픽 앤 플레이스 상세.