Year 2 project, Robot Arm(week3)
Friday, February 15, 2019
Week 3:
Before attending week 3 lab session, we met
the supervisor for some suggestions regarding the problem we are facing in
the robot gripper, he gave us solutions to overcome the problem by
either changing the gripper angle in coding or changing the construction of the
gripper. In addition he suggested us to add a sensor on the edges of the car as
when the car approaches to other obstacles, it sends feedback such as ps2
vibrations.
In the lab session, we focused on solving the gripper problem.
So we decided to change the gripper original angel and servo end angel
which controls the gripper and it was tested several times. Finally the servo
worked. Our next activity was to add a distance sensor HC-SR09 to the car
to send feedback to the ps2 controller in vibration form when the can
approach any obstacle in its way. We tried to combine the two parts of the
code, unfortunately id did not work, it seems like there is a conflict between
the distance sensor and ps2 controller when carrying data transmission.
We tried harder and searched for more information and changed the code,
but is still did not work.
MIN[0] = 10;
MAX[0] = 50;
INITANGLE[0] = 30;
MIN[1] = 10;
MAX[1] = 140;
INITANGLE[1] = 90;
MIN[2] = 40;
MAX[2] = 170;
INITANGLE[2] = 90;
MIN[3] = 0;
MAX[3] = 170;
INITANGLE[3] = 90;
myservo1.write(INITANGLE[0]);
myservo2.write(INITANGLE[1]);
myservo3.write(INITANGLE[2]);
myservo4.write(INITANGLE[3]);
currentAngle[0]=INITANGLE[0];
currentAngle[1]=INITANGLE[1];
currentAngle[2]=INITANGLE[2];
currentAngle[3]=INITANGLE[3];
if(ps2x.ButtonPressed(PSB_CIRCLE))
{
Serial.println("Circle just
pressed");
openGripper();
}
if(ps2x.NewButtonState(PSB_CROSS)) {
Serial.println("X just changed");
ps2x.read_gamepad(true, vibrate);
}
if(ps2x.ButtonPressed(PSB_SQUARE))
{
Serial.println("Square just
released");
closeGripper() ;
}
if(ps2x.Button(PSB_L1) || ps2x.Button(PSB_R1)) {
Serial.print("Stick Values:");
Serial.print(ps2x.Analog(PSS_LY), DEC);
//Left stick, Y axis. Other options: LX, RY, RX
Serial.print(",");
Serial.print(ps2x.Analog(PSS_LX), DEC);
Serial.print(",");
Serial.print(ps2x.Analog(PSS_RY), DEC);
Serial.print(",");
Serial.println(ps2x.Analog(PSS_RX),
DEC);
}
value[0] = ps2x.Analog(PSS_LX);
value[1] = ps2x.Analog(PSS_RY);
value[2] = ps2x.Analog(PSS_LY);
value[3] = ps2x.Analog(PSS_RX);
for (int i = 0; i < SERVOS; i++)
{
if (value[i] > 130)
{
if (currentAngle[i] < MAX[i])
currentAngle[i]+=1;
switch(i)
{
case 0:
myservo1.write(currentAngle[i]);break;
case 1:
myservo2.write(currentAngle[i]);break;
case 2:
myservo3.write(currentAngle[i]);break;
case 3:
myservo4.write(currentAngle[i]);break;
}
}
else if (value[i] < 120)
{
if (currentAngle[i] > MIN[i])
currentAngle[i]-=1;
switch(i)
{
case 0:
myservo1.write(currentAngle[i]);break;
case 1:
myservo2.write(currentAngle[i]);break;
case 2:
myservo3.write(currentAngle[i]);break;
case 3:
myservo4.write(currentAngle[i]);break;
}
}
}
//the code for arm
Next week aim is to solve the problem and may change the method
if necessary, for example give LED light feedback or buzzer feedback.
Comments
Post a Comment