We are going to develop and learn the four things above so we can complete our semester 2 project.
Ms.White is guiding us to use these skills to later help us choose our project
We are going to use our robotic are to later help us create our semester 2 project.
I like the hand design on this arm, which is all we will be building with our cardboard creation. The pincher is a good shape.
I pretty much immediately knew i want one servo to connect to one pincher and one servo to connect to the other and when the arduino told the servo to spin clockwise for one servo and counter clockwise for the other the hand would open up and then they would spin the opposite way and they would close.
This is my robot working with it's code in action picking up a box.
This is a good angle on my robot so you can see that handle and how it's handheld.
modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>
Servo myservo;
Servo myservo1;// create servo object to control a servo
// twelve servo objects can be created on most boards
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo1.attach(10); // attaches the servo on pin 10 to the servo object
}
void loop() {
myservo.write(0);
myservo1.write(90);
delay(5000);
myservo.write(90);
myservo1.write(0);
delay(5000);
// for (pos = 0; pos <= 90; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
// myservo.write(pos);
// myservo1.write(pos);// tell servo to go to position in variable 'pos'
// delay(15); // waits 15ms for the servo to reach the position
// }
// for (pos = 90; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
// myservo.write(pos); // tell servo to go to position in variable 'pos'
// myservo1.write(pos); // tell servo to go to position in variable 'pos'
// delay(15); // waits 15ms for the servo to reach the position
// }
}
In this video you can see my Robotic Arm without it's claw working to move back and forward for grabbing things in the future. To the left is a photo so you can see how it is put togther.
Today we practiced calibrating my servos specifically the claw and in the video to the left you can see it opening and closing.
Here the left servo is in action moving upwards to allow my arm to have more downward and upward reach. We worked on this today in class.
Above is a video of the base of my robot moving at a 180 degree angle due to my base servo being properly calculated. It moves From degree 0 to 180 which i have marked on the base of the robot.
#include <Servo.h>
Servo left;
Servo right;// create servo object to control a servo
// twelve servo objects can be created on most boards
Servo claw;
Servo base;
int pos = 0;
int rpos = 0;
int lpos = 0;
int bpos = 0;
int cpos = 0;
void setup() {
left.attach(9); // attaches the servo on pin 9 to the servo object
base.attach(7);
claw.attach(8);
right.attach(10); // attaches the servo on pin 10 to the servo object
// up
right.write(0); //back
left.write(90); // up
base.write(90); //middle
claw.write(90); //open
delay(3000);
//down
right.write(0); //back
for (lpos = 90; lpos >= 40; lpos -= 1) { //small arm up
left.write(lpos);
delay(15);
}
base.write(90); //middle
claw.write(90); //open
delay(3000);
//rotate
right.write(0); //back
left.write(40); // up
for (bpos = 90; bpos >= 0; bpos -= 1) { //small arm up
base.write(bpos);
delay(15);
}
claw.write(90); //open
delay(3000);
//stretch
for (rpos = 0; rpos >= 90; rpos += 1) { //forward position
right.write(rpos);
delay(15);
}
for (lpos = 40; lpos >= 70; lpos += 1) { //forward position
left.write(lpos);
delay(15);
}
base.write(0); //middle
claw.write(90); //open
delay(3000);
//close
right.write(90); //back
left.write(80);
base.write(0); //middle
claw.write(0); //open
delay(3000);
//retract
right.write(0); //back
left.write(40);
base.write(0); //middle
claw.write(0); //open
delay(3000);
//turn fully left
right.write(0); //back
left.write(40);
base.write(180); //middle
claw.write(0); //open
delay(3000);
//stretch
right.write(90); //back
left.write(80);
base.write(180); //middle
claw.write(0); //open
delay(3000);
//open
right.write(90); //back
left.write(80);
base.write(180); //middle
claw.write(90); //open
delay(3000);
//retract
right.write(0); //back
left.write(40);
base.write(180); //middle
claw.write(90); //open
delay(3000);
//rotate
right.write(0); //back
left.write(40);
base.write(90); //middle
claw.write(90); //open
delay(3000);
//starting pos
right.write(0); //back
left.write(90);
base.write(90); //middle
claw.write(90); //open
delay(3000);
//for (lpos = 110; lpos >= 60; lpos -= 1) { //small arm up
// left.write(lpos);
// delay(15);
//}
// for (lpos = 60; lpos >= 90; lpos += 1) { //forward position
// left.write(lpos);
// delay(15);
//
}
void loop() {
}
// delay(15);
//
}
void loop() {
}
In my video the robot had to complete 10 motions to pickup a a box and then move it over. I had to do this entirely independently a find a way to allow my robot to do this using my the degrees of the servos.
#include <Servo.h>
Servo left;
Servo right;// create servo object to control a servo
// twelve servo objects can be created on most boards
Servo claw;
Servo base;
int pos = 0;
int rpos = 0;
int lpos = 0;
int bpos = 0;
int cpos = 0;
void setup() {
left.attach(9); // attaches the servo on pin 9 to the servo object
base.attach(7);
claw.attach(8);
right.attach(10); // attaches the servo on pin 10 to the servo object
// starting pos
right.write(0); //back
left.write(90); // up
base.write(90); //middle
claw.write(90); //open
delay(3000);
// rotate left
right.write(0); //back
left.write(90); // up
base.write(45); //middle
claw.write(90); //open
delay(3000);
// slightly down
right.write(0); //back
left.write(60); // up
base.write(45); //middle
claw.write(90); //open
delay(3000);
// stretch
right.write(90); //back
left.write(80); // up
base.write(45); //middle
claw.write(90); //open
delay(3000);
// close claw
right.write(90); //back
left.write(80); // up
base.write(45); //middle
claw.write(0); //open
delay(3000);
// retract
right.write(0); //back
left.write(60); // up
base.write(45); //middle
claw.write(0); //open
delay(3000);
// slightly up
right.write(0); //back
left.write(90); // up
base.write(45); //middle
claw.write(0); //open
delay(3000);
// rotate to other side
right.write(0); //back
left.write(90); // up
base.write(135); //middle
claw.write(0); //open
delay(3000);
// slightly down
right.write(0); //back
left.write(60); // up
base.write(135); //middle
claw.write(0); //open
delay(3000);
// stretch
right.write(90); //back
left.write(80); // up
base.write(135); //middle
claw.write(0); //open
delay(3000);
// open
right.write(90); //back
left.write(80); // up
base.write(135); //middle
claw.write(90); //open
delay(3000);
// starting pos
right.write(0); //back
left.write(90); // up
base.write(90); //middle
claw.write(90); //open
delay(3000);
}
void loop() {
}
// delay(15);
In this video you can see my sensors reaction to different colors with in it's view.
Shows the connections between the RGB sensor and my arduino nano and 4 servo motors in my robotic arm
This video contains the code and such needed for building a sorting robot and it also has the circuit and parts and measurements And has 2 levels to scan the color and then move it to its location
This one similiar to the other video the the left takes one skittle at a time and has multiple levels on it that go down to a ramp to the pile of the color you want
Sketch of basic layout for our prototype skittle sorter
The funnel that the skittles will fall into
This will be the holder for the sensor that keeps it in place with an opening to scan skittles colors
This will hold the skittles and take them to be scanned and then sent down the ramp
Tape used to narrow the skittles so one comes out at a time
This is a steep ramp designed to catch the skittle and have it fall into the correct box
The structure is a tower reinforced with cardboard and the skittles make their way down the tower
Attached the sensor with a cardboard holder with a hole
It had to be changed because the ramp interfered with the servos movement and it was too close to the boxes to make the skittles go in
#include <Servo.h>
#include <Wire.h>
#include "Adafruit_TCS34725.h"
float active = true;
float phase = 0;
float pos;
Servo servo1;
Servo servo2;
//reds = 125, 75, 60
//orang = 140, 70, 50
//yellow = 130, 80, 50
//purp = 120, 80, 60
//green = 105, 90, 60
//carboard = 105, 85, 70
#define redpin 2
#define greenpin 3
#define bluepin 4
#define commonAnode true
byte gammatable[256];
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
void setup() {
// put your setup code here, to run once:
//colorview stuff
Serial.begin(9600);
if (tcs.begin()) {
Serial.println("Found sensor");
} else {
Serial.println("No TCS34725 found ... check your connections");
while (1); // halt!
}
#if defined(ARDUINO_ARCH_ESP32)
ledcAttachPin(redpin, 1);
ledcSetup(1, 12000, 8);
ledcAttachPin(greenpin, 2);
ledcSetup(2, 12000, 8);
ledcAttachPin(bluepin, 3);
ledcSetup(3, 12000, 8);
#else
pinMode(redpin, OUTPUT);
pinMode(greenpin, OUTPUT);
pinMode(bluepin, OUTPUT);
#endif
for (int i=0; i<256; i++) {
float x = i;
x /= 255;
x = pow(x, 2.5);
x *= 255;
if (commonAnode) {
gammatable[i] = 255 - x;
} else {
gammatable[i] = x;
}
//Serial.println(gammatable[i]);
}
//servo stuff
servo1.attach(7);
servo2.attach(8);
servo1.write(0);
delay(1000);
servo1.write(90);
delay(1000);
servo2.write(60);
delay(2000);
servo2.write(120);
delay(2000);
servo2.write(90);
delay(2000);
active = false;
pos = 90;
phase = 1;
}
float red, green, blue;
void loop() {
// put your main code here, to run repeatedly:
if(phase == 1 && active == false){
active = true;
for(int i = 0; i<90; i++){
servo1.write(i);
delay(10);
}
servo1.write(90);
delay(2000);
for(int i = 90; i>45; i--){
servo1.write(i);
delay(10);
}
servo1.write(45);
delay(1000);
active = false;
phase = 2;
while(phase == 2 && active == false){
scan();
if(red >= 140 && red <= 158 && green >= 60 && green <= 72 && blue >= 51 && blue <= 72){ //red
active = true;
for(int i = 90; i>0; i--){
servo2.write(i);
delay(10);
}
pos = 0;
servo2.write(0);
delay(200);
for(int i = 45; i>0; i--){
servo1.write(i);
delay(10);
}
servo1.write(0);
} else if(red >= 125 && red <= 135 && green >= 70 && green <= 79 && blue >= 45 && blue <= 56){//purple
active = true;
for(int i = 90; i>60; i--){
servo2.write(i);
delay(10);
}
pos = 60;
servo2.write(60);
delay(200);
for(int i = 45; i>0; i--){
servo1.write(i);
delay(10);
}
servo1.write(0);
} else if(red >= 114 && red <= 122 && green >= 86 && green <= 91 && blue >= 42 && blue <= 51){//green
active = true;
for(int i = 45; i>0; i--){
servo1.write(i);
delay(10);
}
pos = 90;
servo1.write(0);
} else if(red >= 122 && red <= 139 && green >= 72 && green <= 81 && blue >= 34 && blue <= 42){//yellow
active = true;
for(int i = 90; i<120; i++){
servo2.write(i);
delay(10);
}
servo2.write(120);
delay(200);
for(int i = 45; i>0; i--){
servo1.write(i);
delay(10);
}
pos = 120;
servo1.write(0);
} else if(red >= 149 && red <= 158 && green >= 60 && green <= 66 && blue >= 37 && blue <= 44){//orange
active = true;
for(int i = 90; i<180; i++){
servo2.write(i);
delay(10);
}
servo2.write(180);
delay(200);
for(int i = 45; i>0; i--){
servo1.write(i);
delay(10);
}
pos = 180;
servo1.write(0);
}
delay(60);
}
delay(1000);
if(pos != 90){
if(pos > 90){
for(int i = pos; i>90; i--){
servo2.write(i);
delay(10);
}
} else if(pos < 90){
for(int i = pos; i<90; i++){
servo2.write(i);
delay(10);
}
}
}
servo2.write(90);
delay(200);
active = false;
phase = 1;
}
}
void scan(){
tcs.setInterrupt(false); // turn on LED
delay(60); // takes 50ms to read
tcs.getRGB(&red, &green, &blue);
tcs.setInterrupt(true); // turn off LED
Serial.print("R:\t"); Serial.print(int(red));
Serial.print("\tG:\t"); Serial.print(int(green));
Serial.print("\tB:\t"); Serial.print(int(blue));
// Serial.print("\t");
// Serial.print((int)red, HEX); Serial.print((int)green, HEX); Serial.print((int)blue, HEX);
Serial.print("\n");
#if defined(ARDUINO_ARCH_ESP32)
ledcWrite(1, gammatable[(int)red]);
ledcWrite(2, gammatable[(int)green]);
ledcWrite(3, gammatable[(int)blue]);
#else
analogWrite(redpin, gammatable[(int)red]);
analogWrite(greenpin, gammatable[(int)green]);
analogWrite(bluepin, gammatable[(int)blue]);
#endif
}
Above I cut out all the boxes and worked on making sure they were the right height for the ramp because I made them too tall the first time
This is a building functional part of the skittle sorter is used to hold all skittles going through the process of skittles and ensuring that they come out of the pipe on by one for sensing.
It was tested by simply putting skittles down the pipe to make sure they could be held and moved smoothly. When we tested this we observed that the pipe was too slim at the beginning to skittles to pass but after removing some excess cardboard the problem was fixed.
Another issue observed was more than one skittle would come out at the bottom because it was placed in too high so tape was added to slim the shoot for one skittle to be outputted at a time.
This Function of the sorter was one of the most crucial parts for both building and coding. As for building it is the mechanism that sends the sensor the skittles and scans them. A servo holds a disk with a indentation in it to catch the skittles and then it swivels to be scanned and sent down a shoot.
We tested it by putting skittles down the shoot one at a time so it would land in the sensor and then allow it to go through the function making sure it's color was identified properly and it didn't get jammed.
Some problems we discovered in the build were that the sensor was at one point too far from the skittles and it couldn't get a good read so we had to lower it, we also had to alter the size of the disc before attaching it so it wouldn't hit the side of the carboard so we made it smaller.
This is in my opinion our second most important build. It functions as a moving ramp that can change its aim using a servo to send skittles into the correct box based on the scanners information.
We tested this by putting skittles through the hole in the top to see how the skittles fell. We also tested it by putting it through the sensor as well to make sure the servo was getting its full movement.
After testing we noticed some errors, the ramp would hit the sides of the cardboard so we decided to cut out the sides so it could fully swivel. We also needed to iterate the back of the ramp by cutting a chunk out so that the servo didn't get caught on it. Finally we noticed the skittles weren't going out far enough so we added more bend to the ramp by cutting it so the skittles had more momentum.
This is a video of our final functioning robot, sorting the skittles into secured boxes using a disc to drag the skittles into the sensor to determine its color and then be sent down a ramp into the boxes, the skittles sort the correct color 8/10 times.
A magnet usage example on how to get a somewhat Idea on separating the magnetic from the non- magnetic.
The recycling process done in facilities is multi- stepped and contain multiple way of sorting the items, like using spinning discs to kick up light paper and cardboard, a weigh and tipping machine that make sure an even amount of recyclables enter the machine, gusts of air that blow glass away, magnets to get rid of metal and tin and an infared sensor to see what type of plastic is around and use air to blow it off, and aluminum is sorted by being pushing by an opposing metal force
A simple grate that drops small items down beneath. I think this would be a good way to solve our recycling problem because it could be made more complex and this simple function could help to separate initially smaller items from large ones and then they could be further processsed
Air blows heavy pieces out of the flow. Which could easily remove lighter, less dense materials which could be useful too our machine
With this project, I was tasked with creating a program that could identify what kind of recyclable trash an object is through just an image. This was a difficult task to complete, and took a lot of trial and error, but I eventually made a program in Python that uses functions and datasets to analyze the aspects of the image, like shade and shape. I then used a neural network to train the model to identify different kinds of Recycled items through repeated tests and trials of the model. The model that came out of this testing is able to determine which of the 4 types (Crumpled paper, can, carboard box, and milk carton) an object is with 100% accuracy. The code used in this model is linked to the left.
The goal I wanted to achieve was a model that was trained to tell the difference between these 4 items. We hoped that a program like this could be used to automatically sort trash right when its put into a recycling bin.
Can
Carton
Paper
Box
With a data set of 1008 48 x 48 pixel images with 252 in each file I was able to use all of these for my model to properly differentiate my 4 recycled items. Each image is taken at a slightly different angle to show a variety and improve the accuracy when predicting the object. Code within the project directs the model on the path it must take through my drive to reach these files.
This is the code used to build the actual model. The first line of code inputs keras library which is needed for the model to use certain skills. The second line of code calls for a layer with a size of 1024 this improves the models accuracy. The third line improves accuracy again with giving the output along with another dense layer. The fourth line uses the keras to define the term model so the last line can return an overall summarization of the models results.
The model was able to detect this image as paper using its image in the dataset and comparing them
The image was labeled Carton in the data set and the model was able to predict it correctly
The model could detect this image as box mostly from its darker shades in comaprision to other objects
My model had 100% accuracy when labeling images therefore we have no examples of mislabeled images.