Coder Social home page Coder Social logo

aniskoubaa / rosgpt Goto Github PK

View Code? Open in Web Editor NEW
296.0 14.0 64.0 75 KB

ROSGPT is a pioneering approach that combines the power of ChatGPT and ROS (Robot Operating System) to redefine human-robot interaction. By leveraging large language models like ChatGPT, ROSGPT enables the conversion of unstructured human language into actionable robotic commands. T

Python 75.39% HTML 9.73% JavaScript 12.64% CSS 2.24%

rosgpt's Introduction

ROSGPT: ChatGPT Interface for ROS2 for Human-Robot Interaction

ROSGPT is a pioneering approach that combines the power of ChatGPT and ROS (Robot Operating System) to redefine human-robot interaction. By leveraging large language models like ChatGPT, ROSGPT enables the conversion of unstructured human language into actionable robotic commands. This repository contains the implementation of ROSGPT, allowing developers to explore and contribute to the project.

Reference Paper

DOI

Author: Anis Koubaa

Citation: Koubaa, A. (2023). ROSGPT: Next-Generation Human-Robot Interaction with ChatGPT and ROS. Preprints.org, 2023, 2023040827. https://www.preprints.org/manuscript/202304.0827/v2

BibTeX Citation:

@article{koubaa2023rosgpt,
  title={ROSGPT: Next-Generation Human-Robot Interaction with ChatGPT and ROS},
  author={Koubaa, Anis},
  journal={Preprints.org},
  year={2023},
  volume={2023},
  pages={2023040827},
  doi={10.20944/preprints202304.0827.v2}
}

Video Demo

Explore ROSGPT in action with this video demonstration, showcasing the process of getting started and the capabilities of the system.

ROSGPT Video Demonstration

ROSGPT ROS2 Package Description

The ROSGPT ROS2 package includes a collection of scripts that work together to provide a convenient way of translating natural human language text into structured JSON commands, which can be utilized by robots like Turtlesim and Turtlebot3. Below is a brief overview of each script:

  • rosgpt.py: This script creates the ROSGPT node, which is a ROS2 node with a REST server that takes in POST requests containing natural human language text. It then translates the text into structured JSON commands via an API call to ChatGPT. The script also defines an ontology-based prompt that helps ChatGPT convert human commands into JSON commands. The ROSGPT node publishes the JSON command on the /voice_cmd topic.
  • rosgpt_client_node.py: This script establishes a ROS2 client node that sends POST requests with natural human language text to the ROSGPT REST server. It waits for the structured JSON commands and displays them upon receipt. Use the ros2 run command to execute this node.
  • rosgpt_client.py: Similar to rosgpt_client_node.py, this script sends POST requests with natural human language text to the ROSGPT REST server, but without implementing a ROS2 node. It solely functions as a REST client for ROSGPT. Use the python command, not ros2 run, to execute this script.
  • rosgptparser_turtlesim.py: This script implements the ROSGPTParser, which subscribes to the /voice_cmd topic and receives JSON commands. The node parses the JSON command and determines the ROS2 primitives required to execute the specified tasks. In this script, a simple navigation task for the Turtlesim robot is considered, including move and rotate functions.
  • rosgptparser_tb3_nav.py: This script also implements the ROSGPTParser, subscribing to the /voice_cmd topic and receiving JSON commands. The JSON commands are parsed and transformed into navigation goal tasks for the Turtlebot3 robot.

Getting Started

To get started with ROSGPT, follow these steps:

  1. Clone the repository to your local machine.
  2. Install the dependencies listed in the environment setup section.
  3. After following the environment setup steps, run the ROSGPT flask server using
    ros2 run rosgpt rosgpt
  4. Run the turtlesim node using
    ros2 run turtlesim turtlesim_node
  5. Run the rosgptparser_turtlesim.py using
    ros2 run rosgpt rosgptparser_turtlesim 
  6. Run the rosgpt_client_node.py using
    ros2 run rosgpt rosgpt_client_node 
  7. Now you can start giving commands to the robot using the rosgpt_client_node terminal .for example you can say "ı want that you move forward 1 meter speed 1" and the robot will move forward 1 meter with speed 1.

Environment Setup

This ROS 2 package was tested using ROS 2 Humble with Ubuntu 22.04. It should also work with ROS 2 Foxy and other ROS 2 versions. You need to install the following dependencies:

  • Add your OpenAI API Key in your .bashrc as an environment variable

    echo 'export OPENAI_API_KEY=your_api_key' >> ~/.bashrc
    
  • Install the dependencies required for the text-to-speech functionality

    sudo apt-get install libespeak1
    sudo apt install ros-humble-turtlesim*
  • For ros2 Humble verison (Ubuntu 22.04) downgrading the setuptools is required

    pip3 install --upgrade setuptools==58.0.2
  • Install python dependencies

    cd rosgpt
    pip3 install -r requirements.txt
  • then build the package

    colcon build --packages-select rosgpt
  • source the workspace

    source install/setup.bash

To get started with ROSGPT, got this section Getting Started

ROSGPT REST API

The ROSGPT REST API is a convenient way of interacting with ROSGPT. It allows you to send POST requests with natural human language text to the ROSGPT server, which will then translate the text into structured JSON commands. The JSON commands can be used to control robots like Turtlesim and Turtlebot3.

To use the ROSGPT REST API, follow these steps:

  1. Run the ROSGPT flask server using ros2 run rosgpt rosgpt.
  2. Run the turtlesim node using ros2 run turtlesim turtlesim_node.
  3. Run the rosgptparser_turtlesim.py using ros2 run rosgpt rosgptparser_turtlesim.
  4. Run the rosgpt_client.py using python rosgpt_client.py.
  5. Send a POST request to the ROSGPT server using curl -X POST -H "Content-Type: application/json" -d '{"text":"move forward"}' http://localhost:5000/rosgpt. You can replace "move forward" with any natural human language text you want. The ROSGPT server will translate the text into structured JSON commands and send them back to the client.
  6. The client will display the JSON commands on the terminal. You can use these commands to control the Turtlesim robot.

ROS1 Support

ROS1 is an earlier version of the Robot Operating System (ROS), which is still widely used in many robotics applications. While ROSGPT was originally developed for ROS 2 Humble on Ubuntu 22.04, we recognize the importance of supporting ROS1 as well.

To use ROSGPT with ROS1, you will need to modify the ROS 2 code in the scripts to the corresponding ROS 1 code. We are actively working on developing this functionality, but it is still a work-in-progress.

If you have already developed an extension to enable ROSGPT to work with ROS1, we would love to hear from you! Please create a pull request in a new branch and we will review it for inclusion in the ROSGPT repository.

License

This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License. You are free to use, share, and adapt this material for non-commercial purposes, as long as you provide attribution to the original author(s) and the source.

Contribute

As this project is still under progress, contributions are welcome! To contribute, please follow these steps:

  1. Fork the repository on GitHub.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes and push them to your fork.
  4. Create a pull request to the main repository.

Before submitting your pull request, please ensure that your changes do not break the build and adhere to the project's coding style.

For any questions or suggestions, please open an issue on the GitHub issue tracker.

rosgpt's People

Contributors

aniskoubaa avatar rgruberski avatar mustafabozkaya avatar

Stargazers

Park Jae Kwan avatar fish-zt avatar Duy Ngo Manh avatar ananya avatar Bowei avatar Kirill Marakulin avatar Tianyu Qiu avatar Emanuele Nicotra avatar Ruoxiang LI avatar  avatar Daniel Eneh avatar Emre Sebat avatar Wenxuan avatar Weibin avatar WU MENGHUNG avatar Mark Soulier avatar Dave Parslow avatar shamisen avatar Yash More avatar  avatar Hanlin Wang avatar  avatar Gabriel de Almeida Spadafora avatar wukun avatar  avatar Irene Bandera Moreno avatar 荔枝王 avatar Yiu chi Wai avatar Aleyna avatar Kevin Stark avatar Hamdi Sharaf avatar Yifei Cheng avatar  avatar Joe Lisk avatar Ben Duffy avatar  avatar Furkan Sarıyıldız avatar FoundWay Studio avatar ddaa avatar Koray avatar Barış Ata avatar ZiSeoi Wong avatar  avatar  avatar wanghm avatar Muhammad Ashfaq avatar Hideyuki Tachibana avatar Ariel Yang avatar Ali Syauqi Bilfaqih avatar Földi Tamás avatar Mohammed S. avatar Glenn avatar  avatar  avatar Abdallah Nomeer avatar  avatar  avatar  avatar Samuel A. Prieto avatar  avatar  avatar  avatar Cassidy Caid avatar Silvia Santano avatar  avatar  avatar  avatar SnoopyRui avatar  avatar ZZ_Min avatar Ahmad avatar Xiaoqing Zhu avatar Yee avatar CHOI WOEN-SUG avatar Sumedh S Vijay avatar Faisal Altassan avatar Saurabh Gupta avatar  avatar Sungboo Yoon avatar 宇宙爆肝锦标赛冠军 avatar  avatar PixelCloud avatar Joerg avatar siyuan avatar Magic Pony avatar Matias B avatar Bilel Benjdira avatar Enes Erdogan avatar Chanjoon Park avatar Rakhim Abdullayev avatar 蜂蜜柚子茶 avatar Christian Pfitzner avatar Bernard Van Haecke avatar Srividya Prasad avatar Aditya Penumarti avatar  avatar Felix Yustian Setiono avatar Joy avatar Mohamed khalil kahlaoui avatar Kalash Jain avatar

Watchers

Tara W avatar HY avatar Max avatar  avatar zeidk avatar  avatar Silvia Santano avatar gxzhou avatar  avatar Sreenath R avatar  avatar  avatar  avatar Duy Ngo Manh avatar

rosgpt's Issues

How to use Speech to Text feature?

I opened the html page from the webpage folder in Chrome browser allow the microphone and select start recording, say "Move robot 1m with speed 0.3" and send the command, but it does not move the turtle while I could see my voice was detected by the GPT. The issue is that it is get converted to text and command for the turtle. Can anybody help me with the issue?

QUESTION: This repo can it be used for ROS1, or is it only available for ROS2

Currently, I'm using ubuntu 20.04 and Noetic version, it mean ROS1 was used right now for me.
I have watched demo video and article, it so amazing, I'm very exicited.
Therefore, I want to apply it to my final project at school, send voice comand to control robot.
But I see you implemented on ROS2, so I scared that this repo still not can be used to for ROS1, right?

I hope will get the soon answer from you!!!!

Best regard!!!

AttributeError: type object 'type' has no attribute '_TYPE_SUPPORT' This might be a ROS 1 message type but it should be a ROS 2 message type. Make sure to source your ROS 2 workspace after your ROS 1 workspace.

Hi, I'm now using ros2 foxy. When I run the command ros2 run rosgpt rosgptparser_turtlesim, I got the following error:

Traceback (most recent call last):
  File "myfolder/rosgpt/install/rosgpt/lib/rosgpt/rosgptparser_turtlesim", line 33, in <module>
    sys.exit(load_entry_point('rosgpt==0.0.1', 'console_scripts', 'rosgptparser_turtlesim')())
  File "myfolder/rosgpt/install/rosgpt/lib/python3.8/site-packages/rosgpt/rosgptparser_turtlesim.py", line 179, in main
    node = TurtlesimController()
  File "myfolder/rosgpt/install/rosgpt/lib/python3.8/site-packages/rosgpt/rosgptparser_turtlesim.py", line 32, in __init__
    self.create_subscription(String,'/voice_cmd',self.voice_cmd_callback,10)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py", line 1205, in create_subscription
    check_for_type_support(msg_type)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/type_support.py", line 20, in check_for_type_support
    ts = msg_type.__class__._TYPE_SUPPORT
AttributeError: type object 'type' has no attribute '_TYPE_SUPPORT' This might be a ROS 1 message type but it should be a ROS 2 message type. Make sure to source your ROS 2 workspace after your ROS 1 workspace.

Could you help check what leads to this issue? Thank you!

SetuptoolsDeprecationWarning depraceted warning

/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(

how can ı fix this error

I find a problem after watch the video

you see, when you want to say something or write something, you must "send" them and then GPT can receive。 if I say something, chatGPT can receive them without sending operation, it will be better.

error 404

[ERROR] [1715579908.467284950] [rosgpt_client]: Error: 404
Enter a move command or a rotate command. The current ROSGPTParser of rosgpt_turtlesim does not multiple command. Will be extended later.
tried modifying the codes, the error persists. anyone know the cause?

ros2 run rosgpt rosgpt_client_node

Please somebody tell me what could be the reason? I am getting the following error.

tufail39@tufail39-VirtualBox:~$ ros2 run rosgpt rosgpt_client_node
[INFO] [1704385697.602028953] [rosgpt_client]: ROSGPT client node started
Enter a move command or a rotate command. The current ROSGPTParser of rosgpt_turtlesim does not multiple command. Will be extended later
Enter a text command: I want that you move 1 meter forward speed 0.2
[ERROR] [1704385738.657950074] [rosgpt_client]: Error: 500

ROS 1 port

Hi,

Many thanks for sharing this. I am interested in porting the code to ROS 1

You mentioned in your readme that:

"To use ROSGPT with ROS1, you will need to modify the ROS 2 code in the scripts to the corresponding ROS 1 code. We are actively working on developing this functionality, but it is still a work-in-progress."

I wondered if there are any particular hurdles that you are aware of, in the way, to make this happen - besides porting the node code from ROS 2 to 1.

Any tips or advice would be most appreciated.

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.