Skip to main content
Version: QTrobot V1

Custom data collection using ROS

Overview

 Level:  Advanced
 Goal:  learn how to use ROS blocks for custom data collection
 Requirements:

In this tutorial, You will learn how to use QTrobot Studio's ROS blocks to collect data from our game and publish it to an external data collector. There are many scenarios in which you want to log the interaction of the user with the tablet and/or QTrobot. One way of doing this is to use LuxAI Report block and its data collection and analytic backend as it is explained in QTrobot Studio's data collection and analytics tutorial. However, you may need to use your custom ROS-based data collector to log or to monitor the interaction and progress of the game. Let;s see how this can be done.

For this tutorial, we assume that there is ROS node which advertise two simple topics: One for logging the questions (let's call it /my_data_collector/question) and another one to log the answers (let's call it /my_data_collector/answer). Whenever we publish to these topics, my_data_collector node stores those values along with their timestamp from ROS message header (msg.header.stamp) in a database. The implementation of my_data_collector is behind the scope of this tutorials but it can be done in few lines in python using ROS subscribers and ROS standard messages.

1. Create a random Q&A game using visuals

First let's create a Q&A game using visuals. The game is pretty simple. QTrobot randomly says the name of one animal and ask the learner to chose the correct answer among the three picture of the animals shown on the tablet. We will repeat this step randomly for different animals. We assume that you have already uploaded a set of animal images (e.g. cat.jpg, cow.jpg,...) to your cloud account under animals category. If you are not familiar with this, please take a few minutes and check Create game with visuals using QTrobot Studio tutorial first.

To make this game more interesting with randomized questions, first we create a list of the name of animals (i.e. cat,cow,dog,duck,bird,horse,lion,mouse) same as the name of their image file (without specifying the extension). Then we randomly remove an animal name from the list and store it as our question in a variable. We also randomly remove two other animal names (animal1 and animal2) which we will use as possible answers along with our question. The reason that we remove those random elements from our list is to avoid having duplicate answer.

We can already shows these three images to user as the possible answers to the question using LuxAI Show clickable images block. However, the order of the images shown on the tablet will be same for all questions. To overcome this issue, and to have the correct answer in the randomized order, we create a list of answers using our question, animal1 and animal2 variables. Now we can randomly remove three answers (answer1, answer2 and answer3) from the the list. One of these answer is same as the question. To show these images on the kid tablet using LuxAI Show clickable images block, we can use the QTrobot studio special character for variable (i.e. { and } ) to enter these names in the block. Look at the block examples bellow.

To check the answers given by learner and provide proper feedback, we create a simple function called check_answer which takes two parameters q for question and a for answer. When the a is equal to q, that means the learner chose the correct answer and we will provide positive feedback. Then we can use check_answer function for each answer given by the learner in our LuxAI Show clickable images block.

2. Adding data collection using ROS

No we want to record the questions and the answer provided by the learner using my_data_collector ROS node. We can simply modify the check_answer function and publish the question and the status of the answer to the corresponding topics as it is shown bellow:

.

Now wherever we use check_answer function, it will automatically add the corresponding reporting message to our custom data collector ROS module. To elaborate the above example, we can define our own data type in ROS to keep the track of questions and answer using a single topic. for example:

improvement

We can even further elaborate our ROS data reporting block using dedicated functions and use it easier in different place in our block-based programme as it is shown bellow:

improvement2