Notifications
Clear all

ROS package: qbo_control

24 Posts
4 Users
6 Reactions
3,525 Views
caju
 caju
(@caju)
Member
Joined: 4 years ago
Posts: 22
Topic starter  

In this new thread, we can discuss any doubt or problem found when installing or using the ROS package qbo_control, that you can find in the following link: https://github.com/carlosjdd/qbo_control

 

If you are starting to control Qbo with ROS, please have a look to the thread "How to control Qbo using ROS". Hope the indications shown there and in the README file of the ROS package are useful.


   
Quote
(@romeo)
Member
Joined: 6 years ago
Posts: 76
 

hi Caju, I followed your instructions and installed ros kinetic on a 32Gb sim for QBO raspian strech. i ran the test.py program and it worked, but when i tried the programs in ros i got this error: $ rosrun qbo_control motor_x.py
Traceback (most recent call last):
File "/home/pi/catkin_ws/src/qbo_control/src/motor_x.py", line 4, in <module>
import rospy
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/__init__.py", line 47, in <module>
from std_msgs.msg import Header
File "/opt/ros/kinetic/lib/python2.7/dist-packages/std_msgs/msg/__init__.py", line 1, in <module>
from ._Bool import *
File "/opt/ros/kinetic/lib/python2.7/dist-packages/std_msgs/msg/_Bool.py", line 6, in <module>
import genpy
File "/opt/ros/kinetic/lib/python2.7/dist-packages/genpy/__init__.py", line 34, in <module>
from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
File "/opt/ros/kinetic/lib/python2.7/dist-packages/genpy/message.py", line 48, in <module>
import yaml
ImportError: No module named 'yaml'

 

i think it's because the ros installation was compiled with python 2.7 ... but i'm not sure as i don't have much experience in ros.

Thank you if you give me some suggestions regarding this my first experience.

   
ReplyQuote
caju
 caju
(@caju)
Member
Joined: 4 years ago
Posts: 22
Topic starter  

Hello Romeo,

When you recive an error like 'ImportError: No module named '__'', means that you are trying to execute something that uses the library '__' and it is not installed. You can google that line of the error and you may found several forums solving the issue. Do not worry if they are not related to ROS, because this is not a ROS problem, but an error related to the Python dependencies.

In your case, it teels you that you do not have installed 'yaml'. To solve it, you can try to install it for python 3:

pip3 install pyyaml

But, just in case, I also recommend to install it for python 2.7 in case it is not:

pip install pyyaml

About the python issue, note that motor_x, for example, when been executed with rosrun will be executed in python3 because of the first line of the code:

#!/usr/bin/python3

You can change the 3 with a 2.7 to modify the python version to use. However, you should be able to use python 3 although your ros installation were in python 2.7. Only in case you need more dependencies (libraries needed as yaml), you will have to install them.

 

Hope this helps you solve your error and understand a bit better the reason. Just in case you have any other doubt or problem, let me know and I will try to solve it as soon as possible. I would also thank you if you could write when you manage to have it working.


   
ReplyQuote
Niko
 Niko
(@niko)
Eminent Member
Joined: 6 years ago
Posts: 39
 

Hi @caju & @romeo,

i am really excited to use ROS with Q.bo. My knowledge are limited but my dream is to have a "base" Distro based on ROS and the latest Raspberry Pi OS (previously called Raspbian) in order to make some developments.

I don't know if this is difficult or not but these is what I am thinking:

1.- Start Q.bo with a BASE Distro Based on ROS and the latest Raspberry Pi OS.

2.- Improve Face Detection and Tracking on Qbo ( robust face detection )

3.- Nodes to launch Speech recognition & Synthesis.

4.- Nodes to launch different mouth patterns. ( I think @caju made something before like this but not sure ).

Honestly, I think all things are simples but very powerful for developments purposes.

I know that theCorpora is working in a touch screen "add on" that can change everything for much better. It's simply amazing to have the capability to interact with Qbo to some orders via a touch screen. 

Waiting anxiously!!!!


   
ReplyQuote
caju
 caju
(@caju)
Member
Joined: 4 years ago
Posts: 22
Topic starter  

Hello Niko, 

All you are saying is great, and you can integrate everything with ROS. And related to the 4º point, yes, in the qbo_control ROS package, the node mouth.py subscribes to /set_expression topic in which you can indicate several different mouth patterns I created. You can look at the end of the README of the package, in the excel table where I explain the mouth node (You may need to make zoom in)

However, as I have already developed by myself this functions (the voice recognition and facial recognition integrated with ROS), I must say that the Raspberry pi 3 is not good enough to run them at the same time, so you will need a better CPU, as a raspberry Pi 4 (I don't know if it would be enough), or a computer to do the hard processing while you communicate with Qbo via ROS_MASTER_URI.

I would really like to use a Raspberry Pi 4 with Qbo to check how much can I run at the same time with it, but I am not able to configure Qbo to make it work as with a Raspberry Pi 3.


   
ReplyQuote
(@romeo)
Member
Joined: 6 years ago
Posts: 76
 

hello @caju and @Nico ... I made it work but I spent a lot of time on it: first of all I reinstalled ros with this procedure: install Ros kinetic in raspberry pi3 from http://wiki.ros.org/ROSberryPi/Installing%2520ROS%2520Kinetic%2520on%2520the%2520Raspberry%2520Pi&source=gmail&ust=1605644751324000&usg=AFQjCNF51kaeGSNu4lugEDfGVa6Bo66qY Q"> http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Kinetic%20on%20the%20Raspberry%20Pi
step1:
sudo apt-get install dirmngr
step2:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu&source=gmail&ust=1605644751324000&usg=AFQjCNH0nxZK2EcLskXKpuqFbVia9qy93 Q"> http://packages.ros.org/ros/ubuntu  $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
step3:
sudo apt-key adv --keyserver hkp://http://ha.pool.sks-keyservers.net:80&source=gmail&ust=1605644751324000&usg=AFQjCNFwJyqZBr97KCsaxeG90-bkdK_hE g">ha.pool.sks-keyservers.net:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
step5:
sudo apt-get update
step6:
sudo apt-get upgrade
--------------------
install boostrap dependencies
step7:
sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake
--------------------
initializing
step8:
sudo rosdep init
step9:
rosdep update
--------------
download Kinetic e installazione ( in Workspace):
creation for workspace:
step10:
mkdir -p ~/ros_catkin_ws
step11:
cd ~/ros_catkin_ws
------------------
Download ROS packages:
step12:
rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall
step13:
wstool init src kinetic-ros_comm-wet.rosinstall
..................
(generation for folder "SRC" and 18 sub-folders in ~/ros_catkin_ws)
................
building ROS Kinetic (option J2) 
step14:
sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic -j2
************
... compilation (for 52 packages) .... for raspberry pi3 you have to wait a long time and maybe restart more than once ...
************
activate the installation
step15:
source /opt/ros/kinetic/setup.bash
Or, have ROS environment variables automatically added to your bash session every time a new shell is launched (recommended)
step15_r:
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
------------------------------
test installation ROS Kinetic:
$ roscore
-----------
...
* /rosdistro: Kinetic
* /rosversion: 1.12.17
...
started core service [/rosout]
------------------------------

******************************

I reinstalled qbo_control following @caju's procedure:

https://github.com/carlosjdd/qbo_control

...............................................................

I changed the header to the node files 

#!/usr/bin/python3 
#!/usr/bin/python env 2.7 
Because I don't have python 3 installed

(I configured raspy with original Strech without update)

I tried to command nose and expression with rostopic pub ... and it seems to work

I have yet to try the head motors.


   
ReplyQuote
caju
 caju
(@caju)
Member
Joined: 4 years ago
Posts: 22
Topic starter  

Great Romeo!! I am so happy you finally could manage to make it work with ROS! 😀 

It is true that it is a bit hard procedure to have everything working and you can find several problems on it, but with patience it can be done succesfully.

Thanks also for the detailed procedure!


   
ReplyQuote
Niko
 Niko
(@niko)
Eminent Member
Joined: 6 years ago
Posts: 39
 
Posted by: @caju

However, as I have already developed by myself this functions (the voice recognition and facial recognition integrated with ROS), I must say that the Raspberry pi 3 is not good enough to run them at the same time, so you will need a better CPU, as a raspberry Pi 4 (I don't know if it would be enough), or a computer to do the hard processing while you communicate with Qbo via ROS_MASTER_URI.

I would really like to use a Raspberry Pi 4 with Qbo to check how much can I run at the same time with it, but I am not able to configure Qbo to make it work as with a Raspberry Pi 3.

@caju really interesting that you have FR & VR running in ROS. Honestly I think Rpi3 in Q.bo is enough to run all in separates threads. OpenQbo V2.0 runs Voice Recognition, Face tracking and all functions in real time very smoothly. I am not sure if Rpi4 is strictly necessary.

Face tracking is a new method design by you to detect faces or you are using the FT development by thecorpora?.


   
ReplyQuote
caju
 caju
(@caju)
Member
Joined: 4 years ago
Posts: 22
Topic starter  

Hi Niko,

For the face detection I used this tutorial using python and OpenCV: https://www.pyimagesearch.com/2018/06/18/face-recognition-with-opencv-python-and-deep-learning/

Only I integrated it with ros by subscribing to a topic that tells me when to detect and publishing a topic to tell who has been recognized and to tell where is the center of evey face detected.

I think it is for the libraries used that it uses a lot of resources and can be high for a raspberry pi 3. Although it can deal with it smoothly, it is true that uses several resources.

For the VR, I have used wit.ai (link) and it does not require lots of resources, but when I integrate everything in Qbo, with some other functionalities, everything in a different thread, as every ROS node is executed in parallel, I can see with "htop" how the RAM and the swap space collapse, as much as how the cores of the raspberry are using full resources. It is also true that I didn't programmed looking for efficiency, but I think I can not improve it much more while keeping all my functionalities.


   
ReplyQuote
(@romeo)
Member
Joined: 6 years ago
Posts: 76
 
hello @caju, I made another small supplementary test for q.bo that I attach here... I hope it will be interesting ...
This post was modified 4 years ago by romeo

   
ReplyQuote
caju
 caju
(@caju)
Member
Joined: 4 years ago
Posts: 22
Topic starter  

Thanks @romeo, it is great!!

Just one question, does the touch work for your Qbo? I have not been able to have it working on mine. If you tell me that your script works with the touch sensors I will test it too


   
ReplyQuote
(@romeo)
Member
Joined: 6 years ago
Posts: 76
 
 
 
YES, on my QBO the sensors work, but the central one is missing and I will have to try to do it myself.
I tried running the Feel.py file from the / opt / qbo directory and then I adjusted it to your software to do the test.
But now I should try to generate a node for this too ... but I have no experience with ROS ... I did the tutorials ... 
but nothing more ...
I am attaching the photo of the connection terminal board of the two sensors.
 

This post was modified 4 years ago by romeo

   
ReplyQuote
(@romeo)
Member
Joined: 6 years ago
Posts: 76
 
 
I would also have prepared a SIM with ubuntu server 20.04 and I would also have installed ros2 foxy-
I would like to know if this version could also be used to check QBO ... but I just have no idea how to proceed to install the QBO_cmd in this version .. .
 
I attach the photo of the connection of a sensor on the head of QBO.

This post was modified 4 years ago by romeo

   
ReplyQuote
caju
 caju
(@caju)
Member
Joined: 4 years ago
Posts: 22
Topic starter  

Hello Romeo, thanks for your answer. In my case, I have not been able to have the touch sensors working on Qbo. Otherwise, I would have included another node for it on the ROS package. If I finally manage to use it, although I don't know where can be the problem, I will create and include the node, but don't count on it. 

Anyway, if you are finally able to create a ROS node controlling it, you can feel free to include the node in the package qbo_control and push it to GitHub. And please, in that case, also inform us here in the Forum.

Regarding to the ROS2 issue, sorry but I can't help you as I have no experience at all working on it. I do not even know its compatibility with ROS, nor its commands.

Hope you can progress with your project!


   
ReplyQuote
(@romeo)
Member
Joined: 6 years ago
Posts: 76
 
Hi caju, I tried to make my first ros_node for QBO, which I am attaching to this post, 
please note that I am not a ROS expert and would like to know if it can be an acceptable job. Thanks for your opinion...
The software detects the touch and publishes the actual string:

#!/usr/bin/env python2.7
# import the necessary packages
import rospy
import serial
import QboCmd

# import the necessary msgs. Example with msg type String_Int_Arrays:
from std_msgs.msg import UInt8
from std_msgs.msg import String
touch_str =''
class Sensor_Controler():
""" Class nose_controler.

Bridge class to control with ROS the nose of the robot.
"""

def __init__(self):
"""Class constructor

It is the constructor of the class. It does:
- Call serial_configuration
- Pulish touch_str
"""

#-------

self.serial_configuration()


def serial_configuration(self):
"""Void serial_configuration

Configure the serial communication with the Qbo PCB.
Set the serial port, the baudrate and similar things"""
port = '/dev/serial0'
ser = serial.Serial(port, baudrate = 115200, bytesize = serial.EIGHTBITS, stopbits = serial.STOPBITS_ONE, parity = serial.PARITY_NONE, rtscts = False, dsrdtr = False, timeout = 0)
self.QBO = QboCmd.Controller(ser)

def stopping_node(self):
"""ROS closing node

Is the function called when ROS node is closed."""
print("\n\nBye bye! :)\n\n")

def Sensor_cb(self):
while not rospy.is_shutdown():

print("start")
"""ROS callback

This void is executed when a message is received"""
touch = self.QBO.GetHeadCmd("GET_TOUCH", 0)

if touch:
global touch_str

if touch == [1]:
touch_str = "Touch: right"

print("touch",touch)

elif touch == [2]:
touch_str = "Touch: up"

print("touch",touch)

elif touch == [3]:
touch_str = "Touch: left"

print("touch",touch)

if touch == [1] or touch == [2] or touch == [3]:
print(touch_str)

pub = rospy.Publisher('test_1', String, queue_size=10)
r = rospy.Rate(10) # 10hz

#functions to repeat until the node is closed
pub.publish(touch_str)
print("send touch type to test_1")
r.sleep()

if __name__=='__main__':
""" Main void.

Is the main void executed when started. It does:
- Start the node
- Create an object of the class
- Run the node

"""
try:
rospy.init_node('Sensor_node') # Init ROS node

Sensor_touch = Sensor_Controler()
print("[INFO] Node started")
rospy.on_shutdown(Sensor_touch.stopping_node) #When ROS is closed, this void is executed

Sensor_touch.Sensor_cb()

except rospy.ROSInterruptException:
pass

This post was modified 4 years ago by romeo

   
ReplyQuote
Page 1 / 2
Share: