Run Demo node
A demo node has been developed to help developer getting started with Probot. The demo node leverages an LLM to allow the probot to seeamsly interact with a user. The main objective of the Demo node is to showcase the functionality of the topics provided by the base package of Probot wich exposes the base functionalities
- Face ui
- Touch sensors
- Servo control (via ros2_control)
And extra functionalities such as:
- TTS
- STT
Installing dependencies
To run the demo code you will need to install the following dependencies
Creating virtual enviorment
Since the demo node is developed in python can be a good approach to install all the python dependencies into a virtual enviorment wich help decouple and isolate Python installs and associated pip packages. This allows end-users to install and manage their own set of packages that are independent of those provided by the system or used by other projects.
The first step is to open a terminal into the root of our ros workspace and run:
python3 -m venv .venv
This will create a virtual enviorment in the .venv folder.
After created, we need to activate the virtual envirment by running
source .venv/bin/activate
If the virtual enviorment is activate succesfully it will appear near the username in the terminal like so:
(.venv) user@protomrobotics-ros2:~/Desktop/probot_test$
Next we need to install the python dependencies required by the demo by running:
pip install openai
🛈 Info
The steps above are optional since it's possible to install the node dependencies system wide by running
pip install openaiin the terminal
Run the demo
Befor running the demo we need to start the stt and tts nodes on the robot, to do so we need to establish an ssh connection by running:
ssh probot@<PROBOT-IP-ADDRESS>
Once connected to the robot run:
ros2 run probot_voice_stt probot_stt --ros-args -p provider:=azure -p azure_key:=$AZURE_KEY -p azure_region:=$AZURE_REGION
ros2 run probot_voice_tts probot_tts --ros-args -p provider:=azure -p azure_key:=$AZURE_KEY -p azure_region:=$AZURE_REGION
This will start the TTS and STT Node used by the demo node running on our machine.
Next, back on our machine we need to configure the demo node launch file to be able to connect to an OpenAI compatible llm service (either local or cloud). To apply the configuration open the the file src/probot_coordinator/launch/probot_coordinator.launch.py and configure the LLM_URL and LLM_KEY
import launch
from launch_ros.actions import Node
LLM_URL = 'http://localhost:11434/v1'
LLM_KEY = '<YOUR-LLM-API-KEY>'
def generate_launch_description():
return launch.LaunchDescription([
# Coordinator Node
Node(
package='probot_coordinator',
executable='coordinator',
name='chat_gpt_coordinator',
parameters = [{
'llm_url' : LLM_URL,
'llm_key' : LLM_KEY,
'system_prompt': 'Rispondi in modo breve. Usa un tono accomodante e cortese, non usare punti elenco, non usare periodi lunghi. Si conciso nelle risposte e nel saluto.'
}]
),
])
As you can see from the launch file above we are using a local LLM running on the machine, in case we need to use services like ChatGPT just set LLM_URL as an empty string and set LLM_KEY to a valid ChatGPT API key.
Once configured the node, move into the root of our ros workspace and run:
colcon build --symlink-install
source install/setup.sh
🛈 Info
If you are using created a virtual enviorment you will need to run
. install/setup.sh && export PYTHONPATH=$PYTHONPATH:$(pwd)/.venv/lib/python3.10/site-packagesin the terminal
Then to launch the demo node run
ros2 launch probot_coordinator probot_coordinator.launch.py