Skip to content

robosoft-ai/robosoft_openai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5f4d674 · Jul 29, 2024

History

9 Commits
Jul 7, 2024
Jul 11, 2024
Jul 29, 2024
Jul 6, 2024
Jul 6, 2024
Jul 6, 2024
Jul 6, 2024
Jul 16, 2024
Jun 30, 2024
Jul 16, 2024
Jul 16, 2024
Jul 16, 2024

Repository files navigation

robosoft_openai

OpenAI server node for ROS2 Applications

What is this useful for?

If you don't have an image processing pipeline or a GPU on your robot, calls to OpenAI can replace much of that functionality. As of July 2024 we generally recommend yes/no questions, otherwise you will need to parse the response yourself. This package includes a simple filter which parses for yes/no. For example:

  • Is it safe for the robot to drive forward? Please respond in one word, yes or no.
  • Is the door open? Please respond in one word, yes or no.
  • Is there a customer at that table? Please respond in one word, yes or no.
  • Did the robot successfully grasp the cube? Please respond in one word, yes or no.
  • Does the control panel look identical to the last time I checked? Please respond in one word, yes or no.

Some of these examples are useful for reinforcement learning, i.e. for determining if a reward was earned.

Setup

Requires an OpenAI key as described here: https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key

Set it as an environment variable: export OPENAI_API_KEY="..."

Dependencies

sudo apt install -y libcurl4-openssl-dev

sudo apt install -y nlohmann-json3-dev

sudo apt install -y libb64-dev

Run

Here's a quick example:

ros2 run robosoft_openai openai_server

Send it a prompt. Here's an example that returns a bool from a yes/no question. Note that the image field of the service request may be left empty...

ros2 service call /openai_server ai_prompt_msgs/srv/StringImagePrompt prompt:\ "Are you a pirate? Please respond with a one-word answer, yes or no"

Here's an example that returns a full string...

ros2 service call /openai_server ai_prompt_msgs/srv/StringImagePrompt prompt:\ "Are you a pirate?"

Here's an example client which sends an image of a wooden table and prompts whether it is indeed a wooden table:

ros2 run robosoft_openai example_client

Citation

If you use this work, please cite it like so:

About

OpenAI server node for ROS2 Applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published