项目作者: DiveIntoMachineLearningSUSTech

项目描述 :
智障机器人
高级语言: Python
项目地址: git://github.com/DiveIntoMachineLearningSUSTech/IntelligentRobotProject.git


Intelligent Robot Final Project

2018.1.4


Main Idea

Control our robot with gesture recognition.

  • Open CV
  • ROS Topic
  • Multithread/Multiprocess
  • Combine Opencv, ROS(CPP), Linux Bash Shell together with Python.

Open CV Core Code

  1. def reset():
  2. global status
  3. print 'reset before'
  4. time.sleep(5.5)
  5. print 'reset after'
  6. status = 0
  1. if status == 0:
  2. if fingers == 2:
  3. p = subprocess.Popen('rosrun turtle_move line', stdout=subprocess.PIPE, shell=True)
  4. print 'line'
  5. thread.start_new_thread(reset, ())
  6. elif fingers == 1:
  7. p = subprocess.Popen('rosrun turtle_move circle', stdout=subprocess.PIPE, shell=True)
  8. print 'circle'
  9. thread.start_new_thread(reset, ())
  10. else:
  11. p = subprocess.Popen('rosrun turtle_move move_turtle_goforward', stdout=subprocess.PIPE, shell=True)
  12. print 'goforward'
  13. thread.start_new_thread(reset_forward, ())

ROS Package

  1. while (ros::ok())
  2. {
  3. time_t current = time(NULL);
  4. if (current - start > 5.0f)
  5. break;
  6. speed.linear.x = 0.1; // 设置线速度为0.1m/s,正为前进,负为后退
  7. speed.angular.z = vel_rad; // 设置角速度为0rad/s,正为左转,负为右转
  8. cmdVelPub.publish(speed); // 将刚才设置的指令发送给机器人
  9. loopRate.sleep();//休眠直到一个频率周期的时间
  10. }

Gesture Recognition


Usage:

  1. export ROS_MASTER_URI=http://hostip:11311
  2. export ROS_IP=`hostname -I`
  3. catkin_make
  4. source devel/setup.bash
  5. python recongnize.py

Our Source Code: