yahvin
March 18, 2019, 6:45pm
1
Hello Everyone,
I am running the arm_test.py python file of bookreader2 on a BrickPi3. When I run the code, I get an error
===========
Traceback (most recent call last):
File "/home/pi/Software/BrickPi_Python/arm_test.py", line 42, in <module>
if(BrickPi.Encoder[arm]-init_pos>710):
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
>>>
A portion of the code where the error occurred is shown below:
while True:
BrickPiUpdateValues()
if(BrickPi.Encoder[arm]-init_pos>710):
BrickPi.MotorSpeed[arm] = -85
BrickPiUpdateValues()
time.sleep(.1)
BrickPi.MotorSpeed[arm] = 0
BrickPiUpdateValues()
time.sleep(.01)
break
time.sleep(.01) # sleep for 100 ms
What is wrong?
It looks like both values BrickPi.Encoder[arm]
and init_pos
haven’t been initialized. That’s what the exception is telling.
Let me check the code.
Thank you!
Edit: can you actually show me where you got that code?
yahvin
March 18, 2019, 8:20pm
3
Thank you for your reply. I am a 9th grade newbie at Raspberry Pi and Python. I am not sure how to initiallize the values
I also have another problem with the BrickPi3. The led is not blinking at all! Is it broken?
1 Like
cleoqc
March 18, 2019, 9:13pm
4
That project was written for the BrickPi+ and not the BrickPi3.
It can be adapted but it won’t be a 2 seconds fix.
Cleo
yahvin
March 18, 2019, 11:00pm
5
You can find the code in the file arm_test.py. If you search for bookreader 2 on Dexter Industries you will get a link that shows you how to make it. At the bottom of the link, there is another link to the Github page. The arm_test.py file is on the Github.
1 Like
yahvin
March 19, 2019, 1:42am
6
where do I start? Any hint would be appreciated.
I found it here:
#!/usr/bin/env python
###################################################################################
#arm_test.py
#Testing the code for movement of the robotic arm and roller for turning pages
#
#Karan Nayan
#29 Jan,2014
#Dexter Industries
#www.dexterindustries.com
#
#You may use this code as you wish, provided you give credit where it's due.
###################################################################################
from BrickPi import * #import BrickPi.py file to use BrickPi operations
roller =PORT_A
arm= PORT_B
BrickPiSetup() #setup the serial port for communication
BrickPi.MotorEnable[roller] = 1 #Enable the Motor A
BrickPi.MotorEnable[arm] = 1 #Enable the Motor B
BrickPiSetupSensors() #Send the properties of sensors to BrickPi
This file has been truncated. show original
So, unfortunately, this project is only for the old BrickPi board. What you have is a BrickPi3. And for the BrickPi3 we have 3 projects that are listed in here .
You might want to do the BricKuber as it is in the same ballpark as the BookReader project for the old BrickPi board.
Thank you!
1 Like