A.I. Powered Claw Car
| Engineer | School | Area of Interest | Grade |
|---|---|---|---|
| Zia S. | Archbishop Mitty Highschool | Computer Engineering | Incoming Sophmore |
3rd Milestone (A.I. Powered Claw Car)
Summary
Project
My project is an A.I. Powered Claw Car, a robot controlled by a wireless remote that travels using 4 wheels and has a servo-powered claw attached on top. Using a raspberry camera module and the object identification A.I. program, Tensorflow, it is capable of identifying various objects based a training data set and pick them up with the claw.
Components
- 4 Wheel Acrylic Car Chassis
- RC Wheels
- TT Motors
- L298N Motor Driver Module
- Arduino Uno
- Arduino Nano
- Arduino Joystick Module
- Jumper Cables
- Small Breadboards
- 9V Batteries
- NRF24L01 Wireless Modules<1i>
- Cokoino Claw Arm
- Wooden Board
- Small Switch
- 1 uF Capacitors </ul>
- Acrylic Plates
- Arduino Nano
- Arduino Shield
- Servo Package
- Joysticks
- USB Cable
- Jumper Cables
- Battery Case
- AA Batteries
- Turntable
- Acrylic Plate
- Arduino Uno
- Mini Breadboard
- TT Wheel
- 1" Wheel
- TT Motor
- WLAN Module
- USB Cable
- Jumper Cables
- 9V Battery
- IR Reciever
- IR Controller
- Velcro
How Components Work Together
The Arduino Nano, the joystick module, the small breadboard, and the wireless module are all mounted on a small, rectangular board with the battery velcroed behind. The battery powers the Arduino Nano that contains the code to read the analog values of joystick based on its position, convert the values into bytes (integers 0-255), and transmit those values through the wireless module to be received by the wireless module of the Arduino Nano on the car chassis. With the switch, the remote can be turned on and off. The Arduino Uno on the car chassis processes the received values and based on them, commands the motor driver to power the wheels in a certain direction. For example, holding the joystick forward will move the car forwards, holding it backward moves the car backwards, and vice versa for turining left and right. The entire car chassis is also powered by a 9V battery.Progress
For the third milestone, I cut out a small rectangular board with a saw and drilled holes into it to act as the base for my remote. I then screwed the joystick module on the board and using the breadboard adhesive, mounted the small breadboard with the Arduino Nano on the board as well. I then made the necessary connection for the remote to work using the jumper cables and also attached the battery to the back of the board using velcro. Finally, I finished the remote by taping the wireless module to the middle of the board. I also setup the necessary connections on the Arduino Uno of the car to make sure that the wireless module was working properly. I coded the remote and the car and was successfully able to control the car wirelessly with little latency. However, I later realized that the car chassis I had from milestone 1 was not large enough to fit all of the necessary hardware for the robot so I asked my instructors for a bigger car chassis to replace it. I assembled the new chassis with four new motors mand mounted the Arduino Uno, a new motor driver, a small breadboard for ground and power connections, and a 9V battery to it. I then reprogrammed the Arduino Uno to controll four wheels instead of two. Finally, I mounted the claw on top of the car using screws and tested the car to see how well it could move with the heavy claw. It worked very well and was able to move effortlessly.Challenges Faced
I had many challenges with the third milestone with one of the them being the setup of the wireless module. It required very specific code and wire connections for it to work properly as it has 7 pins that neeeded to be connected to specfic places on the Arduinos for it to work properly. When it did not work the first time, I had to solder a capacitor to each module for less power fluctations so that a smooth connection could be created bewteen the two wireless modules. It started working afterwards, but I then ran into another issue with the transmission of data. At first, I coded the remote to transmit the x value first and then the y value of the joystick module to the car, causing a bug in which the value that was received second would permanently drop the zero and not update. To fix this, I changed the code to send the joystick values in a structure or a data package so the values were sent at the same time. Overall, it took me almost two days to setup the wireless modules. Another challenge I faced was that one motor would always be slower than the other when moving forward, leading to the car turning. This was a problem most likely caused by the universal wheel or the motor driver glitching out but was fixed when I switched to the new car chassis with four wheels, making it virtually impossible for it to not move forward when intended. The switch unfortunetly led to a new problem that wasted three days. The previous motor driver was capable of controlling the speed of the motors with purely code, but the new motor driver needed a separate pin, the Enable pin, to be connected to the Arduino Uno in order to control the speed of the motors. I was absolutely not able to get this to work and tried multiple motor drivers to find out what was wrong. In the end, I gave on on speed control as it was already taking up too much time and moved on to coding the new controls for the car. I was able to control the car as before except it would go forward without turning which was fantastic but run into yet another issue: my computer suddenly stopped working and was not able to access the arduino .inos for the remote and the car, disallowing me from further debugging. I cannot access the codes which is why they are not on this portfolio. As such, I am forced to leave the car and remote as they are despite any bugs that may come up.Next Step
For my modifications or final milestone, I shall add the A.I aspect of the project and use Tensorflow, an object identification program, to power the claw using a Raspberry Pi.Hexapod_Ultrasonic2_OLED.ino
```c++ ``` # Second Milestone (A.I. Powered Claw Car)
Summary
Project
My project is an A.I. Powered Claw Car, a robot that travels using 2 wheels controlled by servos and has a claw attached on top. Using a raspberry camera module and an object identification A.I. program, it is capable of identifying various objects based a training data set and pick them up with the claw.Components
How Components Work Together
The acrylic parts of the claw act as the base and main body that house the servos, Arduino Nano, and Arduino shield. The base of the claw has a servo that rotates a ball-bearing wheel, rotatating the entire claw. Two other servos control the arm of the claw, making it capable of moving up or down. The final servo controls the actual claw; it is attached to one claw half with a gear at the end that is in contact with the gear of the other claw half so when the servo rotates, the entire claw grabs or releases. The servos are controlled by two joysticks that are connected to the Arduino Nano; one controls the rotation and position of the claw arm and the other control the claw itself.Progress
For the second milestone, I had to cut the ground and voltage wires of the battery port of the claw and solder them to a new battery case as lithium batteries are not allowed in Bluestamp projects. Before beginning assembly, I used the Arduino program, Servo_90_ADJ.ino, provided by the pdf claw tutorial to adjust the servos to all be 90°, using a USB to connect the Arduino Nano to my computer. I then assembled the stand for the Arduino Nano and shield using standoffs and did the same for the ball-bearing base of the claw arm. Next, I added the servo for the base of the claw arm and attached a rectangular piece to it that would allow the servo to rotate the entire base. I then screwed together the claw arm with two servos, making sure that they were straight. Finally, I screwed in the servo for the claw and attached the claw half to it and lined up the other half with the first. I then assembled a simple controller using one of the acrylic plates and screwing in two joysticks. I then did the necessary wiring for the claw to properly work and be controllled by the claw. I uploaded the Arduino program, Arm.ino, provided by the tutorial to the Arduino Nano, allowing me to control the claw with the joysticks.Challenges Faced
One of the major problems I faced with the claw assembly was screwing in small screws into tiny nuts in tight spaces. It was quite difficult for me and wasted a lot of time. Eventually, I figured out a way to make it easier by always turning the claw over to a side in which the nut would be lying down to facilitate the screwing process. Another problem I faced was accidently attached the rectangular piece the wrong way on the base servo. This was an issue because one, the traction of the servo and the ball-bearing base was weak, leading to little rotation, and two, removing the servo arm from the rectangular piece is difficult. The servo arm is attached to the retangular piece using self-tapping screws which are difficult to remove once they are screwed in. It also did not help that the screwdriver I was using broke away from the handle, making it ineffective. I wasted more time trying to remove the self-tapping screws but managed to get them out using a plier that had a good grip on them.Next Step
My third milestone will be mounting the claw onto the car and programming them to be controlled by the same controller by making communication between the Arduino Uno of the car and Arduino Nano of the claw possible. I must learn how to make communication between two Arduino board possible and how to make a custom controller for the robot.Servo_90_ADJ.ino
```c++ // /* * This code applies to cokoino mechanical arm * Through this link you can download the source code: * https://github.com/Cokoino/CKK0006 * Company web site: * http://cokoino.com/ #includeSchematic
Arm.ino
```c++ /* * This code applies to cokoino mechanical arm * Through this link you can download the source code: * https://github.com/Cokoino/CKK0006 * Company web site: * http://cokoino.com/ * ________ * ----|servo4| * | -------- * |servo3| * | * | * |servo2| * | * | * ___________ * | servo1 | * ____________________ * ____________________ * Fanctions: * arm.servo1.read(); //read the servo of angle * arm.servo2.read(); * arm.servo3.read(); * arm.servo4.read(); * * arm.servo1.write(angle); //servo run * arm.servo2.write(angle); * arm.servo3.write(angle); * arm.servo4.write(angle); * * arm.left(speed); //perform the action * arm.right(speed); * arm.up(speed); * arm.down(speed); * arm.open(speed); * arm.close(speed); * * arm.captureAction(); //capture the current action,return pointer array * arm.do_action(int *p,int speed); //P is a pointer to the array * * arm.JoyStickL.read_x(); //Returns joystick numerical * arm.JoyStickL.read_y(); * arm.JoyStickR.read_x(); * arm.JoyStickR.read_y(); */ #include "src/CokoinoArm.h" #define buzzerPin 9 CokoinoArm arm; int xL,yL,xR,yR; const int act_max=10; //Default 10 action,4 the Angle of servo int act[act_max][4]; //Only can change the number of action int num=0,num_do=0; /////////////////////////////////////////////////////////////// void turnUD(void){ if(xL!=512){ if(0<=xL && xL<=100){arm.up(10);return;} if(900<xL && xL<=1024){arm.down(10);return;} if(100<xL && xL<=200){arm.up(20);return;} if(800<xL && xL<=900){arm.down(20);return;} if(200<xL && xL<=300){arm.up(25);return;} if(700<xL && xL<=800){arm.down(25);return;} if(300<xL && xL<=400){arm.up(30);return;} if(600<xL && xL<=700){arm.down(30);return;} if(400<xL && xL<=480){arm.up(35);return;} if(540<xL && xL<=600){arm.down(35);return;} } } /////////////////////////////////////////////////////////////// void turnLR(void){ if(yL!=512){ if(0<=yL && yL<=100){arm.right(0);return;} if(900<yL && yL<=1024){arm.left(0);return;} if(100<yL && yL<=200){arm.right(5);return;} if(800<yL && yL<=900){arm.left(5);return;} if(200<yL && yL<=300){arm.right(10);return;} if(700<yL && yL<=800){arm.left(10);return;} if(300<yL && yL<=400){arm.right(15);return;} if(600<yL && yL<=700){arm.left(15);return;} if(400<yL && yL<=480){arm.right(20);return;} if(540<yL && yL<=600){arm.left(20);return;} } } /////////////////////////////////////////////////////////////// void turnCO(void){ if(xR!=512){ if(0<=xR && xR<=100){arm.close(0);return;} if(900<xR && xR<=1024){arm.open(0);return;} if(100<xR && xR<=200){arm.close(5);return;} if(800<xR && xR<=900){arm.open(5);return;} if(200<xR && xR<=300){arm.close(10);return;} if(700<xR && xR<=800){arm.open(10);return;} if(300<xR && xR<=400){arm.close(15);return;} if(600<xR && xR<=700){arm.open(15);return;} if(400<xR && xR<=480){arm.close(20);return;} if(540<xR && xR<=600){arm.open(20);return;} } } /////////////////////////////////////////////////////////////// void date_processing(int *x,int *y){ if(abs(512-*x)>abs(512-*y)) {*y = 512;} else {*x = 512;} } /////////////////////////////////////////////////////////////// void buzzer(int H,int L){ while(yR<420){ digitalWrite(buzzerPin,HIGH); delayMicroseconds(H); digitalWrite(buzzerPin,LOW); delayMicroseconds(L); yR = arm.JoyStickR.read_y(); } while(yR>600){ digitalWrite(buzzerPin,HIGH); delayMicroseconds(H); digitalWrite(buzzerPin,LOW); delayMicroseconds(L); yR = arm.JoyStickR.read_y(); } } /////////////////////////////////////////////////////////////// void C_action(void){ if(yR>800){ int *p; p=arm.captureAction(); for(char i=0;i<4;i++){ act[num][i]=*p; p=p+1; } num++; num_do=num; if(num>=act_max){ num=0; buzzer(600,400); } while(yR>600){yR = arm.JoyStickR.read_y();} //Serial.println(act[0][0]); } } /////////////////////////////////////////////////////////////// void Do_action(void){ if(yR<220){ buzzer(200,300); for(int i=0;i<num_do;i++){ arm.do_action(act[i],15); } num=0; while(yR<420){yR = arm.JoyStickR.read_y();} for(int i=0;i<2000;i++){ digitalWrite(buzzerPin,HIGH); delayMicroseconds(200); digitalWrite(buzzerPin,LOW); delayMicroseconds(300); } } } /////////////////////////////////////////////////////////////// void setup() { //Serial.begin(9600); //arm of servo motor connection pins arm.ServoAttach(4,5,6,7); //arm of joy stick connection pins : xL,yL,xR,yR arm.JoyStickAttach(A0,A1,A2,A3); pinMode(buzzerPin,OUTPUT); } /////////////////////////////////////////////////////////////// void loop() { xL = arm.JoyStickL.read_x(); yL = arm.JoyStickL.read_y(); xR = arm.JoyStickR.read_x(); yR = arm.JoyStickR.read_y(); date_processing(&xL,&yL); date_processing(&xR,&yR); turnUD(); turnLR(); turnCO(); C_action(); Do_action(); } ``` # First Milestone (A.I. Powered Claw Car)
Summary
Project
My project is an A.I. Powered Claw Car, a robot that travels using 2 wheels controlled by servos and has a claw attached on top. Using a raspberry camera module and an object identification A.I. program, it is capable of identifying various objects based a training data set and pick them up with the claw.Components
How Components Work Together
The acrylic plate acts as the base of the car; everything including the servos, Arduino Uno, mini breadboard, L9110 module, universal wheel, and 9V Battery is attached to it. Whenever a button is pressed on the IR controller, the IR reciever recieves the signal and sends it to the Arduino Uno. The Uno then processes the signal and depending on the button pressed, sends a signal to the L9110 module with the specific activation truth table. This activates the motors and moves the car.Progress
For the first milestone, I assembled the whole car and downloaded the necessary software, such as the Arduino library IRRemote and the Processing IDE, to control the car using the IR remote.Challenges Faced
I had a few troubles attaching the motors to the acrylic plate as the window for attachment was very tight and took me a bit to attach. I also wasted much time looking for specific standoffs that were missing from my kit that were needed for the universal wheel and ended up having to use slightly longer standoffs.Next Step
The next step is completing my second milestone: assembling the claw and programming it.Car_Remote_Control.ino
Schematic