项目简介:通过将电子宠物与智能花盆相结合,不仅给机器人本身赋予了生命的特征,同时也能将植物无声的情感通过机器人来表达,以猫为原型,试图用猫的动作来表现植物的状态,并使用户与植物之间有更多交互的方式。
![桌面级植物宠物机器人扩比原型机初稿图27](https://mc.dfrobot.com.cn/data/attachment/forum/202107/12/111108muueez7dcqj8p6l8.gif) ![桌面级植物宠物机器人扩比原型机初稿图28](https://mc.dfrobot.com.cn/data/attachment/forum/202107/12/111108wwx3qwlpp43mr4w7.gif)
核心功能介绍:一.喂水。当土壤湿度传感器检测到植物缺水时,NEKO会用realsense自己找人,并把水盆“叼”到用户面前,同时会通过耳朵和尾巴等肢体语言向用户传达缺水的信息,让主人用水壶倒水。二.追光。平时NEKO会自己在桌面上有阳光的地方呆着,用户可以用专门的小手电来逗他,他会追着光照的地方跑去。三.充电。NEKO有一个自己的小房子,每天晚上会自己回去充电。并且如果某天光照不足,小房子里装有紫外线灯,会自动给植物补充光照。
![桌面级植物宠物机器人扩比原型机初稿图5](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/104913hkuvnu3eav9dkuya.jpg)
传感器及控制器清单:模拟光线传感器*4,防跌落传感器*4,切诺基平台*1,舵机*5,迷你水泵*1,人体红外传感器*1,磁力传感器*1,土壤湿度传感器*1,Intel®RealSense (SR300) *1
模型制作:
建模:
![桌面级植物宠物机器人扩比原型机初稿图4](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/104903siqugq1up13v1rfi.jpg)
先来个立方体
![桌面级植物宠物机器人扩比原型机初稿图3](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/104903xsxfe3h3zd3xqu1k.jpg)
细节加点再
![桌面级植物宠物机器人扩比原型机初稿图1](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/104903cm1njhf2bbnhbfp4.jpg) ![桌面级植物宠物机器人扩比原型机初稿图2](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/104903hc9vxbwz9vt0txpb.jpg)
然后把东西塞进去
![桌面级植物宠物机器人扩比原型机初稿图6](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/105112d8hjh75hxbbjacch.jpg) ![桌面级植物宠物机器人扩比原型机初稿图7](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/105113h7yuux4z4zig5i34.jpg)
切割打印
![桌面级植物宠物机器人扩比原型机初稿图8](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/105212gca62m6fhicql57q.jpg) ![桌面级植物宠物机器人扩比原型机初稿图9](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/105212tzm15el6d5z58zee.jpg) ![桌面级植物宠物机器人扩比原型机初稿图14](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/105701vyq038vy3ynzm2cw.jpg)
拼粘上腻子
![桌面级植物宠物机器人扩比原型机初稿图10](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/105300g1d17pm4mx8cx77q.jpg)
喷漆上光油
![桌面级植物宠物机器人扩比原型机初稿图11](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/105355t3442hidy5u6h54f.jpg) ![桌面级植物宠物机器人扩比原型机初稿图12](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/105558pgk89hcl7cq2vq5c.jpg) ![桌面级植物宠物机器人扩比原型机初稿图13](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/105558xufu6cu3fk7y60b1.jpg)
半组装(组装传感器)
![桌面级植物宠物机器人扩比原型机初稿图15](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/111027y02ey80u1801yn66.jpg) ![桌面级植物宠物机器人扩比原型机初稿图16](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/111045a227q23k2bkpqqzb.jpg)
传感器调试
![桌面级植物宠物机器人扩比原型机初稿图17](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/111533tj4v880p29e9jech.jpg)
传感器+驱动系统调试
![桌面级植物宠物机器人扩比原型机初稿图19](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/111554ep511uqktuz4q4uo.jpg) ![桌面级植物宠物机器人扩比原型机初稿图18](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/111544znjjrl1233lm2zcc.jpg) ![桌面级植物宠物机器人扩比原型机初稿图20](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/111604wjlt84984tj4l8l8.jpg)
整机测试
![桌面级植物宠物机器人扩比原型机初稿图21](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/111613ml0htqz55mi6t8p5.jpg)
组装
追光程序
光敏传感器位置(目前只用了三个,第四个用于降低误差,没有写入)
![桌面级植物宠物机器人扩比原型机初稿图22](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/122119p80089m0u0sl6988.png)
- //pin脚
- int lgSP1=2; //1号光敏
- int lgSP2=3; //2号光敏
- int lgSP3=4; //3号光敏
-
- //小车控制pin脚
- int speedPin_M1 = 5; //M1 Speed Control
- int speedPin_M2 = 6; //M2 Speed Control
- int directionPin_M1 = 4; //M1 Direction Control
- int directionPin_M2 = 7; //M1 Direction Control
-
- //光敏读数
- int lgS1;
- int lgS2;
- int lgS3;
- int LR;
- int FB;
-
- //环境光初始值
- int lgS10=0;
- int lgS20=0;
- int lgS30=0;
-
- //其他参数
- int threshold=100;//阙值
- int thresholdLR=200;
- int thresholdFBMin=100;
- int thresholdFBMax=300;
- int state=1;
- int advanceSpeed=200;
- int backSpeed=150;
- int turnSpeed=250;
- int moveState=0;//状态参数
- int period=30000;
- unsigned long time0;
- unsigned long time1;
-
- //*********************主程序*************************
- void setup() {
- // put your setup code here, to run once:
- pinMode(lgSP1,INPUT);
- pinMode(lgSP2,INPUT);
- pinMode(lgSP3,INPUT);
-
- //环境光初始化
- for(int i=0;i<20;i++){
- lgS10=analogRead(lgSP1)+lgS10;
- lgS20=analogRead(lgSP2)+lgS20;
- lgS30=analogRead(lgSP3)+lgS30;
- delay(10);
- }
- lgS10=lgS10/10;
- lgS20=lgS20/10;
- lgS30=lgS30/10;
-
- //设置通信
- Serial.begin(9600);
- }
-
- void loop() {
- carStop();
-
- if(lgS1<threshold&&lgS2<threshold&&lgS3<threshold){//隔一段时间常态下更新光值
- resetLight();
- }
-
- //读取环境光值
- lgS1=analogRead(lgSP1)-lgS10;
- lgS2=analogRead(lgSP2)-lgS20;
- lgS3=analogRead(lgSP3)-lgS30;
-
- printLR();
- printFB();
- Serial.println(" 无光");
-
- while(lgS1>threshold||lgS2>threshold||lgS3>threshold){//环境光值变化大于阙值
- delay(100);
-
-
- lgS1=analogRead(lgSP1)-lgS10; //测量值减初始值
- lgS2=analogRead(lgSP2)-lgS20;
- LR=lgS1-lgS2; //左右光值差
-
- //print0();printLR();printFB();
-
- if(abs(LR)>thresholdLR){//左右光值差大于阙值
- swerve();
- moveState=1; //行驶状态参数
- }else{
- carStop();
- moveState=0;
- printLR();
- Serial.println(" 左右正常");
- }
-
- lgS1=analogRead(lgSP1)-lgS10;
- lgS3=analogRead(lgSP3)-lgS30;
- FB=lgS1-lgS3;
-
- if(abs(FB)>thresholdFBMin&&abs(FB)<thresholdFBMax){//前后光值差大于阙值
- walk();
- }else if(moveState==1){
- Serial.println(" 转弯中");
- }else
- carStop();
- printFB();
- Serial.println(" 前后正常");
- }
- }
-
- //*********************函数*************************
- //-----------------环境光初始函数-----------------
- void resetLight(){
- if(state==1){
- time0= millis();
- state=0;
- }
- time1=millis()-time0;//间隔一段时间
- // Serial.print("time0=");
- // Serial.print(time0);
- // Serial.print("time1=");
- // Serial.print(time1);
- // Serial.println();
- if(time1>period){//间隔一段时间后初始环境光
- for(int i=0;i<10;i++){
- lgS10=analogRead(lgSP1)+lgS10;
- lgS20=analogRead(lgSP2)+lgS20;
- lgS30=analogRead(lgSP3)+lgS30;
- delay(10);
- }
- lgS10=lgS10/10;
- lgS20=lgS20/10;
- lgS30=lgS30/10;
- state=1;
- print0();
- Serial.println(" success");
- }
- }
- //-----------------打印函数-----------------
- void print0(){
- Serial.print("lgS10=");
- Serial.print(lgS10);
- Serial.print(" ");
- Serial.print("lgS20=");
- Serial.print(lgS20);
- Serial.print(" ");
- Serial.print("lgS30=");
- Serial.print(lgS30);
- }
- void printLR(){
- Serial.print("lgS1=");
- Serial.print(lgS1);
- Serial.print(" ");
- Serial.print("lgS2=");
- Serial.print(lgS2);
- Serial.print(" ");
- Serial.print("LR=");
- Serial.print(LR);
- }
- void printFB(){
- Serial.print("lgS1=");
- Serial.print(lgS1);
- Serial.print(" ");
- Serial.print("lgS3=");
- Serial.print(lgS3);
- Serial.print(" ");
- Serial.print("FB=");
- Serial.print(FB);
- }
-
- //-----------------光判断函数-----------------
- void swerve(){//转向判断函数
- if(LR>10){
- printLR();
- Serial.println(" 左转");
- carTurnRight(turnSpeed,turnSpeed);
- }else if(LR<-10){
- printLR();
- Serial.println(" 右转");
- carTurnLeft(turnSpeed,turnSpeed);
- }
- }
-
- void walk(){//前进判断函数
- if(FB>0){
- printFB();
- Serial.println(" 前进");
- carAdvance(advanceSpeed,advanceSpeed);
- // isCliff=analogRead(distLPin);
- // isCliff=analogRead(distRPin);
- }else if(FB<0){
- printFB();
- Serial.println(" 后退");
- carBack(backSpeed,backSpeed);
- }
- }
-
- //-----------------车运动函数-----------------
- void carStop(){ // Motor Stop
- digitalWrite(speedPin_M2,0);
- digitalWrite(directionPin_M2,LOW);
- digitalWrite(speedPin_M1,0);
- digitalWrite(directionPin_M1,LOW);
- }
-
- void carAdvance(int leftSpeed,int rightSpeed){ //Move FORkward
- analogWrite (speedPin_M2,leftSpeed); //PWM Speed Control
- digitalWrite(directionPin_M2,LOW);
- analogWrite (speedPin_M1,rightSpeed);
- digitalWrite(directionPin_M1,HIGH);
- }
-
- void carBack(int leftSpeed,int rightSpeed){ //Move BACKrward
- analogWrite (speedPin_M2,leftSpeed);
- digitalWrite(directionPin_M2,HIGH);
- analogWrite (speedPin_M1,rightSpeed);
- digitalWrite(directionPin_M1,LOW);
- }
-
- void carTurnLeft(int leftSpeed,int rightSpeed){ //Turn Left
- analogWrite (speedPin_M2,leftSpeed);
- digitalWrite(directionPin_M2,HIGH);
- analogWrite (speedPin_M1,rightSpeed);
- digitalWrite(directionPin_M1,HIGH);
- }
- void carTurnRight(int leftSpeed,int rightSpeed){ //Turn Right
- analogWrite (speedPin_M2,leftSpeed);
- digitalWrite(directionPin_M2,LOW);
- analogWrite (speedPin_M1,rightSpeed);
- digitalWrite(directionPin_M1,LOW);
- }
复制代码
主程序:
![桌面级植物宠物机器人扩比原型机初稿图26](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/122159oipi425vuj5juuwp.png)
![桌面级植物宠物机器人扩比原型机初稿图24](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/122159jl1613yz14l432ql.png)
![桌面级植物宠物机器人扩比原型机初稿图25](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/122159u2uh7w77lu002zsm.png)
![桌面级植物宠物机器人扩比原型机初稿图23](https://mc.dfrobot.com.cn/data/attachment/forum/201707/07/122158w67snz9tt07q9d5q.png)
总结:目前正在进一步完善初稿的程序和debug,有些传感器还没写入代码里,模型正在进一步缩小以更贴近初始尺寸,多舵机使用是一定要注意电压问题!这是从植物开始的生物义肢,希望大家可以喜欢我们的项目。
|