极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2369|回复: 0

开源项目分享 | 智能捡乒乓球机器人

[复制链接]
发表于 2023-1-10 08:42:57 | 显示全部楼层 |阅读模式
本帖最后由 机器谱 于 2023-1-10 08:42 编辑

本文素材来源于宁夏大学
作者:丁文龙 、王小军、任剑杰、张钊铭
指导老师:康彩

一、项目简介

       随着人们对机器人技术智能化本质认识的加深,机器人技术开始源源不断地向人类活动的各个领域渗透。在这其中,服务机器人作为一个重要分支,在国内外研究领域已经得到普遍重视。服务机器人的应用范围很广,主要从事维护保养、修理、运输、清洗、保安、救援、监护等工作。但至目前为止,乒乓球捡拾器在国内外市场上的发展却较为滞后。文中所述的智能捡乒乓球机器人,正是一种应用于兵乓球体育赛事的自主式移动的服务机器人。智能捡乒乓球机器人可以应用在业余或专业的乒乓球训练基地或训练学校,使用智能捡乒乓球机器人可以减轻训练人员回收乒乓球的负担,能够减少训练时的无效训练时间,提高运动员的训练效率,使运动员可以更好的投入到专业的训练当中,从而取得更好的比赛成绩。
       智能捡乒乓球机器人利用OpenMV对乒乓球进行定位,接着机器人接收到乒乓球的位置前往捡球,到达位置时,升降台降下捡球筐,利用捡球筐底部弹簧,对乒乓球进行拾取,完成捡球。
       本项目涉及机械设计、Solidworks、机械原理等知识以及自动化、传感器、图像处理等先进技术,在实际中应用了Solidworks三维构图,Arduino编程、Python编程和计算机模拟的知识,是多学科综合运用的结果。
       现阶段国内外捡乒乓球机器人的研究有两个方向:一是夹持式,二是吸附式。第一类中机械手的设计过于复杂,且机械手与球之间是硬接触,容易对乒乓球造成机械式的损伤。第二类比第一类在技术上更成熟,但由于在拾取后真空泵要持续工作,耗能比大,不符合当下节能减排的思想。本项目设计的机器人在灵活性与节能减排等方面都有很大的提升,经济与实用效益都非常可观。

二、开发过程

       本设计完全是基于实践考虑,设计之初进行了详细的前期考察和调研;根据考察的结果制定具体的设计方案和要求,初步设计出整体的布局和结构外形; 使用计算机进行虚拟样机的仿真模拟,并优化;根据优化后的数据制作物理样机;进行捡球实验,最终确定样机形式。

(1) 前期考察调研
       各大体育场馆的乒乓球训练、比赛场地进行了实地考察,了解服务人员对捡球车有什么需求和建议,对比目前在用的捡球方法和捡球器械的捡球器械的优缺点。

(2) 捡球车定型
       根据考察的结果,选定本设计的捡球机器人利用升降台升降捡球筐捡球。

(3) 乒乓球捡球车的三维机构设计及优化
       捡乒乓球机器人机构包括底盘的运动机构、捡球结构、储球机构,通过三维建模确定整车设计可行性,并对各零部件做出优化,最终确定整车的数据。

(4) 乒乓球捡球车运动仿真
      利用SolidWorks对所建立的三维模型进行运动仿真,通过软件分析查看整车效果并做优化处理,生成最终的装配图和工程图。

(5) 调试图像识别
      利用OpenMV对乒乓球进行识别,通过一定算法,确定位置。


(6) 调试超声波避障
      利用超声波模块对障碍物进行避障。


(7) 调试捡球装置
      利用升降台升降捡球筐捡球。


(8) 调试程序
      对图像识别程序、超声波避障程序、电机驱动程序等一系列程序进行组合,构建OpenMV与Arduino之间的通信。


(9) 乒乓球捡球车的制造
      根据零件图和装配图选取探索者套件,完成整机组装,并为捡球车配置整套电控系统,对组装好的捡球车进行调试。


三、程序代码

超声波避障部分代码:
  1. const int TrigPin1 = 22;

  2. const int EchoPin1 = 23;

  3. const int TrigPin2 = 24;

  4. const int EchoPin2 = 25;

  5. const int TrigPin3 = 26;

  6. const int EchoPin3 = 27;

  7. const int TrigPin4 = 28;

  8. const int EchoPin4 = 29;

  9. const int TrigPin5 = 30;

  10. const int EchoPin5 = 31;

  11. const int leftMotor1 = 32;

  12. const int leftMotor2 = 34;

  13. const int RightMotor1 =36;

  14. const int RightMotor2 =38;

  15. int distance_cm1 = 0;

  16. int distance_cm2 = 0;

  17. int distance_cm3 = 0;

  18. int distance_cm4 = 0;

  19. int distance_cm5 = 0;


  20. void setup() {

  21. pinMode(TrigPin1,OUTPUT);

  22. pinMode(EchoPin1,INPUT);

  23. pinMode(TrigPin2,OUTPUT);

  24. pinMode(EchoPin2,INPUT);

  25. pinMode(TrigPin3,OUTPUT);

  26. pinMode(EchoPin3,INPUT);

  27. pinMode(TrigPin4,OUTPUT);

  28. pinMode(EchoPin4,INPUT);

  29. pinMode(TrigPin5,OUTPUT);

  30. pinMode(EchoPin5,INPUT);

  31. pinMode(leftMotor1, OUTPUT);

  32. pinMode(leftMotor2, OUTPUT);

  33. pinMode(RightMotor1, OUTPUT);

  34. pinMode(RightMotor2, OUTPUT);

  35. Serial.begin(9600);

  36. }

  37. void loop() {

  38. digitalWrite(TrigPin1,LOW);

  39. delayMicroseconds(2);

  40. digitalWrite(TrigPin1,HIGH);

  41. delayMicroseconds(10);

  42. digitalWrite(TrigPin1,LOW);

  43. distance_cm1 = pulseIn(EchoPin1,HIGH)/58;

  44. digitalWrite(TrigPin2,LOW);

  45. delayMicroseconds(2);

  46. digitalWrite(TrigPin2,HIGH);

  47. delayMicroseconds(10);

  48. digitalWrite(TrigPin2,LOW);

  49. distance_cm2 = pulseIn(EchoPin2,HIGH)/58;

  50. digitalWrite(TrigPin3,LOW);

  51. delayMicroseconds(2);

  52. digitalWrite(TrigPin3,HIGH);

  53. delayMicroseconds(10);

  54. digitalWrite(TrigPin3,LOW);

  55. distance_cm3 = pulseIn(EchoPin3,HIGH)/58;

  56. digitalWrite(TrigPin4,LOW);

  57. delayMicroseconds(2);

  58. digitalWrite(TrigPin4,HIGH);

  59. delayMicroseconds(10);

  60. digitalWrite(TrigPin4,LOW);

  61. distance_cm4 = pulseIn(EchoPin4,HIGH)/58;

  62. digitalWrite(TrigPin5,LOW);

  63. delayMicroseconds(2);

  64. digitalWrite(TrigPin5,HIGH);

  65. delayMicroseconds(10);

  66. digitalWrite(TrigPin5,LOW);

  67. distance_cm5 = pulseIn(EchoPin5,HIGH)/58;

  68. Serial.print(distance_cm1);

  69. Serial.print("cm");

  70. Serial.print("   ");

  71. Serial.print(distance_cm2);

  72. Serial.print("cm");

  73. Serial.print("   ");

  74. Serial.print(distance_cm3);

  75. Serial.print("cm");

  76. Serial.print("   ");

  77. Serial.print(distance_cm4);

  78. Serial.print("cm");

  79. Serial.println("   ");

  80. Serial.print(distance_cm5);

  81. Serial.print("cm\n");

  82. delay(10);

  83. if( distance_cm3>25)

  84. {

  85. if( distance_cm1<25)

  86. {

  87. right();

  88. delay(250);}

  89. if( distance_cm2<20)

  90. {

  91. right();

  92. delay(200);}

  93. if( distance_cm5<25)

  94. {

  95. left();

  96. delay(250);}

  97. if( distance_cm4<20)

  98. {

  99. left();

  100. delay(200);}

  101. }

  102. if( distance_cm3<25)

  103. {

  104. back();

  105. delay(250);

  106. right();

  107. delay(250);

  108. }

  109. else

  110. {

  111. forward();

  112. delay(50);

  113. }

  114. }

  115. void forward()

  116. {

  117. digitalWrite(leftMotor1,HIGH);

  118. digitalWrite(leftMotor2,LOW);

  119. digitalWrite(RightMotor1,HIGH);

  120. digitalWrite(RightMotor2,LOW);

  121. }

  122. void left()

  123. {

  124. digitalWrite(leftMotor1,HIGH);

  125. digitalWrite(leftMotor2,LOW);

  126. digitalWrite(RightMotor1,LOW);

  127. digitalWrite(RightMotor2,HIGH);

  128. }

  129. void right()

  130. {

  131. digitalWrite(leftMotor1,LOW);

  132. digitalWrite(leftMotor2,HIGH);

  133. digitalWrite(RightMotor1,HIGH);

  134. digitalWrite(RightMotor2,LOW);

  135. }

  136. void stop()

  137. {

  138. digitalWrite(leftMotor1,LOW);

  139. digitalWrite(leftMotor2,LOW);

  140. digitalWrite(RightMotor1,LOW);

  141. digitalWrite(RightMotor2,LOW);

  142. }


  143. void back()

  144. {

  145. digitalWrite(leftMotor1,LOW);

  146. digitalWrite(leftMotor2,HIGH);

  147. digitalWrite(RightMotor1,LOW);

  148. digitalWrite(RightMotor2,HIGH);

  149. }
复制代码

升降台部分代码:
  1. int x;

  2. void setup()

  3. {

  4. pinMode(6,OUTPUT);

  5. pinMode(5,OUTPUT);

  6. pinMode(4,OUTPUT);

  7. digitalWrite(6,LOW);

  8. }

  9. void loop()

  10. {

  11. digitalWrite(4,HIGH);

  12. for(x = 0; x < 800; x++)

  13. {

  14. digitalWrite(5,HIGH);

  15. delayMicroseconds(1000);

  16. digitalWrite(5,LOW);

  17. delayMicroseconds(1000);

  18. }

  19. delay(100);

  20. digitalWrite(4,LOW);

  21. for(x = 0; x < 800; x++)

  22. {

  23. digitalWrite(5,HIGH);

  24. delayMicroseconds(1000);

  25. digitalWrite(5,LOW);

  26. delayMicroseconds(1000);

  27. }

  28. delay(100);

  29. }
复制代码

图像识别部分代码:
  1. import sensor, image, time

  2. from pyb import UART

  3. yellow_threshold   = (24, 100, 68, -24, 34, 86)

  4. sensor.reset()

  5. sensor.set_pixformat(sensor.RGB565)

  6. sensor.set_framesize(sensor.QQVGA)

  7. sensor.skip_frames(10)

  8. sensor.set_auto_whitebal(False)

  9. clock = time.clock()

  10. uart = UART(3, 115200)

  11. K=1000

  12. while(True):

  13. img = sensor.snapshot()

  14. blobs = img.find_blobs([yellow_threshold])

  15. if len(blobs) == 1:

  16. #if blobs:

  17. b = blobs[0]

  18. img.draw_rectangle(b[0:4])

  19. img.draw_cross(b[5], b[6])

  20. Lm = (b[2]+b[3])/2

  21. length = K/Lm

  22. output_str ="%d" %   (length)

  23. print('you send:',output_str)

  24. uart.write(output_str+'\n')

  25. else:

  26. print('not found!')
复制代码


想了解更多机器人开源项目资料请关注 机器谱网站 https://www.robotway.com





本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-3-29 18:54 , Processed in 0.043278 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表