The GitHub Repository is linked above. It is a clone of the repository we were given with the code architecture for the robot performing general manipulation. Then, we added the following two files, linked below, to complete tasks 1a and 1b.
Algorithm:
Move towards the top of the red block and the green area
Use HSV(Hue, Saturation, and Value) to segment the red block and the green area
Move toward the top of the red block
Move down and grab
Move up
Move toward the top of the green area
Move down and let go
Algorithm:
Move towards the top of the red cylinder and the blue hole
(Rough pose estimation)
Use HSV(Hue, Saturation, and Value) to segment the red cylinder and the blue area
Move toward the top of the red Cylinder, and segment again
(2nd pose estimation)
Move down and grab
Move up
Move toward the top of the blue area, and segment again
(2nd pose estimation)
Move down and let go
This was the Arduino code for controlling the arm servo and the gripper servo by using keystrokes on another computer. In the code, the pump was also intended to be controlled by the Arduino, but we did not have time to complete the hardware for it.
#include <Servo.h> // Include the Servo library
Servo armServo; // Create a Servo object
Servo gripperServo;
// Output Pins
int armServoPin = 11;
int gripperServoPin = 10;
int pumpPin = 9;
char incomingByte = 'd';
void setup() {
// sets the pins as outputs:
pinMode(pumpPin, OUTPUT);
armServo.attach(armServoPin);
gripperServo.attach(gripperServoPin);
digitalWrite(pumpPin, LOW); // pump off
armServo.write(0); // pneumatic down
gripperServo.write(0); // gripper open
delay(1000);
Serial.begin(9600);
}
void loop() {
if (Serial.available()) { // Check if serial data is available
incomingByte = Serial.read();
}
if (incomingByte == 'a'){ //gripper open
digitalWrite(pumpPin, LOW); // pump off
armServo.write(130); // gripper down
gripperServo.write(0); // gripper open
}
else if (incomingByte == 's'){
digitalWrite(pumpPin, LOW); // pump off
armServo.write(130); // gripper down
gripperServo.write(50); // gripper closed to size of block
}
else if (incomingByte == 'd'){
digitalWrite(pumpPin, LOW); // pump off
armServo.write(0); // pneumatic down
gripperServo.write(0); // gripper open
}
else if (incomingByte == 'f'){
digitalWrite(pumpPin, HIGH); // pump off
armServo.write(0); // pneumatic down
gripperServo.write(0); // gripper open
}
delay(3000);
}