No version for distro humble. Known supported distros are highlighted in the buttons above.
No version for distro jazzy. Known supported distros are highlighted in the buttons above.
No version for distro rolling. Known supported distros are highlighted in the buttons above.

ros2ai package from ros2ai repo

ros2ai

Package Summary

Tags No category tags.
Version 0.1.0
License Apache License 2.0
Build type AMENT_PYTHON
Use RECOMMENDED

Repository Summary

Description ros2ai is a next-generation ROS 2 command line interface extension with LLMs
Checkout URI https://github.com/fujitatomoya/ros2ai.git
VCS Type git
VCS Version rolling
Last Updated 2025-01-15
Dev Status UNKNOWN
CI status No Continuous Integration
Released UNRELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

The OpenAI command for ROS 2 command line tools.

Additional Links

No additional links.

Maintainers

  • Tomoya Fujita

Authors

  • Tomoya Fujita

humble jazzy rolling humble-nightly jazzy-nightly rolling-nightly

ros2ai 🤖

ros2ai is a next-generation ROS 2 command line interface extension with OpenAI and Ollama.

see overview slide deck for more information.

ros2ai Architecture Overview

Motivation

  • (Just for fun 😝)
  • Getting answers against the questions directly without browsing, clicking and typing many times.
  • Easy to use for everyone, especially for ROS 2 beginners and students who do not really know ros2cli.
  • Multiple language support.
  • Multiple LLMs support (with OpenAI Python API)

Demo 🖥️

See how it works 🔥

https://github.com/fujitatomoya/ros2ai/assets/43395114/78a0799b-40e3-4dc8-99cb-488994e94769

Supported ROS Distribution

Distribution Supported Note
Rolling Ridley Development / Mainstream Branch
Jazzy Jalisco  
Humble Hawksbill  

Installation

Docker Container

see available images for tomoyafujita/ros2ai@dockerhub

docker run -it --rm --net=host -e OPENAI_API_KEY=$OPENAI_API_KEY tomoyafujita/ros2ai:humble

[!NOTE] OPENAI_API_KEY environmental variable is not required if using Ollama. And it is expecting that Ollama runs on the host system mostly, so that container is bound to the host network interface.

https://github.com/fujitatomoya/ros2ai/assets/43395114/2af4fd44-2ccf-472c-9153-c3c19987dc96

Required Package

  • rolling / jazzy
  pip install openai ollama validators --break-system-packages --ignore-installed
  

[!NOTE] see PEP 668 – Marking Python base environments as “externally managed” why --break-system-packages is required.

  • humble
  pip install openai ollama validators --ignore-installed
  

Build

No released package is available, needs to be build in colcon workspace.

source /opt/ros/rolling/setup.bash
mkdir -p colcon_ws/src
cd colcon_ws/src
git clone https://github.com/fujitatomoya/ros2ai.git
cd ..
colcon build --symlink-install --packages-select ros2ai

Usage

Prerequisites

As described in overview diagram, ros2ai uses only OpenAI Python API but backend implementation can be replaced with Ollama that provides the compatible API with OpenAI. User need to choose either of them is used by ros2ai as following configuration, otherwise it falls back to use OpenAI.

  export OPENAI_API_KEY='your-api-key-here'
  

[!CAUTION] Do not share or expose your OpenAI API key.

  ### Install Ollama and System Service
  sudo curl -fsSL https://ollama.com/install.sh | sh
  ### Check ollama.service is up and running
  systemctl status ollama
  ### Pull llama3.1 (for example) model
  ollama pull llama3.1
  ### List available models
  ollama list
  

Optional

environmental variable default Note
OPENAI_API_KEY None. Required for OpenAI
OPENAI_MODEL_NAME ‘gpt-4o’ AI model to be used. e.g) llama3.1 (Ollama)
OPENAI_ENDPOINT ‘https://api.openai.com/v1’ API endpoint URL. e.g) http://127.0.0.1:11434/v1 (Ollama)
OPENAI_TEMPERATURE 0.5 OpenAI temperature

[!NOTE] These are optional environmental variables. if not set, default value will be used.

Examples

Basics

  • configuration
  ### OpenAI configuration
  export OPENAI_API_KEY=<YOUR_API_KEY>
  export OPENAI_MODEL_NAME=gpt-4
  export OPENAI_ENDPOINT=https://api.openai.com/v1

  ### Ollama
  unset OPENAI_API_KEY
  export OPENAI_MODEL_NAME=llama3.1
  export OPENAI_ENDPOINT=http://127.0.0.1:11434/v1
  
  • status to check OpenAI API key is valid.
  root@tomoyafujita:~/docker_ws/ros2_colcon# ros2 ai status -v
  ----- api_model: gpt-4
  ----- api_endpoint: https://api.openai.com/v1
  ----- api_token: None
  As an artificial intelligence, I do not have a physical presence, so I can't be "in service" in the traditional sense. But I am available to assist you 24/7.
  [SUCCESS] Valid OpenAI API key.
  
  • query to ask any questions to ROS 2 assistant.
  root@tomoyafujita:~/docker_ws/ros2_colcon# ros2 ai query "Tell me how to check the available topics?"
  To check the available topics in ROS 2, you can use the following command in the terminal:

  ---
  ros2 topic list
  ---

  After you enter this command, a list of all currently active topics in your ROS2 system will be displayed. This list includes all topics that nodes in your system are currently publishing to or subscribing from.
  
  • exec that ROS 2 assistant can execute the appropriate command based on your request.
  root@tomoyafujita:~/docker_ws/ros2_colcon# ros2 ai exec "give me all nodes"
  /talker
  root@tomoyafujita:~/docker_ws/ros2_colcon# ros2 ai exec "what topics available"
  /chatter
  /parameter_events
  /rosout
  root@tomoyafujita:~/docker_ws/ros2_colcon# ros2 ai exec "give me detailed info for topic /chatter"
  Type: std_msgs/msg/String
  Publisher count: 1
  Subscription count: 0
  

Multiple Language

  • Japanese (could be any language ❓)
  root@tomoyafujita:~/docker_ws/ros2_colcon# ros2 ai query "パラメータのリスト取得方法を教えて"
  ROS 2のパラメータリストを取得するには、コマンドラインインターフェース(CLI)を使います。具体的には、次のコマンドを使用します:

  ---code
  ros2 param list
  ---

  このコマンドは、現在動作しているすべてのノードのパラメーターをリストアップします。特定のノードのパラメータだけを見たい場合には、以下のようにノード名を指定することもできます。

  ---code
  ros2 param list /node_name
  ---

  このようにして、ROS2のパラメータリストの取得を行うことが可能です。なお、上述したコマンドはシェルから直接実行してください。
  

Reference

Special thanks to OpenAI API and Ollama 🌟🌟🌟

CHANGELOG

Changelog for package ros2ai

0.1.0 (2023-11-11)

  • 1st commit.
  • Add ros2ai command.
  • Contributors: Tomoya Fujita

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged ros2ai at Robotics Stack Exchange

No version for distro noetic. Known supported distros are highlighted in the buttons above.
No version for distro ardent. Known supported distros are highlighted in the buttons above.
No version for distro bouncy. Known supported distros are highlighted in the buttons above.
No version for distro crystal. Known supported distros are highlighted in the buttons above.
No version for distro eloquent. Known supported distros are highlighted in the buttons above.
No version for distro dashing. Known supported distros are highlighted in the buttons above.
No version for distro galactic. Known supported distros are highlighted in the buttons above.
No version for distro foxy. Known supported distros are highlighted in the buttons above.
No version for distro iron. Known supported distros are highlighted in the buttons above.
No version for distro lunar. Known supported distros are highlighted in the buttons above.
No version for distro jade. Known supported distros are highlighted in the buttons above.
No version for distro indigo. Known supported distros are highlighted in the buttons above.
No version for distro hydro. Known supported distros are highlighted in the buttons above.
No version for distro kinetic. Known supported distros are highlighted in the buttons above.
No version for distro melodic. Known supported distros are highlighted in the buttons above.