In this project, there is a robot with a Raspberry pi 4, a picamera, a PCA9685 chip, an ultrasonic sensor and two servo motors was built to compete a automatic cup grasping mission with high success rate.
Content
- Servo motors
- Picamera installation
- Image processing with OpenCV & Python
- Cup Grasping Robot
PCA9685 is used to control servo moters in this project and servo motors are used to build a robotic arm and robotic paw.
PCA9685: PCA9685 is a driver control module chip, a 16-channel controller with I2C bus interface. The PWM controller of PCA9685 can control the servo motor more accurately than the Raspberry Pi.
The two servo motors are connected with one PCA9685 and they could be controled by different channels.
In "Servo_test.py", channel 8 and channel 10 control different servo moters and the value of each channel represent the degree of servo motor.
Note: It is needed to give the external power to the servo motors. As a result, there are totally two battery on this robot, one for raspberry pi and the other for servo motors
Step 2: Connect the camera with the raspberry pi and confirm the Picamera with this command $vcgencmd get_camera. If the result is like the following picture, it works.
In this project, the target is a cup with red color and there are some steps neededs to be done.
In this step, "test_video.py" is used to ensure turn on the Picamera, transmit the frames in real time and set various parameters of the frames.
Transmitting the frames in real time is the pivotal factor. When the frames can be transmitted in real time, the comming feature extraction function can be successed.
In this step, "ColorDetect_Red.py" would process the image and find out where the red color parts are.
Depends on the different environment, the paremeters of HSV values need to be modified.
Finding out the contours of red objects give a foundation of comming step which allow the robot can filter out the target cup from red objects and the central points for distance detection.
Please check "Red_contours.py".
The blue points represent the center point of red objects and the green point represents the center point of the window.
Please check "DrawRedCenter.py".
In this step, all the contours of red object are be drawn but only the biggest red contour would be drawn on its center point.
The biggest red contour is the target cup of this project.
Please check "DetectRedCup.py".
After the setting of Picamera, servo motors and feature extraction, it is needed to integrate them together to complete the robot.
The ultrasonic sensor also needs to be set to detect the distance between the robot and object in front of it.
The following diagram is the logic flow chart of this project.
Please check "Cup_Grasping_Robot".