I'm currently working on a project to hook up a robotic arm & webcam to my Raspberry Pi and control said arm through a web inteface.

I believe the technical work here involves:

  1. Connecting the Robot Arm to the Pi (done).
  2. Commanding the Arm through Pi using Python (in progress).
  3. Setting up a Webserver on the Pi (done).
  4. Posting commands from the Webserver through to the Python scripts.
  5. Web interface to provide UI control for posting commands to the webserver.

Thanks to the comments already I've managed to get the web server functional. My only question now really lies around the link between the web server and the Python scripts.

Assuming I have a script that can run, awaiting commands to control the Robot Arm, I can't see how I get the Apache web server to forward "commands" into this script. I'm assuming I will need a Python web framework or something similar to achieve this.

I really appreciate all the help so far. Hopefully this edited question makes it slightly more clear what I'm trying to achieve.

Since I'm documenting this project, I will obviously give credit to those that have helped and put the web link in here once it's all finished so you can all put the arm through it's paces :-)

  • 1
    Just run a webserver on the Pi. Make sure you have port-forwarding setup on the router. On the main website just use an iframe to embed the pis webpage. – Gerben Oct 16 '13 at 15:36
  • Thanks Gerben. I've worked out the technical part of the webserver. My main question is really how I get that link between the webserver posting commands and the python scripts that will control the Arm. – Ash Oct 17 '13 at 12:34
  • You can just run a python script on the webserver. Just like PHP. You'll just have the python script generate the html. – Gerben Oct 17 '13 at 15:04

I'm thinking I will need a script running on the RPi to constantly listen for events/commands. Then hopefully I can setup a webserver of sorts...

You've over-complicated things. If you have a piece of hardware connected to the pi and you want to control it via a web interface, all you need is a web server. The server presents a web interface, and controls the hardware in response to external requests.

There's an endless number of ways to do this. I'm not a python user, but there could well be simple python HTTP server frameworks you could use directly; how viable this is may depend on the server load, but presumably in this case you are really dealing with only one user, so that is not an issue.

Doing that, however, requires some understanding of how an HTTP server works. Acquiring that knowledge probably requires you do a little hands on using a monolithic server application, such as the ones that drive the web. So that's where you start; the two most common web servers with python integration that run on the pi are:

These are not obscure -- apache handles a very significant percentage of total WWW traffic -- so you should have no problems finding resources and support. However, the fact that they are used for very large commercial applications does not mean that they are inviable for very small scale things as well. They are designed to be very very efficient and the amount of resources they require depends on what they are doing. So if you are doing something small scale on the pi, they won't hog an obnoxious amount of RAM, etc.

| improve this answer | |
  • Node-js - there are ready made solution out these already. – Piotr Kula Oct 17 '13 at 8:53
  • I didn't mention node.js because you can't code for it in python. – goldilocks Oct 17 '13 at 9:43
  • 1
    Oh right- didn't read the OPs entire question because it was too long. node.js is favoured over at the Robotics Exchange and I think mentioning it as an alternative is a good idea. – Piotr Kula Oct 17 '13 at 9:59
  • Thanks for your help guys. I hoped I might have overcomplicated things - at least that means it will be easier than expected now! I'm quite familiar with web servers and have already setup the Pi with LAMP. That's all running fine. My next plan is to get the Robotics responding to input through python. Once that is achieved I need the link between the webserver interface and the phython that controls the Arm. I appreciate your help! – Ash Oct 17 '13 at 12:32
  • Think of the 'P' in LAMP as referring to python instead of php -- you don't need to write whatever for apache such that it controls some external python app, you write in python for apache such that apache effectively controls the arm. If you write the stuff for controlling the robot in the form of a library (aka. module), you can use that module in a stand-alone python script or something that plugs into apache (e.g., via CGI, although I am sure there's a bunch of options for using python with apache). Having all of your code in one language simplifies things. – goldilocks Oct 17 '13 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.