|
THS
|
Robots /
Blind Robot Brigade -- CompetitionTasksMotion and LocationIn order to create semi-random motion for the robot, the following code was utilized: radius = (abs(radius) < MAXRAD) ? radius + (random() % RADFACT) : -radius + RADFACT; cr8_drive(SPEED, radius); With the initial radius set to zero, this code will give the robot an increasingly positive radius, adding a random number between 0 and RADFACT (12 in this case) until it reaches MAXRAD (800 in this case). It will then shift it over to a large negative radius, which will begin to decrease by a random amount each time until it reaches zero, at which point the cycle will begin again. ![]() To detect balls that are further away, the robot uses a long range (8-80 cm) distance sensor with linearized values. The robot compares the value of the sensor to its value in the last cycle, looking for any sudden changes (5 cm or more in one cycle). An example can be seen in the image to the right. If a ball is found using this method, the robot will head straight forward until it either sees a ball with its close range sensor or three seconds elapses. The three second limit is added to ensure the robot doesn't accidentally follow a ghost reading.
CaptureTo determine if the robot has captured a ball, the robot uses the short range (3-40 cm) distance sensor. The raw values are used, which give the robot a greater sensitivity at shorter distances. If a value greater than 300 is detected, the robot activates the servo motor to drop the arm and hopefully capture the ball. After dropping the arm, the robot rotates to hopefully push any unwilling balls into the arm's center section. The robot then uses the long range distance sensor to determine if a ball is actually in the cage -- a raw reading of 180 or more indicates that the ball is in the cage. Determine Ball ColorAfter capturing a ball, the next step is to determine if the ball is the correct color. it is possible to determine the color of the ball using a photo-resistor. The blue and yellow balls have different readings from the sensor. A function is used that reads the status of a digital switch in order to determine which color we want to keep, and which we throw away. If that function determines that the ball is the opponent's, the robot turns 90 degrees and pushes it away. If it is our team's ball, we try to deliver it to the goal. DeliveryTo deliver the ball to the goal, the code first calls the |