Skip to main content
Version: QTrobot V1

QTrobot Computation and networking

QTrobot comes with two computers: i) QTRP, a Raspberry Pi based computer to control the main hardware and ii) QTPC, an Intel® NUC i5/i7 PC 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 and sensors.

display

As it is shown in the above diagram, QTRP (in QTrobot's head) is internally connected to QTPC (in QTrobot's body) 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).

Operating systems

The older versions of QTrobot came with Ubuntu 16. However, we have updated the operating system of both integrated QTrobot’s computers to the latest stable version of Linux. The Nuc PC (QTPC) comes with Ubuntu 20.04 LTS and the Raspberry Pi board (QTRP) at the head uses the latest version of Raspberry Pi OS (Debian Buster). Both computers are updated to latest stable version of ROS Noetic with Python 3 as default. The latest is particularly interesting because its opens accessing wider list of open-source software and libraries which use Python 3 such as recent machine and deep learning libraries, voice processing and recognition software.

Networking

One of the very interesting features of the recent QTrobots, is the new networking architecture. The following diagram demonstrates a common scenario where different devices (e.g., laptops) are connected to the QTrobot via its Wi-Fi hotspot. The Wi-Fi of RaspberryPi is setup to operate in AP/STA mode. That means the RaspberryPi's Wi-Fi can be connected to a home router (as Wi-Fi client) and at the same time operates as hotspot (access point). This has some distinct advantages: By connecting the Wi-Fi of RaspberryPi to the home/office router with the internet, Nuc PC and any other devices which are connected to the hotspot of the QTrobot also get access to the internet. Moreover, laptops and other devices which are in the same network as the home router, can be easily configured to access and control QTrobot via ROS.

Note

Due to Raspberry Pi's Wi-Fi AP/STA mode limitation, not more than two devices can simultaneously connect to QTrobot's hotspot. If you need to connect more than two devices to QTrobot, you can connect them via an external access point such as your home/office router. Please follow Connect QTrobot to a home network and Internet instruction, then connect your other devices (e.g. laptop) to the same router to access the same network as QTrobot.

ROS setup

The roscore runs on QTRP automatically at QTrobot boot time. The QTPC is setup with the correct ROS_MASTER_URI and ROS_IP to access the same ROS network as QTRP. Usually ROS master URI is set to 192.168.4.1 or 192.168.100.1 depending on the QTrobot's version. However, you can easily check it by looking into /home/qtrobot/.bash_aliases file on QTRP:

source /opt/ros/noetic/setup.bash
source ~/catkin_ws/devel/setup.bash
ROBOT_IP=192.168.4.1
export ROS_MASTER_URI=http://${ROBOT_IP}:11311

The ROS environment is setup in different files on QTRP to make it available to other users (e.g. root user):

  • in /home/qtrobot/.bash_aliases
  • in /etc/environment
  • and in /etc/profile

Catkin workspace

For both QTRP and QTPC, the Catkin workspace is already set up and is accessible under /home/qtrobot/catkin_ws folder. The workspaces also contains some important ROS nodes for QTrobot interfaces such as qt_nuitrack_app, qt_vosk_app and etc. Indeed you can use the same catkin workspace for your own developments but be careful to not remove the src folder within catkin workspace.

Warning
  • You do not need and should not run another instance of roscore neither on QTPC nor QTRP nor any other machine which are in the ROS network of QTrobot.
  • Do not delete the default catkin_ws folders on QTRP nor on QTPC. These folder already used for running some default QTrobot interface nodes such as qt_nuitrack_app on QTPC or qt_vosk_app on QTRP.

QTrobot startup process

The following diagram depicts the default process of QTrobot's startup. Upon turning on the robot (either by plugin the power line or by pressing the power button), the QTRP will boot and set up the network for Lan, Wi-Fi hotspot and connecting to the home/office router (if set up). Then it runs the roscore and launch the QTrobot interfaces such as qt_motor, qt_robot_interface and etc. When the basic interfaces is up and running, it then turn on QTPC via wake-on-lan. QTPC then boot up and start the qt_nuitrack_app interface.

Powering off QTrobot almost follows the reverse procedure of powering on. The QTrobot's power button is connected to Raspberry PI and trigs the power off procedure of QTRP. During the shut down process of QTRP, it also sends power off command to QTPC via SSH so that both computers turn off using a single power button. Below is an overview of the power-off process of QTrobot.

What are autostart scripts?

QTrobot uses some startup scripts (i.e. autostart scripts) for both QTRP and QTPC to start and launch its software and drivers at boot time. Autostart scripts are simply some bash scripts which are executed at QTrobot startup time. There are different set of autostart scripts, one for QTRP and the other set for QTPC. Generally, these scripts prepare QTrobot network, setup ROS environment and launch specific ROS nodes on each machine. For example, autostart scripts of QTRP, run roscore and launch QTrobot motor and other important controllers. Moreover, as it can be inferred from QTrobot Architecture, one of the autostart scripts of QTPC is responsible to launch the qt_nuitrack_app node which provide ROS interface for Nuitrack skeleton tracking using 3D camera. Therefore, it is very important that you completely understand the purpose of each script before disabling or modifying the QTrobot autostart behavior.

For both QTRP and QTPC, the autostart scripts are located in ~/robot/autostart folder under qtrobot user. The scripts are run by Linux Cron job scheduler. In fact, a specific cron job is configured to run the autostart_screens.sh script at boot time. The other scripts are launched by autostart_screens.sh and their output are redirected to the corresponding log files.

QTRP autostart scripts

the autostart_screens.sh script on QTRP is responsible for launching the roscore and some other QTRobot critical interfaces such as qt_motor, qt_robot_interface, etc. Please be careful to not disable any of these critical nodes. Here is the list and short descriptions of each autostart script on QTRP:

  • start_mDNS.sh : start mulitcast discovery service on QTrobot
  • start_roscore.sh : run the roscore
  • start_qtpc.sh : turn on QTPC via wake-on-lan
  • start_qt_motor.sh : launch qt_motor node (for motor, gesture interfaces and etc)
  • start_qt_robot_interface.sh : launch qt_robot_interface node (for robot facial emotion, speech, interfaces and etc.)
  • start_qt_rosbridge.sh : start a secure rosbridge server (used by tablet apps)
  • start_qt_vosk_app.sh : start vosk offline speech recogntion

QTPC autostart scripts

the autostart_screens.sh script on QTPC is mainly responsible for launching the qt_nuitrack_app interface. Here is the list and short descriptions of each autostart script on QTPC:

  • start_qt_nuitrack_app.sh : launch qt_nuitrack_app node (for skeleton tracking, facial feature, gesture recognition and etc.)

How to check the log files of autostart scripts

All programs/ROS nodes which are run by QTrobot autostart scripts redirect their standard output (info/war/error messages) to their corresponding log file. These log files can be found under ~/robot/autostart/logs folder.

How to run my own script at startup

For example, to run your custom script on QTPC at the startup, you need to first create a startup script file and call it from autostart_screens.sh. Do the following steps:

  • [Step 1] Create custom startup script

    open a terminal on QTPC and create a bash script file. Let's name it start_my_script.sh.

    nano ~/robot/autostart/start_my_script.sh

    with the following example content:

    # !/bin/bash
    source /home/qtrobot/robot/autostart/qt_robot.inc

    SCRIPT_NAME="start_my_script"
    LOG_FILE=$(prepare_logfile "$SCRIPT_NAME")

    {
    prepare_ros_environment
    wait_for_ros_node "/rosout" 60
    # ...
    # add your main code here
    /usr/bin/echo "This is my script!"
    # ...
    } &>> ${LOG_FILE}
  • [Step 2] Add it to autostart_screens.sh

    Carefully edit the autostart_screens.sh:

    nano ~/robot/autostart/autostart_screens.sh

    To add your own script (e.g. start_my_script.sh) you can simply add the following line to the buttom of autostart_screens.sh right before the } &>> ${LOG_FILE} line. The autostart_screens.sh should look like the following:

    {
    wait_for_network
    ...
    ...
    run_script "start_my_script.sh"
    } &>> ${LOG_FILE}
  • [Step 3] Reboot and check Reboot the QTrobot. After reboot, your script should be executed on startup of QTPC. You can now check the log file of your script:

    cat ~/robot/austostart/logs/start_my_script.log