网络机器人的故障保护

发布于 2024-08-14 17:45:05 字数 297 浏览 9 评论 0原文

我有一个通过浏览器控制的机器人。带有前进、后退等按钮的页面是用 PHP 编写的,托管在机载计算机上。 PHP 只是通过串行连接将 ASCII 字符发送到微控制器。不管怎样,我需要实现一个故障保护装置,这样当驾驶它的人断开连接时,机器人就会停下来。我唯一能想到的就是在网页上对这个人进行 ping 或其他操作,但我确信有比这更好的方法。机器人通过临时网络或连接到互联网的常规无线网络进行连接。显然,如果我使用 ping 方法,那么在实际断开连接的时间和意识到已断开连接的时间之间必须存在延迟。无论使用什么方法,我都希望延迟尽可能小。如果有任何关于如何做到这一点的想法,我将不胜感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吃不饱 2024-08-21 17:45:05

Ping Web 客户端有些不可靠,因为您必须考虑到客户端 IP 可能会发生变化。

另一方面,您可以通过 Ajax 模拟“dead-man-button”。让网页时不时地发送一个定义的命令(也许每 5 到 10 秒)。如果机器人一段时间没有收到消息,它就会停止。 Ajax 脚本可以在后台运行,因此控制用户甚至不会注意到任何事情。

这当然意味着您的机器人需要有一个每秒递增并在收到消息时重置的计数器。当定时器变量太高时,FULL STOP

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

萝莉病 2024-08-21 17:45:05

我可以建议您使用嵌入网络浏览器中的简单 Flash 对象来打开到机器人上服务器的套接字连接吗?服务器可以用任何合适的语言编写 - 甚至是 PHP(咳)。

然后,在连接断开时立即检测并实施故障安全方法就很简单了。

HTTP 并不是机器人控制的理想协议。

祝你好运!

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!

爱,才寂寞 2024-08-21 17:45:05

我能想到的就是在 HTML 中包含 ajax 代码,每隔 X 秒“ping”一次您的服务器。我相信 Facebook Chat 就是通过这种方式来了解您是否仍然在线。

HTML 5 Web 套接字可能是您正在寻找的解决方案,但您必须考虑到大多数用户的浏览器都不会实现它。

您可能会发现这篇文章很有趣: http://www.infoq .com/news/2008/12/websockets-vs-comet-ajax

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文