Jump to content

Control a (physical) robot/actuator from php script?


stubarny

Recommended Posts

Hi,

 

Please could you tell me how to control a robot from a php script? I've been looking at raspberry pie based robots on the internet but they don't seem to use php as the controlling code. For example if I receive an order on my website, how do I use php to activate a product dispenser to drop a product onto a robot, and then use php to direct the robot to a packing area?

 

Thanks for any pointers.

 

S

Link to comment
Share on other sites

PHP is designed as a high level scripting language for web servers.  It's not really equipped for low level interaction with the server OS (what you need for robotics).  For that you would want something like Python or a C derivative.  That said, you can launch shell scripts and applications through PHP by using shell_exec().  It's not exactly the answer you are looking for as it's not PHP doing things with the server directly, but it does bridge the gap and let you interact with scripts that can natively engage with the OS and its applications.

 

PHP isn't written with the tools and libraries that would be required to fully interact with a server OS directly.  It knows what it is, and has a toolset based around what it was designed to do: server side scripting of web applications.  There may well be third party libraries that will engage with specific aspects of specific operating systems, but that's not the core purpose - as thus not the core functionality - of the language.  Languages such as Python have native controls to interact with the OS directly, Python has also got a fairly high level and pretty simplistic syntax, which is why it's the language of choice for the R-Pi: it's easy for people to pick up without needing a formal tutor.  Either one way or another you are going to need to learn another language to program the robotics of your project.  You are either going to have to learn how to script low level linux (or windows if you are using the Win10 IoT dev release) commands to signal the headers on the board using the installed base drivers directly, or you are going to need to get to grips with a higher level language that can interact with the drivers and abstract control of the headers into something more human friendly.  Whichever route you take, you will be able to launch your scripts through PHP by using the shell_exec() function as a broker.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.