ros2ai

ros2ai

ros2ai is a next-generation ROS 2 command line interface extension with AI such as OpenAI

Stars: 109

Visit
 screenshot

ros2ai is a next-generation ROS 2 command line interface extension with OpenAI. It allows users to ask questions about ROS 2, get answers, and execute commands using natural language. ros2ai is easy to use, especially for ROS 2 beginners and students who do not really know ros2cli. It supports multiple languages and is available as a Docker container or can be built from source.

README:

humble iron rolling

ros2ai 🤖

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

see overview slide deck for more information.

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.

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
Iron Irwini
Humble Hawksbill

[!NOTE] Verified on Ubuntu 22.04 Jammy Jellyfish only, other platform would also work.

Installation

Docker Container

see available images for tomoyafujita/ros2ai@dockerhub

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

[!NOTE] OPENAI_API_KEY environmental variable must be set

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

Required Package

pip install openai

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

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

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

Optional

environmental variable default Note
OPENAI_MODEL_NAME 'gpt-4' AI model to be used.
OPENAI_ENDPOINT 'https://api.openai.com/v1' API endpoint URL.
OPENAI_TEMPERATURE 0.5 OpenAI temperature

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

Examples

Basics

  • 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

Watch the video

Special thanks to OpenAI API 🌟🌟🌟

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for ros2ai

Similar Open Source Tools

For similar tasks

For similar jobs