VPython on Raspberry Pi?

1,058 views
Skip to first unread message

Scott Sumner

unread,
Apr 27, 2013, 10:37:32 PM4/27/13
to vpytho...@googlegroups.com
Hello all,

I just started playing with Visual and its great!  I'd like to run it on a Raspberry Pi which has been successful (albeit incredibly slow as its all software rendering).  Has anyone looked at making a version available that runs with OpenGLES?  (OpenGL for embedded systems?)

Thanks,
Scott

Bruce Sherwood

unread,
Apr 27, 2013, 11:03:42 PM4/27/13
to vpytho...@googlegroups.com
How would a subset of OpenGL help in this situation? Note that it's already the case that VPython does software rendering and doesn't use GPUs with the minor exception of materials (though hopefully VPython will be brought up to date to exploit modern graphics cards).

I'm not at all sure that it's relevant either to mention it, but GlowScript (glowscript.org) is very similar to VPython but runs in a browser using WebGL (which requires modern graphics cards).

Bruce Sherwood



--
You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Scott Sumner

unread,
Apr 28, 2013, 1:16:47 AM4/28/13
to vpytho...@googlegroups.com
Oh ok, I was under the impression that VPython was using accelerated rendering to keep the frame rate up.  I got VPython running on the Raspberry Pi but it took 2-3 minutes based on sphere().  I was hoping that I could use the Pis as the platform but it sounds like they aren't going to be able to handle it.

Scott

Bruce Sherwood

unread,
Apr 28, 2013, 10:52:43 PM4/28/13
to vpytho...@googlegroups.com
I indeed misspoke. What is true is that except for materials, VPython does not use GPU "shader" code (vertex shader and fragment or pixel shader). But VPython does exploit the other kinds of OpenGL capabilities of modern graphics cards. Apparently the Raspberry Pi device doesn't have a modern graphics card, which isn't a surprise.

Scott Sumner

unread,
Apr 28, 2013, 11:28:49 PM4/28/13
to vpytho...@googlegroups.com
Yeah, unfortunately the Raspberry Pi is about all that my project budget will allow for.  I guess I'll have to go with a 2D solution until the hardware catches up.

Scott



On Sun, Apr 28, 2013 at 9:52 PM, Bruce Sherwood <bruce.s...@gmail.com> wrote:
I indeed misspoke. What is true is that except for materials, VPython does not use GPU "shader" code (vertex shader and fragment or pixel shader). But VPython does exploit the other kinds of OpenGL capabilities of modern graphics cards. Apparently the Raspberry Pi device doesn't have a modern graphics card, which isn't a surprise.

Kevin Karplus

unread,
Apr 29, 2013, 12:24:55 AM4/29/13
to vpytho...@googlegroups.com

On Sun, Apr 28, 2013 at 7:52 PM, Bruce Sherwood <bruce.s...@gmail.com> wrote:
I indeed misspoke. What is true is that except for materials, VPython does not use GPU "shader" code (vertex shader and fragment or pixel shader). But VPython does exploit the other kinds of OpenGL capabilities of modern graphics cards. Apparently the Raspberry Pi device doesn't have a modern graphics card, which isn't a surprise.

Actually, the Raspberry Pi does have a GPU.  My understanding, though, is the the software developers were not allowed access to the API for the graphics processing unit (needing a large payment and a non-disclosure agreement), so the capability remains mostly inaccessible.

--
Kevin Karplus   kar...@soe.ucsc.edu    http://www.soe.ucsc.edu/~karplus

Scott Sumner

unread,
Apr 29, 2013, 12:26:59 AM4/29/13
to vpytho...@googlegroups.com
There's limited GPU abilities but it has to be implemented full-screen only, not integrated with X Windows.  That's not a problem either but I've yet to get either a VPython program or a browser capable of WebGL to cooperate with it.

Scott



Jonathan Kessler

unread,
Apr 13, 2018, 5:44:49 PM4/13/18
to VPython-users
I'm curious to know what your work around was? I'm setting up a beowulf cluster from RPi3s that will run an interactive fluid dynamic demo. I was hoping to use vPython, but realtime interaction isn't possible with all the shadow rendering. Or is there a way to reduce shading or anti-aliasing to improve performance?

Jonathan

Bruce Sherwood

unread,
Apr 13, 2018, 7:12:21 PM4/13/18
to VPython-users
There is no rendering of shadows in the GlowScript library used by VPython 7. Nor is there any mechanism for reducing the quality of the rendering. Of course rendering performance increases with the use of more expensive graphics cards.

There is however one thing you should know, which is that if there is even one transparent object in the scene, rendering is significantly slower (and antialiasing is disabled). The machinery for handling transparency is quite complex:


Although the GlowScript library does not currently handle shadows, the algorithm for doing so is similar to the depth-peeling algorithm described above.

I should mention that GlowScript VPython is inherently much faster than standard Python, due to transpiling to fast JavaScript. From an October 2017 post to this forum:

ClassicGasNoNumpy.py:       2.3 milliseconds per loop
ClassicGasNumpy.py:            0.6 ms
Gas.py (VPython 7):               5.5 ms
GasNumpy.py: (VPython 7):   1.3 ms
Gas.py (GlowScript):              0.12 ms (this uses the code from Gas.py; just change the start of the program for GlowScript use)

Summary for this particular (but representative) example program:

1) Use of the numpy module with true Python increases the speed by a factor of 4.

2) Classic is 2 times faster than VPython 7. This is presumably due to the fact that the Classic visual module is mostly written in (fast) C++, whereas most of VPython 7 (except for the vector class) is written in (slow) Python. The vector class was speeded up by using Cython, and the other major component of the vpython module is a candidate for similar treatment, which would likely bring it close to the speed of Classic VPython. I might have thought that the fact that Classic VPython has to do all of the rendering in the CPU, using OpenGL, might have been compensated for in VPython 7 by offloading the rendering to WebGL, but that's not the case.

3) GlowScript VPython is 5 times faster than ClassicGasNumpy and 20 times faster than ClassicGasNoNumpy.

4) GlowScript VPython is 10 times faster than VPython 7 without numpy and 40 times faster than VPython 7 without numpy.

Bruce


Bruce Sherwood

unread,
Apr 13, 2018, 7:38:41 PM4/13/18
to VPython-users
One other thing: Represent a large number of particles with simple_sphere objects rather than sphere objects. The simple_sphere object has many fewer triangles and so renders much faster.

Bruce

Bruce Sherwood

unread,
Apr 13, 2018, 8:13:05 PM4/13/18
to VPython-users
A sphere is rendered with 900 triangles; a simple_sphere is rendered with 64 triangles. More generally, you could make a roughly circular thin circular disk with as few as 10 triangles, compound a list of them, and then clone as many as you need.

Bruce

Jonathan Kessler

unread,
Apr 13, 2018, 10:53:43 PM4/13/18
to vpytho...@googlegroups.com
I'm going to try the simple sphere in the morning. That approach should help. My students are making a 'mock' super computer cluster out of 7 mini computers (raspberry pis). A simple ball pit fluid that can be 'stirred' by the user and used as a demo and educational tool for computational physics, specifically designed to highlight systems that require parallel processing.

Hopefully, we can integrate the ability to toggle nodes on/off, and the user will see performance speed/slow drastically.

However, the computers aren't designed for intense graphics processing. They have minimal resources dedicated to graphics so 3D might be too much for it, but I'd love to avoid coding the frontend code in Java.

Thanks for your help, Bruce.

Love the 4e of M&I. Started reviewing it and preparing lectures for next Fall.

Best,

Jon 


On Fri, Apr 13, 2018 at 7:13 PM Bruce Sherwood <bruce.s...@gmail.com> wrote:
A sphere is rendered with 900 triangles; a simple_sphere is rendered with 64 triangles. More generally, you could make a roughly circular thin circular disk with as few as 10 triangles, compound a list of them, and then clone as many as you need.

Bruce

--
You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--



Jonathan M. Kessler, Ph.D.
Assistant Professor Department of Physics and Engineering Physics
Southeast Missouri State University
Cape Girardeau MO 63701
Phone: 573-651-2387
email: jkes...@semo.edu
http://semo.edu/physics/faculty/kessler.html


Michael Bishton

unread,
May 22, 2020, 4:18:01 PM5/22/20
to VPython-users
I note these posts go from 2018 all the way back to 2013. I'm interested in some updated info but would like to explain why to focus response. I was amazed by the graphics representations in the VPython series for Beginners from "Lets Code Physics!" 

I am a regular glider pilot and ultralight flyer who has programmed in other languages and wants to make aircraft displays that can help ultralight pilots fly more safely. The traditional Heads Up Display has current status information; air speed, compass heading, etc. I would like to show graphics of when a turn is getting to steep and the inside wing is about to stall, or the pilot is about to head down too fast to be able to recover in pulling up. I would also like to create a display for gliders that shows when a person is in a thermal using a path trace. VPython looks like a natural for that. 

You can now get 5" and 7" HDMI displays for the Raspberry Pi that would make it easier to display info on that screen in a browser or some other frame. This seems like a great combo to run VPython. Is it? Can anyone point me in the right direction for which version of linux and VPython I should install and run?

Thanks. Any thoughts are appreciated. 

Bruce Sherwood

unread,
May 22, 2020, 7:46:58 PM5/22/20
to VPython-users
Very briefly: There are two flavors of VPython that are relevant to questions about running on a Raspberry PI:

1) VPython 7: Install Python, then install the vpython module, following the detailed installation information found at vpython.org. You need a Python version >= 3.5.3.

2) GlowScript VPython: Go to glowscript.org and start programming without installing any software. It all works in the browser. You could try that for starters.

Both flavors depend on the GlowScript library, which accesses the very low-level 3D graphics WebGL library that is part of browsers. In the GlowScript case, your Python program is transpiled in the browser to JavaScript in order to be able to run in the browser.

Here is a summary of the architecture: https://vpython.org/contents/VPythonArchitecture.pdf

Bruce

Aaron Titus

unread,
May 23, 2020, 3:13:33 PM5/23/20
to vpytho...@googlegroups.com
In approximately summer 2017, we did a project where we built an apparatus using quadcopter motors and propellers for an undergraduate lab on torque and angular momentum. We needed to control the motors wirelessly. So we installed a raspberry pi on the apparatus and we installed anaconda and vpython on the pi. We ran jupyter notebook from the pi over a wireless network; therefore, we used a remote computer to edit and run our python program (through a jupyter interface) on the pi. The program used vpython sliders to control the motors and used a vpython scene to provide visual feedback to the user.

It worked wonderfully. But note that the display (browser) was running on a remote computer, not the pi.

I don’t remember all of the details, but we used the default linux for the pi and installed anaconda. Besides having to configure jupyter to run with an IP address we could access from another computer (i.e. we could not use localhost), we didn’t do anything differently from how we would install vpython on a Mac or windows machine. In other words, first install anaconda for the OS. Then use conda to install vpython. But the caveat is that we didn’t try to display anything on the pi.

Aaron Titus
--
You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages