Quick start with coding on QTrobot
This document guides you towards quick start coding on the QTrobot using programming languages. If you are looking for graphical programming, please take a look at Quick start with QTrobot studio.
1. Understanding QTrobot architecture
QTrobot is a high-end research platform with powerful computers and state-of-the-art hardware such as 3D camera and far-field microphone array. It comes with two computers: i) QTRP, a Raspberry Pi based computer to control the main hardware and ii) QTPC, which can be an Intel® NUC i5/i7 PC or Nvidia Jetson AGX Orin, to provide more computational power and to accelerate software development cycle. Both computers run on Ubuntu/Debian Linux operating systems and leverage ROS to offer easy-to-use yet very flexible software architecture. QTrobot's hardware is easily extendable via USB-C and USB adaptors, for example, to connect external monitor, keyboard and mouse. QTrobot also provides a rich set of APIs for several programing languages such as C++, Python and JavaScript.
As it is shown in the following diagram, QTrobot consists of two computers, one in the QTrobot head (QTRP) and the other in the body (QTPC), which are internally connected via ethernet cable. All of the QTrobot devices such as display, speakers, microphone and motors are connected to QTRP except the 3D Camera which is connected directly to QTPC. The Wi-Fi of the QTRP is used to create the QTrobot hotspot with the same SSID as the robot’s serial number (e.g. QTRD000101).
Both computers are configured to interact in one ROS environment. Upon starting the QTrobot, QTRP runs the roscore and initializes the ROS environment. It also turn on QTPC via wake-on-lan when the ROS environment is up (check under Turn on QTrobot for AI@Edge version). You will also find two USB port at the back of the QTrobot. In QTrobot NUC version: one of them is attached to QTRP and the second one (USB-C) is connected to QTPC. This USB-C port can be used to connect keyboard,mouse and monitor via a USB-C extension hub to QTPC. In QTrobot AI@Edge version: one of the USB is connected to QTRP and the other one to QTPC. To connect monitor you need to use Display Port on the back of the QTrobot.
QTPC is already configured to work with roscore which is running on QTRP and you can access all QTrobot ROS services ands topics.
2. Prepare your setup
There are few ways of developing code for QTrobot. We strongly recommend you to start developing directly on QTrobot's integrated QTPC. As it is shown in the following picture, you need to prepare:
a keyboard,
a mouse,
and a monitor with HDMI/Display Port cable.
Step 1. Connect keyboard/mouse and monitor to QTPC
Connect keyboard, mouse and HDMI Monitor to your USB-C extension then plug it in the USB-C port at the back of QTrobot.
- Connect the monitor with provided Display Port - HDMI cable to the Display Port on the back of the QTrobot.
- Connect the mouse and the keyboard to the USB below the Display port which is connected to QTPC
Step 2. Turn on QTrobot
To power the QTrobot on, simply connect the QTrobot's power supply1.This triggers the power on process and your QTrobot becomes ready less than a minute. After powering on, you can see the QTrobot face is on and the motors are in their home position. If the QTrobot is already connected to the power supply simply push the power button to turn on the QTrobot.
To power on QTrobot, plug it in using the provided power supply. To turn it off, press the power button on the back and wait for it to completely shut down. Always unplug QTrobot from the power supply before turning it on again. Note that pressing the power button does not turn on the QTPC (Nvidia Jetson).
Step 3. Wait for QTPC to boot
After you turned on your QTrobot it will need some time until your QTPC turns on, because QTRP will turn on QTPC after ROS environment is up. You will see the Ubuntu desktop of QTPC and you can use in the same way you use a standard desktop for development.
To power off the QTrobot simply press the power button on the back of the QTrobot. This will turn off both QTRP and QTPC. Wait enough for QTrobot to turn off before unplugging it from power supply: a blue screen shows up immediately goes off.
Now you should be all settled and ready for coding. However, in most cases you need to have access to the internet. So let's follow the next section to connect your QTrobot to your home/office router and the Internet.
3. Connect QTrobot to a home network and Internet
To have access to the internet from all machines (as it is demonstrated in the following diagram_, the Wi-Fi of QTRP should be connected to your home router. The internet from the home router, is shared to all other machines (including QTPC) via QTRP. The green arrows shows the direction and how internet shared between QTRP and QTPC.
Therefore, you need to connect the QTRP to your home router's Wi-Fi. To do that do the following steps:
Step 1. Access QTRP via ssh from QTPC
From the Ubuntu desktop of QTPC, open a terminal and access QTRP via ssh:
ssh developer@192.168.100.1
# or ssh developer@QTRP
For the password use qtrobot
.
Step 2. Configure qt_wlan0_client service
First, edit the /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
file to update ssid
and psk
accordingly.
cd /etc/wpa_supplicant
sudo nano wpa_supplicant-wlan0.conf
set the ssid
(your router ssid) and psk
(your router passphrase) of your home router setup:
country=LU
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="<your router SSID>"
psk="<your router passphrase>"
}
Next, restart the qt_wlan0_client
service:
sudo systemctl restart qt_wlan0_client.service
- Pay attention that the values for ssid and psk are wrapped with double quotation marks!
- Pay attention to the
<TAB>
before ssid and psk! - Do not create or change any other files related to wpa_supplicant or systemd network! this may break your QTrobot network setup!
- Ensure that you are modifying the
wpa_supplicant-wlan0.conf
file and NOTwpa_supplicant.conf
Step 3. Test and make it permanent
After following the above steps, your QTrobot should be connected to your home/office network and have access to the Internet (i.e. you should be able to ping www.google.com
for example).
ping www.google.com
Disable the qt_wlan0_ap
service and enable the qt_wlan0_client
service to keep QTrobot internet configuration permanent:
sudo systemctl enable qt_wlan0_client.service
sudo systemctl disable qt_wlan0_ap.service
You are all settled! QTRP gets internet connection from your router and will automatically share it with QTPC and any other devices connected to QTrobot Wi-FI hotspot.
- Check if QTrobot is connected to your home/office network. Run the following command on QTRP via ssh: sudo wpa_cli -i wlan0 status. You should see wpa_state=COMPLETED and the correct ssid is reported.
- Double check that you have entered correct values for ssid and psk in /etc/wpa_supplicant/wpa_supplicant-wlan0.conf!
- See the status of the qt_wlan0_client service for any typo or misformatted lines in /etc/wpa_supplicant/wpa_supplicant-wlan0.conf. To do that, run the following command on QTRP: sudo systemctl status qt_wlan0_client.service this should shows that the service is running and active. If not, follow the error messages reported by the service.
- If you are connected to your home/office network (by checking the previous command) but still does not have access to the internet (e.g. cannot ping google), please double check that your home/office network providing any internet connection!
For more informations about QTrobot's networking and to learn how to re-enable QTrobot's hotspot, please check Computation and networking.
4. Optional ways of working with QTrobot
1. Accessing and Programming QTrobot via SSH
You can access and program QTrobot remotely from your laptop via SSH. To do this, you need to connect to QTPC's terminal using SSH.
SSH to QTrobot in Hotspot Mode (Offline):
If your QTrobot is not connected to any Wi-Fi network, it will automatically enter hotspot mode. You can connect to its hotspot using the following steps:
- From your laptop, search for the QTrobot's hotspot Wi-Fi, which is named after its serial number (e.g., QTRD000123).
- Connect to the hotspot using the password:
11111111
. - Once connected, you can access the QTPC via SSH (the default SSH password is
qtrobot
):ssh qtrobot@192.168.100.2
# enter the password
SSH to QTrobot in Online Mode (Connected to Wi-Fi)
If your QTrobot is connected to your Wi-Fi network, follow these steps to find its IP address and establish an SSH connection:
-
Find QTrobot's (QTRP) IP Address: You can obtain the IP address of QTRP by either of the following methods:
-
Using
ifconfig
on QTRP (accessed via QTPC with display and keyboard): first, connect to QTPC using a display and keyboard, then run theifconfig
command on QTRP:# From QTPC:
ssh qtrp ifconfing
# look for the ip address of wlan0 interface. e.g:
# wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
# inet 192.168.80.3 netmask 255.255.255.0 broadcast 192.168.80.255 -
Using Ping with QTrobot Serial Number: Alternatively, you can try pinging the robot using its serial number (e.g., QTRD000123):
# From your computer
ping QTRD000123.local
# example:
# Pinging QTRD000320.local [192.168.80.3] with 32 bytes of data:
# Reply from 192.168.80.3: bytes=32 time=5ms TTL=64Note: This method may not work on all Wi-Fi networks, depending on your network's configuration.
-
-
SSH into QTPC: Once you have the IP address for QTRP (e.g., 192.168.80.3), you can SSH into QTPC using the following command (the default SSH password is
qtrobot
):ssh -o UserKnownHostsFile=/dev/null -J developer@192.168.80.3 qtrobot@qtpc
# enter the passwordAlternative Method: If you prefer, you can first SSH into QTRP, then connect to QTPC:
ssh developer@192.168.80.3
# enter the password
su qtrobot
# enter the password
ssh qtpc
2. Programming QTrobot from your computer via ROS
You can program QTrobot directly from your computer using ROS. To do this, ensure that ROS is installed on your system. If you haven't installed ROS yet, please follow the official installation instructions. Next, follow these instructions to set up your ROS environment:
Setup your ROS environment
Clone QTrobot Software repository.
cd ~/; git clone https://github.com/luxai-qtrobot/software.git
Copy the headers
folder (or make a link in your Catkin source workspace) and build the messages:
cd ~/catkin_ws/src
ln -s ~/software/headers ./
cd ~/catkin_ws
catkin_make
Next, you'll need to configure your ROS environment to connect to QTrobot. Follow these steps:
Connect to QTrobot's Wi-Fi:
- If QTrobot is offline, connect to its Wi-Fi hotspot.
- If QTrobot is online, connect to the same Wi-Fi network that QTrobot is connected to.
Find Your IP Address:
- Open a terminal on your laptop and run the following command to retrieve your IP address:
ifconfig
- Look for the inet address under the Wi-Fi interface (e.g., 192.168.4.25):
wifi0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.4.25 netmask 255.255.255.0 broadcast 10.42.0.255
...
Configure ROS Environment variables:
- Edit the
~/.bash_aliases
file on your computer and add the following lines. ReplaceROS_IP
with the IP address you retrieved in the previous step, and setROS_MASTER_URI
to your QTrobot's serial number.source /opt/ros/noetic/setup.bash
source ~/catkin_ws/devel/setup.bash
## QTrobot
export ROS_IP=<your PC IP address> # e.g. 192.168.4.25
export ROS_MASTER_URI=http://<your QTrobot serial>:11311 # e.g. http://QTRD000100.local:1131 - To apply these changes, run the following command:
source ~/.bash_aliases
Test your setup
To verify the connection, you can list all ROS topics running on QTrobot by executing the following command:
rostopic list
If everything is configured correctly, you should see an output similar to the one below:
/rosout
/qt_robot/audio/play
/qt_robot/behavior/talkAudio
/qt_robot/emotion/show
/qt_robot/gesture/play
/qt_robot/head_position/command
/qt_robot/joints/state
...
You can also test the connection by calling one of QTrobot's ROS interfaces, for example:
rosservice call /qt_robot/speech/say "message: 'Hello.'"
If successful, QTrobot will say "Hello."
Troubleshooting
If you experience issues such as delayed responses when calling rosservice
from your laptop while connected to QTrobot's hotspot (Offline Mode), follow these steps:
-
Add the following line to the
/etc/hosts
file on your laptop:192.168.4.1 <your QTrobot serial> # e.g. QTRD000100.local
If you encounter delays when calling rosservice
while QTrobot is connected to an external Wi-Fi network (Online mode), follow these steps:
-
First, find the QTrobot's IP address by connecting to QTPC and running:
ifconfig wlan0
-
Then, add the QTrobot's IP address to the
/etc/hosts
file on your laptop:192.168.3.193 <your QTrobot serial> # e.g. QTRD000100.local
If you face issues such as errors communicating with services or reading topics running on QTPC (e.g., "ERROR: Unable to communicate with service..."), follow these steps:
-
Find your laptop’s Wi-Fi interface name by running:
ifconfig -a # e.g., wlan0
-
Add the following route on your laptop to communicate with the services:
sudo ip route add 192.168.100.0/24 via <your QTrobot IP> dev <Wi-Fi interface name>
# e.g., sudo ip route add 192.168.100.0/24 via 192.168.3.193 dev wlan0
Congratulation. You are all settled and ready to start programming with QTrobot. Now you can follow plenty of exciting Tutorials.
Footnotes
-
Only use the provided power supply with your QTrobot. ↩