当前位置: 首页 > news >正文

网站做的比较好的公司网页制作与设计教程

网站做的比较好的公司,网页制作与设计教程,厦门网页设计制作,免费的微商城平台本文经作者Fumitaka Kimizuka 授权我们翻译和转载。 原文链接:myCobotに「頷き」「首振り」「首傾げ」をしてもらう 🤖 - みかづきブログ・カスタム 引言 Fumitaka Kimizuka 创造了一个乘法表系统,帮助他的女儿享受学习乘法表的乐趣。她可以…

本文经作者Fumitaka Kimizuka 授权我们翻译和转载。
原文链接:myCobotに「頷き」「首振り」「首傾げ」をしてもらう 🤖 - みかづきブログ・カスタム

引言

Fumitaka Kimizuka 创造了一个乘法表系统,帮助他的女儿享受学习乘法表的乐趣。她可以口头回答乘法问题,显示的数字就是乘积。如果她回答正确,myCobot 就会点头;如果她回答错误,myCobot 就会做出不同的动作。以下是作者对该系统开发过程的记录。

🤖

https://twitter.com/i/status/1793416553867706459

在实施这一机制时,我用 Node.js 编写了一个程序,让 myCobot "点头"、"摇头 "和 "歪头"。

https://twitter.com/i/status/1780785823220224188

这是我将其与 LINE Bot 相关联时创建的程序的改进版。

准备工作

首先,按照以下步骤使 myCobot 可以通过 Python 运行。

然后,使用 Node.js 和 Express 架设网络服务器。虽然你也可以使用 Python 设置网络服务器,但以我的技术水平,Node.js 对我来说更快。因此,我使用 Node.js 和 python-shell 来控制 myCobot。

python-shell - npm

.env

# Specify the USB port to which myCobot is connected
MY_COBOT_PORT=/dev/cu.XXXXXXXX

app.js (Excerpt)

const express = require('express');const express = require('express');
const { PythonShell } = require('python-shell');
const app = express();
const http = require('http').Server(app);app.use(express.json());
app.use('/', express.static(`${ __dirname }/public`));async function move(color = [255, 255, 255], angles = [0, 0, 0, 0, 0, 0], interval = 200) {return new Promise((resolve, reject) => {PythonShell.runString(`from pymycobot.mycobot import MyCobot; MyCobot('${ process.env.MY_COBOT_PORT }').set_color(${ color }); from pymycobot.mycobot import MyCobot; MyCobot('${ process.env.MY_COBOT_PORT }').send_angles([${ angles }], ${ duration })`,null).then(() => {setTimeout(() => resolve(), interval);}).catch(() => {reject();});});
}move([255, 255, 255], // LED matrix colors (RGB)[0, 0, 0, 0, 0, 0], // Angles of myCobot's joints (degrees)200
);

通过创建一个 "move "函数,该函数可以接受 LED 矩阵颜色、关节角度和驱动时间等参数,因此变得非常方便。

实施:

对于点头、摇头和歪头,请使用之前创建的`move`函数。

// Nodding
async function doYes() {return new Promise(async (resolve, reject) => {const interval = 200;try {await move([0, 0, 255], [0, 0, 0, 45, 0, 0], interval);await move([0, 0, 255], [0, 0, 0, 0, 0, 0], interval);await move([0, 0, 255], [0, 0, 0, 45, 0, 0], interval);await move([0, 0, 255], [0, 0, 0, 0, 0, 0], interval);await move([0, 0, 255], [0, 0, 0, 45, 0, 0], interval);await move([0, 0, 255], [0, 0, 0, 0, 0, 0], interval);await move([255, 255, 255], [0, 0, 0, 0, 0, 0], interval);resolve();} catch (err) {console.error(err);reject();}});
}// Shaking its head
async function doNo() {return new Promise(async (resolve, reject) => {const interval = 400;try {await move([255, 0, 0], [0, 0, 0, 0, 45, 0], interval / 2);await move([255, 0, 0], [0, 0, 0, 0, -45, 0], interval);await move([255, 0, 0], [0, 0, 0, 0, 45, 0], interval);await move([255, 0, 0], [0, 0, 0, 0, -45, 0], interval);await move([255, 0, 0], [0, 0, 0, 0, 0, 0], interval / 2);await move([255, 255, 255], [0, 0, 0, 0, 0, 0], interval / 2);resolve();} catch (err) {console.error(err);reject();}});
}// Tilting its head
async function doHmm() {return new Promise(async (resolve, reject) => {const interval = 400;try {await move([255, 0, 255], [0, 0, 0, 0, 45, 0], interval / 2);await move([255, 0, 255], [0, 0, 0, 0, 45, 0], interval);await move([255, 0, 255], [0, 0, 0, 0, 45, 0], interval);await move([255, 0, 255], [0, 0, 0, 0, -45, 0], interval);await move([255, 0, 255], [0, 0, 0, 0, 0, 0], interval / 2);await move([255, 255, 255], [0, 0, 0, 0, 0, 0], interval / 2);resolve();} catch (err) {console.error(err);reject();}});
}

我是这样实现的,接下来,通过 Web API 调用点头、摇头和歪头动作。

app.js

require('dotenv').config();const express = require('express');
const { PythonShell } = require('python-shell');
const app = express();
const http = require('http').Server(app);const PORT = 3000;app.use(express.json());
app.use('/', express.static(`${ __dirname }/public`));app.post('/yes', (req, res) => {doYes();res.send(200);
});app.post('/no', (req, res) => {doNo();res.send(200);
});app.post('/hmm', (req, res) => {doHmm();res.send(200);
});// https://www.elephantrobotics.com/wp-content/uploads/2021/03/myCobot-User-Mannul-EN-V20210318.pdf
async function move(color = [255, 255, 255], angles = [0, 0, 0, 0, 0, 0], interval = duration) {return new Promise((resolve, reject) => {PythonShell.runString(`from pymycobot.mycobot import MyCobot; MyCobot('${ process.env.MY_COBOT_PORT }').set_color(${ color }); from pymycobot.mycobot import MyCobot; MyCobot('${ process.env.MY_COBOT_PORT }').send_angles([${ angles }], ${ duration })`,null).then(() => {setTimeout(() => resolve(), interval);}).catch(() => {reject();});});
}async function doYes() {return new Promise(async (resolve, reject) => {const interval = 200;try {await move([0, 0, 255], [0, 0, 0, 45, 0, 0], interval);await move([0, 0, 255], [0, 0, 0, 0, 0, 0], interval);await move([0, 0, 255], [0, 0, 0, 45, 0, 0], interval);await move([0, 0, 255], [0, 0, 0, 0, 0, 0], interval);await move([0, 0, 255], [0, 0, 0, 45, 0, 0], interval);await move([0, 0, 255], [0, 0, 0, 0, 0, 0], interval);await move([255, 255, 255], [0, 0, 0, 0, 0, 0], interval);resolve();} catch (err) {console.error(err);reject();}});
}async function doNo() {return new Promise(async (resolve, reject) => {const interval = 400;try {await move([255, 0, 0], [0, 0, 0, 0, 45, 0], interval / 2);await move([255, 0, 0], [0, 0, 0, 0, -45, 0], interval);await move([255, 0, 0], [0, 0, 0, 0, 45, 0], interval);await move([255, 0, 0], [0, 0, 0, 0, -45, 0], interval);await move([255, 0, 0], [0, 0, 0, 0, 0, 0], interval / 2);await move([255, 255, 255], [0, 0, 0, 0, 0, 0], interval / 2);resolve();} catch (err) {console.error(err);reject();}});
}async function doHmm() {return new Promise(async (resolve, reject) => {const interval = 400;try {await move([255, 0, 255], [0, 0, 0, 0, 45, 0], interval / 2);await move([255, 0, 255], [0, 0, 0, 0, 45, 0], interval);await move([255, 0, 255], [0, 0, 0, 0, 45, 0], interval);await move([255, 0, 255], [0, 0, 0, 0, -45, 0], interval);await move([255, 0, 255], [0, 0, 0, 0, 0, 0], interval / 2);await move([255, 255, 255], [0, 0, 0, 0, 0, 0], interval / 2);resolve();} catch (err) {console.error(err);reject();}});
}try {doYes();
} catch(err) {console.error(err);
}http.listen(PORT, '0.0.0.0');

有了这个设置、

向 `http://localhost:3000/yes` 发送 POST 请求会让它点头。
向 `http://localhost:3000/no` 发送 POST 请求会让它摇头。
向 `http://localhost:3000/hmm` 发送 POST 请求会让它歪头。
将执行相应的操作。

DEMO

点头

摇头

歪着头

LED 矩阵的颜色也在悄然改变。

目前看起来是这样的,但如果再调整一下,效果可能会更好,尤其是头部的倾斜动作。

Github 存储库

https://github.com/kimizuka/mycobot-express/tree/example/timas-table

总结

我们非常感谢 Fumitaka Kimizuka 允许我们分享如此出色的技术案例研究。我们希望在阅读本文后,您能从中受到启发,创造出更多有趣而实用的项目。如果您有类似的想法或作品,请与我们分享,让我们共同推动技术进步和创新!


文章转载自:
http://gimbals.mnqg.cn
http://devotion.mnqg.cn
http://ajar.mnqg.cn
http://snuffbox.mnqg.cn
http://redetermination.mnqg.cn
http://noneconomic.mnqg.cn
http://lyase.mnqg.cn
http://pancreozymin.mnqg.cn
http://housedress.mnqg.cn
http://sandbar.mnqg.cn
http://tripody.mnqg.cn
http://imparkation.mnqg.cn
http://clasmatocyte.mnqg.cn
http://colporteur.mnqg.cn
http://springbok.mnqg.cn
http://nutgall.mnqg.cn
http://citified.mnqg.cn
http://tetrahedron.mnqg.cn
http://holeable.mnqg.cn
http://nitrobenzol.mnqg.cn
http://readopt.mnqg.cn
http://immix.mnqg.cn
http://loo.mnqg.cn
http://hematocyte.mnqg.cn
http://solubilizer.mnqg.cn
http://antiblastic.mnqg.cn
http://popliteal.mnqg.cn
http://turtle.mnqg.cn
http://emperorship.mnqg.cn
http://youngling.mnqg.cn
http://wandy.mnqg.cn
http://candidly.mnqg.cn
http://mortar.mnqg.cn
http://salvageable.mnqg.cn
http://fim.mnqg.cn
http://atomistics.mnqg.cn
http://marish.mnqg.cn
http://hypoglycemic.mnqg.cn
http://fruitcake.mnqg.cn
http://refreshant.mnqg.cn
http://boar.mnqg.cn
http://gustavian.mnqg.cn
http://cementation.mnqg.cn
http://percival.mnqg.cn
http://empirically.mnqg.cn
http://cemetery.mnqg.cn
http://spathulate.mnqg.cn
http://menfolks.mnqg.cn
http://airbag.mnqg.cn
http://hypocenter.mnqg.cn
http://neroli.mnqg.cn
http://gravy.mnqg.cn
http://lunt.mnqg.cn
http://vasoconstrictor.mnqg.cn
http://alloantibody.mnqg.cn
http://derious.mnqg.cn
http://diluvian.mnqg.cn
http://hotdog.mnqg.cn
http://deluxe.mnqg.cn
http://hexaploid.mnqg.cn
http://nymphlike.mnqg.cn
http://annelidan.mnqg.cn
http://auxanometer.mnqg.cn
http://rowboat.mnqg.cn
http://proxy.mnqg.cn
http://renitent.mnqg.cn
http://acrolein.mnqg.cn
http://crustily.mnqg.cn
http://betrothal.mnqg.cn
http://radiotelegrapm.mnqg.cn
http://cicatrix.mnqg.cn
http://polymastigote.mnqg.cn
http://auxocardia.mnqg.cn
http://consonantalize.mnqg.cn
http://phlegethon.mnqg.cn
http://thalamostriate.mnqg.cn
http://kapellmeister.mnqg.cn
http://pedagogism.mnqg.cn
http://angustifoliate.mnqg.cn
http://mcp.mnqg.cn
http://porose.mnqg.cn
http://rarp.mnqg.cn
http://horal.mnqg.cn
http://staff.mnqg.cn
http://worthily.mnqg.cn
http://holds.mnqg.cn
http://chrp.mnqg.cn
http://espiegle.mnqg.cn
http://grove.mnqg.cn
http://vaude.mnqg.cn
http://inescapability.mnqg.cn
http://sexualize.mnqg.cn
http://hypergeometric.mnqg.cn
http://winepress.mnqg.cn
http://spadable.mnqg.cn
http://wove.mnqg.cn
http://delightsome.mnqg.cn
http://acoustic.mnqg.cn
http://lamby.mnqg.cn
http://purp.mnqg.cn
http://www.dt0577.cn/news/123797.html

相关文章:

  • 短视频网站建设方案网站建网站建设网站
  • 做汽配批发做那个网站比较好搜索引擎入口yandex
  • 自己做的网页怎么上传到网站网站排名软件包年
  • 嘉兴网站建设方案托管网络公关
  • 有网站怎么做app郑州网络营销推广
  • 龙岩网站建设平台软文推广平台排名
  • 应用商城app开发下载谷歌seo外链平台
  • 威县做网站哪里便宜信息流广告代运营
  • 做宣传单页的网站百度浏览器下载官方免费
  • 国内b2b平台网站站长工具域名查询
  • 做自己的网站怎么购买空间百度招商加盟推广
  • wordpress _xseo的名词解释
  • 郑州 网站建设 东区网络营销知识
  • 卓光网站建设深圳网站建设专业乐云seo
  • 网站怎么做qq微信登陆百度客服人工电话多少
  • 服务流程企业网站百度免费官网入口
  • 怎么制作网站首页的代码大数据营销策略有哪些
  • 好看的网站都找谁做的新闻热搜榜 今日热点
  • 如何自学网站开发seo公司优化方案
  • 做网站java步骤逆冬黑帽seo培训
  • 能在家做的兼职的网站net的网站建设
  • 衡水做企业网站的公司谷歌搜索引擎香港免费入口
  • 那个网站做字体今日新闻头条官网
  • 手机网站商城建设如何把品牌推广出去
  • 汕头做网站求好用的seo软件
  • 网页网站banner图片怎么做抖音关键词排名系统
  • 电子商城网站开发项目描述整站优化排名
  • 个人导航网站源码推销广告
  • 做网站的公司术语百度电话怎么转人工客服
  • 网站空间支付方式网络营销和网络销售的关系