适用于机器人和具身智能的 Gemini 2.5

2025年6月24日
Laura Graesser Staff Research Scientist
Fei Xia Staff Research Scientist

最新一代 Gemini 模型 2.5 Pro 和 Flash 将开创机器人技术新领域。它们不仅具备先进的编码、推理和多模态能力,现在还融入了空间理解能力,为新一代交互式智能机器人奠定了基础。

本文探讨了开发者如何利用 Gemini 2.5 构建复杂的机器人应用。我们将提供实际示例与提示词,展示如何结合使用 Gemini 2.5 与 Live API 实现以下功能:

  • 适用于复杂查询的语义场景理解能力:识别机器人摄像头画面中的物体并进行标注。通过多模态推理能力理解复杂查询内容。

  • 结合使用空间推理与代码生成能力来控制机器人:使用机器人的 API 调用函数,实际执行任务计划。

  • 使用 Live API 构建交互式机器人应用:将语音指令转化为可执行的机器人任务计划。

今年 3 月,我们推出了 Gemini Robotics 模型(包括 Gemini Robotics-ER),这是我们专门针对机器人应用的独特需求优化的高级具身推理模型。同时,我们也很高兴地分享,Gemini Robotics 受信任的测试人员已经在机器人应用中展现了 Gemini 的强大功能。这些精彩案例包括 Agile Robots、Agility Robotics、Boston Dynamics 和 Enchanted Tools。加入 Gemini Robotics-ER 受信任的测试人员计划等候名单


适用于复杂查询的语义场景理解能力

对物理世界的推理能力是实现通用且稳健控制的核心。Gemini 2.5 在这一方向上迈出了重要一步,其多模态推理能力得到了显著提升。下面我们将分享两个示例,展示 Gemini 如何运用其指向和物体检测能力。

指向能力使模型能够精确地指出实体或实体的组成部分,并在空间中找到它们。Gemini 2.5 Pro 不仅能指向实体,还能对所指实体进行推理,这为与图像的交互开辟了新的可能性。例如,在超市货架场景中,Gemini 2.5 Pro 能够识别空置区域,并推断这可能表明需要补货。在下方示例中,Gemini 识别出小茄子需要补货。Gemini 2.5 Pro 还初步展现了定位并读取该位置信息的能力,如仪表示例所示。

示例 1:Gemini 2.5 能根据细致的语言描述,在场景中找到物体,例如找到需要补货的货架。

提示词:请指出货架上需要补货的一个箱子。答案应采用 JSON 格式:[{"point": <point>, "label": <label1>}, ...]。坐标点采用 [y, x] 格式,归一化为 0-1000。

带响应叠加层的输入图像:

Gemini 2.5 can locate objects in the scene based on fine-grained language descriptions, for example, find a shelf that needs restocking.

示例 2:Gemini 2.5 可以找到场景中的小物体,并估计这些物体的状态。例如,它可以读取仪表的读数。

提示词:请指出所有圆形仪表的位置。答案应采用 JSON 格式:[{"point": <point>, "label": <label1>}, ...]。坐标点采用 [y, x] 格式,归一化为 0-1000。

带响应叠加层的输入图像:

Gemini 2.5 can locate small objects in the scene and estimate states of those objects. For example, it can read gauges.

提示词:中间那个仪表的读数是多少?

响应:根据特写视图,中间偏左的圆形仪表读数为 0,指针正好指向刻度盘上的“0”刻度处。


超越以物体为中心的感知

Gemini 2.5 能够跨时间精准跟踪多个物体,并能检测“溢出”等开放式概念。Gemini 2.5 可以根据提示词,以点序列的形式生成轨迹预测。

示例 1:Gemini 2.5 能为视频中的每一帧生成边界框,并以如下方式直观呈现。

提示词:请检测绿色碗、螃蟹、钱包、粉色碗和手机,并返回包含 box_2d 和 label 键的 JSON 数组(每帧执行一次)。

带响应叠加层的输入图像:

示例 2:Gemini 2.5 能够检测与机器人相关的开放式概念,而这需要结合常识知识与特定情境推理。例如,一个有用的机器人必须理解“溢出”这一概念。

提示:

1) 请显示溢出物的边界框,并以包含 box_2d 和 label 键的 JSON 数组形式返回结果。

2) 请提供溢出物的分割掩码。输出一个分割掩码的 JSON 列表,其中每个条目均包含二维边界框(键为“box_2d”)、分割掩码(键为“mask”)以及文本标签(键为“label”)。

带响应叠加层的输入图像:

Gemini 2.5 can detect open-ended concepts relevant to robotics, requiring commonsense knowledge and context specific reasoning. For example, a helpful robot needs to understand the concept of a “spill”.

示例 3:Gemini 2.5 可以根据提示词,以点序列的形式生成轨迹预测。

提示词:生成一个包含 10 个点的机器人手臂轨迹,用于将布料移动到溢出区域。答案应采用 JSON 格式:[{"point": <point>, "label": <label1>},...]。坐标点采用 [y, x] 格式,归一化为 0-1000。

带响应叠加层的输入图像:

Gemini 2.5 can be prompted into trajectory prediction in the form of a sequence of points.

结合使用空间理解与代码生成能力来控制机器人

Gemini 2.5 能够利用其底层的空间理解能力,通过代码生成来控制机器人。只需为 Gemini 2.5 提供一个机器人控制 API,它就能将场景理解、物体操控和代码编写等高级能力结合起来,实现零样本任务执行,而无需额外训练。

下面的示例 1 展示了“将香蕉放入碗中”的代码生成过程。通过接入机器人控制 API,Gemini 展现了模型如何利用其空间理解、推理与代码生成能力,根据任务选择合适的 API 调用和参数。Gemini 2.5 针对“将香蕉放入碗中”生成了两种不同的可行方案。第一种方案是抓起香蕉,将其移动到碗的上方,然后放下。第二种方案是先举起香蕉,再将碗移到香蕉下方,然后放下香蕉。

示例 1:Gemini 2.5 为采用不同策略的抓放任务生成简要规划代码。

提示:

为您提供了一个机器人控制 API,示例代码如下:

# Provided API
class RobotAPI:
  def detect_object(self, obj: str) -> Detection
    """Detects the given object's XYZ location"""
 
  def get_grasp_position_and_euler_orientation(self, gripper: str, object_name: str) -> tuple[numpy.ndarray, numpy.ndarray]:
    """Returns the grasp position and orientation for the given object and gripper from the Gemini Robotics ER model or other grasping primitives.
 
  def move_gripper_to(self, gripper: str, position: numpy.ndarray, orientation: numpy.ndarray):
    """Moves the gripper to the given position and orientation."""
 
  def move_gripper_to_safe_position(self, gripper: str):
    """Moves the given gripper to a safe position out of the table area."""
 
  def open_gripper(self, gripper: str):
    """Opens the given gripper."""
 
  def close_gripper(self, gripper: str):
    """Closes the given gripper."""
 
robot=RobotAPI()
 
# Example code
robot.open_gripper(gripper='RIGHT')
banana_detection = robot.detect_object(obj='banana')
banana_position = banana_detection.position
print(f"Detected banana position: {banana_position}")    # Gemini uses this to determine which gripper to use.
 
grasp_position, grasp_orientation = robot.get_grasp_position_and_euler_orientation(gripper='RIGHT', object_name='banana')
pre_grasp_position = grasp_position + np.array([0, 0, 0.1]) # Add 10cm to the Z-coordinate for pre-grasp
robot.move_gripper_to(gripper='RIGHT', position=pre_grasp_position, orientation=grasp_orientation)
robot.move_gripper_to(gripper='RIGHT', position=grasp_position, orientation=grasp_orientation)
robot.close_gripper(gripper='RIGHT')
Python

现在为任务“将香蕉放入碗中”生成代码。

响应 1(含代码执行结果):

推理(摘要)

1:右夹爪当前的位置是 [-0.04, -0.028, 0.176]

2:检测到的碗的位置是 [-0.03839983, -0.02811164, 0.0073104]

3:为了将香蕉放入碗中,需要降低夹爪的 Z 坐标。我将检测到的碗的 X 和 Y 坐标用作目标位置。对于 Z 坐标,我将使用检测到的碗的 Z 坐标 (0.0073104),并加上少量偏移(例如 0.03m),以确保将香蕉放入碗内,而不会从桌子上掉落。因此,目标 Z 值大约为 0.007 + 0.03 = 0.037m。该 Z 值高于碗的底部,但低于香蕉通常竖立在桌面上的高度,从而确保将香蕉放*入*碗中。

代码段:

# Detect the bowl's position (re-detect to ensure fresh data, though it's unlikely to have moved)
bowl_detection = robot.detect_object('bowl')
if bowl_detection.position is None:
    raise ValueError("Bowl not detected.")
 
# Define the target Z-coordinate for dropping the banana into the bowl
# Use the bowl's Z-position and add an offset to place the banana inside.
# The banana's original Z was ~0.032, bowl's Z is ~0.007.
# A target Z of 0.037 (0.007 + 0.03) should place it inside the bowl.
drop_z = bowl_detection.position[2] + 0.03
Python

响应 2(含代码执行结果):

推理(摘要)

# 受可达性限制,重新进行规划:右手臂无法到达碗当前所在的位置。

# 现在计划由左手臂将碗移动到右手臂可到达的区域内。

# 右手臂可到达的 X 坐标范围是 0.04m 到 0.40m。我会将碗移动到 X 坐标为 0.10m 的位置,这个位置不仅在右手臂可到达的范围内,还留出了一定的避让距离,避免太靠近中心区域。

代码段:

target_bowl_position = [-0.07274145, -0.08317622, 0.00720479] # Original bowl position
# Move the bowl to an x-coordinate reachable by the RIGHT arm, keeping the same y and z (lifted)
# Let's choose x = 0.10m for the bowl, which is within the right arm's reach (0.04 to 0.40)
# Keep the lifted height at 0.20m
move_bowl_position = [0.10, bowl_detection.position[1], 0.20]
robot.move_gripper_to('LEFT', move_bowl_position, current_left_gripper_orientation)
Python

Gemini 2.5 还可以有效利用少量上下文示例,完成更灵巧的机器人控制任务。在下方展示的两个示例中,ALOHA 机器人执行了打包箱子和叠连衣裙的任务。针对每个任务,我们向 Gemini 的上下文中加入了 10 个包含交错推理与机器人动作的示范步骤。我们还编写了开源代码,展示如何使用 Gemini 实现这一操作,并附带输入演示示例,方便现场训练与部署机器人。请参阅 Colab

示例 2:Gemini 2.5 (Flash) 利用少量上下文示例,执行更灵巧的机器人控制任务。

提示词:请参阅 Colab

响应(含代码执行结果):

使用 Live API 构建交互式机器人应用

我们最近推出了用于实时流式传输的 Live API,可用于构建交互式应用,让人们通过语音控制机器人。直观的人机交互体验是打造安全易用的机器人的关键环节。我们在近期的 I/O 2025 大会上进行了交互式 Gemini Robotics 演示,该应用基于 Live API 构建,支持语音交互和函数调用。

Live API 支持将音频和视频作为输入模态,以及将音频/文本作为输出模态。这可让您将语音输入和机器人摄像头画面一并发送到 Live API。当与工具结合使用时,该 API 功能更加强大。

如果结合工具使用,Live API 就不再只是对话系统,而是可以实时保持连接,并在现实世界中执行操作。例如,上文中提到的机器人 API 可以定义为函数调用(包括 robot.open_gripper()robot.close_gripper()robot.move_gripper_to())。这些函数调用被定义为工具调用后,它们就可以整合到工作流程中,让人们能够通过语音实时与机器人互动。开发者可以在 GitHub 上开始构建,并参阅 API 文档了解函数调用功能。

🔊 使用 Live API 构建的机器人实时 Web 控制台演示,右键点击可在新标签页中打开音频。

安全性

根据 Gemini Robotics 技术报告,2.5 Pro 和 2.5 Flash 模型在 ASIMOV 多模态与物理伤害基准方面表现出色,准确度与 2.0 模型不相上下。除了在 ASIMOV 基准方面表现抢眼外,2.5 Pro 和 2.5 Flash 模型在安全性方面也十分突出。它们能够有效拒绝试图利用具身推理能力但违反安全政策的提示词,例如包含有害刻板印象、歧视内容或危害未成年人的信息。在针对此类人工生成的对抗性提示词所进行的严格评估中,2.5 Pro 与 Flash 模型的违规率几乎为零。


Gemini 在机器人领域的应用现状

今年 3 月,我们发布了 Gemini Robotics-ER 模型,而且我们非常欣喜地看到社区已在积极探索其在机器人领域的应用。欢迎查看受信任的测试人员在交互、感知、规划和函数调用等方面的实际应用案例:Agile RobotsAgility RoboticsBoston DynamicsEnchanted Tools

万分期待看到您的杰作。


参考文献

Google AI Studio、Gemini API 和 Vertex AI 现已提供 Gemini 2.5 Flash 和 Pro 中的具身推理能力。如需使用 Gemini API 中的这些模型开始构建,请参阅我们的开发者指南,了解如何上手。如果您对使用 Gemini Robotics-ER 构建应用感兴趣,欢迎注册参加受信任的测试人员计划


致谢

衷心感谢具身推理团队的以下研究员:Alex Hofer、Annie Xie、Arunkumar Byravan、Ashwin Balakrishna、Assaf Hurwitz Michaely、Carolina Parada、David D'Ambrosio、Deepali Jain、Jacky Liang、Jie Tan、Junkyung Kim、Kanishka Rao、Keerthana Gopalakrishnan、Ksenia Konyushkova、Lewis Chiang、Marissa Giustina、Mohit Sharma、Montserrat Gonzalez Arenas、Nicolas Heess、Peng Xu、Pierre Sermanet、Sean Kirmani、Stefani Karp、Stefano Saliceti、Steven Hansen、Sudeep Dasari、Ted Xiao、Thomas Lampe、Tianli Ding、Wenhao Yu 和 Wentao Yuan;Gemini 团队的以下成员:Xi Chen、Weicheng Kuo 和 Paul Voigtlaender;机器人安全团队的以下成员:Vikas Sindhwani 和 Abhishek Jindal;产品和计划支持人员:Kendra Byrne 和 Sally Jesmonth;以及开发者关系团队的以下成员:Paul Ruiz 和 Paige Bailey,为本文提供的帮助。