English 中文(简体)
failsafe for networked robot
原标题:
  • 时间:2009-12-13 01:00:10
  •  标签:
  • php
  • robotics

I have a robot that I m controlling via a browser. A page with buttons to go forward, reverse, etc is written in PHP hosted on an onboard computer. The PHP is just sending ASCII characters over a serial connection to a microcontroller. Anyway, I need to implement a failsafe so that when the person driving it gets disconnected, the robot will stop. The only thing I can think to do is to ping the person on the web page or something, but I m sure there is a better way than that. The robot is connected either via an ad hoc network or a regular wireless network that is connected to the internet. Obviously if I go with the ping method then there will have to be a delay between the actual time disconnected and when it realizes it s been disconnected. I d like this delay to be a small as possible, whatever the method used. I d appreciate any ideas on how to do this.

最佳回答

May I suggest you use a simple flash object embedded in the web browser to open a socket connection to a server on the robot? The server can be written in any suitable language - even PHP (cough).

Then it is a simple matter to detect immediately when the connection goes down, and implement your fail-safe approach.

HTTP is not a ideal protocol for robot control.

Good luck!

问题回答

Pinging a web client is somewhat unreliable, for you have to take into account, that the client ip might change.

On the other hand, you could emulate a "dead-man-button" via Ajax. Let the webpage send a defined command every now and then (maybe every 5 to 10 seconds). If the robot doesn t receive the message for some time, it can stop. The Ajax script could run in the background so the controlling user won t even notice anything.

This would of course mean, that your robot needs to have a counter which is incremented every second and reset when the message is received. The moment the timer variable is too high, FULL STOP

All I can think of is to include ajax code in your HTML that "pings" your server every X second. I believe that s what Facebook Chat does to know whether or not you are still online.

HTML 5 Web sockets might be the solution you are looking for but you have to consider that it won t be implemented by most of your users browsers.

You might find this article interesting: http://www.infoq.com/news/2008/12/websockets-vs-comet-ajax.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签