I thought I would start a thread for those of us just learning Python and trying to learn how to program our new robot. Just a note I am programming directly on my raspberry pi. I have a HDMI monitor and a keyboard and mouse hooked up to my Qbo. Secondly I am not using anything fancy to write my code right now. I am just using the PYTHON 2 IDLE that came pre-installed. One more thing to note the python code supplied with your Qbo is written in python 2.7.
Now on to some simple coding nothing fancy here folks. Inside of the /home/pi/Documents/Python projects is a file called QboCmd.py. This is an important file for us mere beginners. With in the file there are commands that we can use to control our Qbo.
Let’s just start with the controlling head movement. The head moves both along the X axis (left and right) and the Y axis (up and down).
First thing we need to import some files. Importing the files allows us to use the code with in those files. So what this means for us beginners is that someone really smart person wrote the hard stuff and we get to cheat off of them. We don’t need to re-invent the wheel. LOL
import time
import serial #handles the serial ports
import QboCmd #holds some commands we can use for Qbo
#set up ports for communicating with servos
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)
QBO = QboCmd.Controller(ser)
print("Start Positon")
#Set a start position
QBO.SetServo(1,511, 100)#Axis,Angle,Speed
QBO.SetServo(2,450,100)#Axis,Angle,Speed
time.sleep(1)
print("Left Positon")
#Move the head to the left
QBO.SetServo(1,725, 100)#Axis,Angle,Speed
#Pause
time.sleep(1)
print("Start Positon")
#move it back to starting point
QBO.SetServo(1,511, 100)#Axis,Angle,Speed
#Pause
time.sleep(1)
print("Right Positon")
#Move the head to the right
QBO.SetServo(1,290, 100)#Axis,Angle,Speed
#Pause
time.sleep(1)
print("Start Positon")
#move it back to starting point
QBO.SetServo(1,511, 100)#Axis,Angle,Speed
#Pause
time.sleep(1)
#moving the head up and down along Y axis
print("Up Positon")
#Move the head to the left
QBO.SetServo(2,530, 100)#Axis,Angle,Speed
#Pause
time.sleep(1)
print("Start Positon")
#move it back to starting point
QBO.SetServo(2,450,100)#Axis,Angle,Speed
#Pause
time.sleep(1)
print("Down Positon")
#Move the head to the right
QBO.SetServo(2,400, 100)#Axis,Angle,Speed
#Pause
time.sleep(1)
print("Start Positon")
#move it back to starting point
QBO.SetServo(2,450,100)#Axis,Angle,Speed
#Pause
time.sleep(1)
Hey!!!. Great contribution to the forum. Thanks
Dear Friends from QBO:
I was having a lot of issues controlling the head movements without success. I also tested this code and do not work at all. The Arduino code running inside QBo V2 seems to have many issues. For instance, when this code runs, only the Servo 2 commands worked. All the commands for servo 1 didn't work at all.
We are very grateful with QBo, but we really would like to have to Arduino code in order to be able to debug these issues, and the most importan thing, to adapt QBo to our needs (we are adding a manipulator which will complement the robot). However currently we are unable to do that.
We would like to ask you if you could share the Arduino code. You will have a lot of benefits because we will detect and fix bugs, and issues that would improve the entire platform.
Appreciate a lot
Rodrigo
Dear Friends from QBO:
I was having a lot of issues controlling the head movements without success. I also tested this code and do not work at all. The Arduino code running inside QBo V2 seems to have many issues. For instance, when this code runs, only the Servo 2 commands worked. All the commands for servo 1 didn't work at all.
We are very grateful with QBo, but we really would like to have to Arduino code in order to be able to debug these issues, and the most importan thing, to adapt QBo to our needs (we are adding a manipulator which will complement the robot). However currently we are unable to do that.
We would like to ask you if you could share the Arduino code. You will have a lot of benefits because we will detect and fix bugs, and issues that would improve the entire platform.
Appreciate a lot
Rodrigo
Hi Faturita,
i have the latest firmware provide by thecorpora. They are fixing some bugs with some developers in the forum.
I think the only thing you need to do is send an email to them and cross your fingers ;)
I advise you to read my textbook to implement Q.BO STEM or Q.BO One at the latest version, with which you can also make it play with chat-gpt.