ItR Mini Project 3: Playful Robots

We are the Champion!!!

 

 

1st Week Progress: Pushing Boxes

Building Process

Since the robot is modified from the last Escape Robots, the main structure is quite the same. For the first week, we started to design a function that can let it find its target and run towards it.

We’ve discussed what hardware we need to achieve this function. An ultrasonic sensor to detect objects and an infrared sensor to detect the line are enough. After our discussion, we decided to remove all the light sensors and add new sensors. We stick the ultrasonic sensor at the lower front of our robot since putting it in this place can minimize the influence of other objects and can adapt to all the heights of our components. Also, the fixed position can force the robot facing at the objects when it detects them. Then we put the infrared sensor beside the ultrasonic sensor. In order to put let the 

After all the installation of the hardware is done, we started to work on the logic part. In order to detect the object beside the robot, we need to rotate the ultrasonic sensor like a radar. Since we don’t want to use that many servos on the robot, the position of the sensor is fixed at the front of its body. In this case, we have to rotate the robot itself to sense the environment. When the robot can sense the object, it runs toward it and pushes it out of the circle. When the infrared sensor has detected the black lane of the circle, make the robot moves backward and rotate a certain angle to get away from the edge of the field.

We use black tape to detect the output of the infrared sensor. We found that when the sensor is on the tape, the value is about 300-400. When the sensor is on the white floor, the value is around 30-60. So we set the value at 250. Then we test the distance value. According to our test, if the distance is too short, it won’t detect the far-away object. If the distance is too long, it will detect other objects outside the circle. So we set the value of the ultrasonic sensor equal to the diameter of the circle.

Then, here comes our code:

if (lineFinder >= 250) {
    carBack(250, 250);
    delay(1000);
    carTurnRight(250, 250);
    delay(500);
  } else {
    // decide how to control the actions here
    if (distance >= 2 && distance < 80) {
      carAdvance(FULL_SPEED, FULL_SPEED);
      //delay(500);  //do not use long delays within loop, unless necessary
    } else{
      carTurnRight(250, 250);
    } 
  }

Testing

The procedure of testing is far more fluent than we thought. 

 

However,  our robot will stop accidentally. At first, we can’t figure out what’s the problem since we didn’t write stop() in our code. Then we find that when the robot is plugged in, it won’t have such a problem. At that moment, we realized that it was the problem with the batteries. After we changed a set of new batteries, the problem was solved.

2nd Week Progress: Pushing Boxes

After finishing the first week’s progress, we started to design the attacking part. According to our materials, we decided to put 2 servos in front of the robot and make the arm sweep (like a crab?).

While installing the components, some of the connection parts are too thick to screw on the servo. In this case, we used sandpaper to polish them and make them fit the servos.

After we install all the components, we need to fabricate the arm for it. At first, we intended to use 3D printing to print the arms. However, since it will take a lot of time, we decided to use the laser cut instead. We do the design on the computers in the Fab Lab(but forget to export the file), laser cut 8 wooden chips, and screwed 4 of them together as a set to make a solid arm.

 

However, after we got the chips, we found that only 2 screw holes can not make it strong enough. So we cut another 2 holes on the other side of the chip. After sticking the nails on them, the arms(or crabs) are finished.

Then we started to test the servos.

At first, we used the sample code provided in the Arduino software. These two servos ran normally can fluently.

 

When we thought that all the work was done and copied these codes into the main program, we found a big problem. The problem is that the sample code use delay() to let the servo run. However, with delay, the robot can’t move or use other sensors. In this case, we need to modify the code.

Then we came up with a solution:

 unsigned long currentMillis = millis();
  angle = currentMillis % 1400;
  if (angle<=700){
    inAngle = map(angle, 0, 700, 20, 20);
  }else{
    inAngle = map(angle, 700, 1400, 150, 150);
  }

  myservoL.write(inAngle);
  myservoR.write(180 - inAngle);

We use the millis() as a timer. When it reaches 1400ms, the angle will return to 0 and continue counting again. We’ve tried 2000ms but the servo will stop at the setting point since the period is too long. Then we tried 1000ms but the servo can’t reach the target position since the period is too short. After many tries, we set the timer at 1400ms.

Then we use map() to define the angle to make the servo can sweep. In this solution, the servo can move fluently and it won’t affect the movement of other components.

The Final Day

Just after the final day, we found another critical problem. The power of the batteries is not enough for the 4motors and 2 servos. We’ve changed some new batteries but the situation was not improved. At last, we find our instructor Rudi to get a chargeable battery that can provide more powerful electricity than AA batteries. After changing the batteries, our robot works perfectly!

 

 

 

 

 

 

 

 

 

 

 

Here comes the first competition. The result is that our robot grabbed down the opponent’s balloon but it didn’t puncture it. This makes us start to redesign the needles. We can’t adjust the angle of the needles since they have been glued to the arms. So we add an extra pair of needles on the arm which has a better angle that can puncture the balloon more easily.

 

Here comes the final competition. Since the distance value is quite short and the audiences are quite nearby, our robot didn’t find the other robot at the very beginning. After it found the opponent, it quickly aimed at it and punctured its balloon rapidly. We are all very satisfied with the performance of our robot.

Leave a Reply

Your email address will not be published. Required fields are marked *