Hello,
I'm a french teacher and I'm using The raspberry Pi with my students. I'm using Python with them but I don't have any knowledges in 3D.
I just would like ta make a demo in Python (2.7) which can control a simple 3D model orientation with accelerometer datas.
I think that pi3D library is a good choice to do such kind of thing, so I've installed it.
I'm trying to launch some of the demos but each of them terminates with an error in 'Shader.py' file : --> AttributeError : 'NoneType' object has no attribute 'encode'. I've got the same error with Python 3.
Could you help me please.
Thanks a lot,
Michael B |
Thanks a lot for your answers !!I joined the screenshot with the error in the terminal window.I extended the GPU memory to 128 without any improvement...I assume that it is a problem with a library, but I've tried to uninstalland reinstall all the modules and requires for Pi3D, but I'm not sure...I used the latest version of Raspbian Jessie with the PIXEL interface.My Raspberry is a Pi 3.
Michael, thinking about this on the bus from Essaouira it occurs to me that the ways. path is probably being confused by the /... dist... egg stuff in the path to your pi3d installation. How did you install pi3d? Is it running inside virtual environment?
Michael, I've looked into this now and tried changing to pkg_resources.resource_string() (see http://peak.telecommunity.com/DevCenter/PythonEggs#accessing-package-resources). Could you let me know what process you used to set up pi3d so I can test out if this will fix your problem. Thanks, Paddy
Usually not a problem, but it broke pi3d when tries to open resources (e.g. shaders) in it's module 'tree', which it expects to be expanded/unzipped fully.
/usr/local/lib/python3.4/dist-packages/pi3d-2.13-py3.4.egg/..
build/bdist.linux-armv7l/egg/..
import sys
sys.path.insert(1, '/home/pi/Documents/TempRPi/pi3d-master')...
model = pi3d.Model(file_string='models/quadcopter01.obj')
model.set_shader(shader)
empty = pi3d.Triangle(corners=((-0.005, -0.003), (0.0, 0.006), (0.005, -0.003)), y=-2.5, z=20.0)
empty.add_child(model)
...
while DISPLAY.loop_running():
empty.draw()
while ser.in_waiting > 10: # serial input from arduino with MPU6050
line = ser.readline()
if b'ypr' in line or b'euler' in line:
_, ry, rx, rz, heading = line.split(b'\t')
rx, ry, rz, heading = float(rx), float(ry), float(rz), float(heading)
model.rotateToX(rx)
model.rotateToZ(rz)
empty.rotateToY(heading)
...