NAO robot ALBarcodeReader API not working

181 views
Skip to first unread message

Mahla Nasrollahi

unread,
Feb 3, 2021, 10:35:45 AM2/3/21
to ROS Sig Aldebaran
Hello,

I have setup Python 2.7 SDK for virtual NAO6 robot (v2.8) on my windows 10 laptop.

I have tested if the SDK is working on my laptop while running the virtual NAO in Choregraphe platform in the background. I have used the hello_world example on my Python IDE and used the command line (terminal) to run the scripts. It outputs the correct result and the virtual robot reacts to it. 
hello_world.py example:
Screenshot 2021-02-03 at 15.00.01.png

However, I am trying to use the the ALBarcodeReader module example which I found on the website:

I changed the code for subscribing to an event:

vision_barcodeReader_subscribeToEvent.py:
----------------------------------------------------------------------------------------------------------------------

#! /usr/bin/env python
# -*- encoding: UTF-8 -*-

"""Example: A Simple class to get & read BarcodeDetection Events"""

import qi
import argparse
import sys
import time


class BarcodeReader(object):
    """
    A simple class to react to barcode detection events.
    
    """

    def __init__(self, app):
        super(BarcodeReader, self).__init__()
        # start application and get session
        app.start()
        session = app.session
        # Get the services ALBarcodeReader and ALMemory.
        self.memory_service = session.service("ALMemory")
        self.barcode_service = session.service("ALBarcodeReader")
        self.subscriber = self.memory_service.subscriber("BarcodeReader/BarcodeDetected")
        self.subscriber.signal.connect(self.on_barcode_detected)
        self.barcode_service.subscribe("test_barcode")

    def on_barcode_detected(self, value):
        """
        Callback for event BarcodeReader/BarcodeDetected
        """
        print "I saw a barcode"
        print "The event data are: " +str(value)

    def run(self):
        """
        Loop on, wait for events until manual interruption.
        """
        print "Starting BarcodeReader"
        try:
            while True:
                time.sleep(1)
        except KeyboardInterrupt:
            print "Interrupted by user, stopping BarcodeReader"
            self.barcode_service.unsubscribe("test_barcode")
            # Stop
            sys.exit(0)

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", type=str, default="desktop-6d4cqe5.local",
                        help="Robot IP address. On virtual robot: use 'nao.loacal'.")
    parser.add_argument("--port", type=int, default=9559,
                        help="Naoqi port number")

    args = parser.parse_args()
    try:
        # Initialize qi framework.
        connection_url = "tcp://" + args.ip + ":" + str(args.port)
        app = qi.Application(["BarcodeReader", "--qi-url=" + connection_url])
    except RuntimeError:
        print ("Can't connect to Naoqi at ip \"" + args.ip + "\" on port " + str(args.port) +".\n"
               "Please check your script arguments. Run with -h option for help.")
        sys.exit(1)
    
    barcode_reader = BarcodeReader(app)
    barcode_reader.run()

----------------------------------------------------------------------------------------------------------------------


However, whenever I run the code above I get this error message:
Screenshot 2021-02-03 at 15.27.50.png 

I wasn't sure where the error was coming from and am still learning about the NAOqi Vision APIs. 
There wasn't enough information on the ALBarcodeReader API page either in order to help me:

My whole point of doing this is so I can scan simple barcodes using the virtual robot using the Python SDK and NAOqi APIs. 

Some guidance and help is appreciated!


Kind Regards,
Mahla Nasrollahi



Emile KROEGER

unread,
Feb 3, 2021, 10:55:37 AM2/3/21
to ros-sig-...@googlegroups.com
Hello Mahla,

A lot of vision-related APIs will not work on the Choregraphe simulated robot, even in cases where the relevant Service exists in the Service directory, they will not be able to process images, as the simulated robot does not have a camera (even simulated).

Regards,

Emile

--
You received this message because you are subscribed to the Google Groups "ROS Sig Aldebaran" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ros-sig-aldeba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ros-sig-aldebaran/321493ef-47c4-4583-bf09-4352a5170e4fn%40googlegroups.com.

This email and any attachment thereto are confidential and intended solely for the use of the individual or entity to whom they are addressed.
If you are not the intended recipient, please be advised that disclosing, copying, distributing or taking any action in reliance on the contents of this email is strictly prohibited. In such case, please immediately advise the sender, and delete all copies and attachment from your system.
This email shall not be construed and is not tantamount to an offer, an acceptance of offer, or an agreement by SoftBank Robotics Europe on any discussion or contractual document whatsoever. No employee or agent is authorized to represent or bind SoftBank Robotics Europe to third parties by email, or act on behalf of SoftBank Robotics Europe by email, without express written confirmation by SoftBank Robotics Europe’ duly authorized representatives.


Ce message électronique et éventuelles pièces jointes sont confidentiels, et exclusivement destinés à la personne ou l'entité à qui ils sont adressés.
Si vous n'êtes pas le destinataire visé, vous êtes prié de ne pas divulguer, copier, distribuer ou prendre toute décision sur la foi de ce message électronique. Merci d'en aviser immédiatement l'expéditeur et de supprimer toutes les copies et éventuelles pièces jointes de votre système.
Ce message électronique n'équivaut pas à une offre, à une acceptation d’offre, ou à un accord de SoftBank Robotics Europe sur toute discussion ou document contractuel quel qu’il soit, et ne peut être interprété comme tel. Aucun employé ou agent de SoftBank Robotics Europe n'est autorisé à représenter ou à engager la société par email, ou à agir au nom et pour le compte de la société par email, sans qu’une confirmation écrite soit donnée par le représentant légal de SoftBank Robotics Europe ou par toute autre personne ayant reçu délégation de pouvoir appropriée.

Mahla Nasrollahi

unread,
Feb 3, 2021, 11:08:24 AM2/3/21
to ROS Sig Aldebaran
Dear Emile,

Thank you for reading my post!

I see. Is there any way to use the laptop's camera as a substitute and then transfer the code to the physical robot?
I'm wondering if I can write an external API on my local computer that scans barcodes but I'm not sure how it would be connected to the robot~




Best,
Mahla

Emile KROEGER

unread,
Feb 3, 2021, 11:28:39 AM2/3/21
to ros-sig-...@googlegroups.com
Hello Mahla,

What do you want to do exactly?

You talk about the physical robot, is that your end goal, or do you want to also be able to scan barcodes from Choregraphe's simulated robot?

Because it's technically possible to do pretty much anything, take images from your laptop and send them to a physical or simulated robot, but he won't process them 'as if' he saw them.

You might want to check out this project: https://github.com/softbankrobotics-labs/barcodereader It's for Pepper, but as it runs on NAOqi, most of it should work just fine on NAO v6 (you just won't have the tablet part, and may need to remove the tablet-related part of the code). Not however that it won't work on a simulated robot either.

Regards,

Emile

Mahla Nasrollahi

unread,
Feb 3, 2021, 12:08:37 PM2/3/21
to ROS Sig Aldebaran
Dear Emile,

I am trying to scan a QR code using NAO's front cameras and process the information that is inside the barcode in order to give some personalised feedback to the users.

The final point is to test the code on the physical robot but before to get to the end point, I currently only have access to the Choregraphe's simulated robot. I know the virtual robot has some limitations like there is no sound, etc but wasn't sure if the NAO's cameras were connected to the laptop's camera. I now know that it's not possible to use the simulated robot's camera to scan. 

From what I understand, I can write an API on my local laptop that can scan a barcode and send it to the robot. However, I cannot test the API using the NAO's front camera's to test as I only have the virtual robot. 

But, would the physical robot be able to scan a barcode (1) by itself? or (2) using an API like the project you have sent? 
...or I still need to have to send data to it from my laptop?

I will check the project that you have provided as I might get some ideas from it but very sad that it can't be tested on the virtual robot. Thank you for sending it :) 


Best,
Mahla
Reply all
Reply to author
Forward
0 new messages