20 Playing soccer (software)
Share
Congratulations!
This is the last step of the tutorial. Now you will embark on your Soccer Robotics journey. Your goal is to make the best soccer robot possible (and maybe even win some competitions along the way).
This might be daunting, but I have made some objectives that you can work towards below. It will require a lot of thinking, failing, and trying different things so feel free to rewatch previous steps to remember how to do things.
Also make sure to talk to others when you get stuck or want to strategize. If you don't have anyone around you that could help, ask on the robomov discord or even contact me:
ogata-at-berkeley.edu
saying you finished the zircon tutorial and are stuck figuring out the next steps or stuck on a specific problem. Im happy to help!
With that in mind, here is the objective:
Now we have learned everything we need to make a soccer playing robot. Combine the compass sensor code to correct the direction of the robot, the line sensor code to stay within bounds, and the ball sensor code to go towards the ball in step 18 to get a soccer playing robot. (hint: to make the robot go around the ball, you could go diagonally instead of straight. Also a more advanced robot would use all its sensors and not even have to rotate to find the ball!). Dont worry if all this is overwhelming. The crucial point is to start with one basic program doing a basic thing, then adding another feature, then adding another.
My recommendation is as follows:
1. Make the robot stay in the field. Do this by making the robot go away from the line when it detects it (so if the robot detects a line from the front sensor, make it go back and so on for the other two line sensors as well).
2. Modify the line avoidance program to go forwards if the robot sees a ball while making staying in bounds a priority (if you place the ball out of bounds, the robot should stay in bounds while trying to get the ball)
3. Modify this program to make the robot turn in place to find the ball when it doesn't detect any lines or balls.
4. Use the compass sensor to go around the ball when facing your own goal, but go towards the ball when facing your opponents
Below is a very basic fusion of the compass and ball sensors to play soccer!
Try it out on your robot, and then think about how you could improve it.
Some ideas:
- read the line sensor and react to a line detection (remember you can do readLine(1) > 400 for example to detect a line. Also the exact number you use might be different depending on your exact field so make sure to measure the sensor value of the green and white lines like in the step 14 line sensors tutorial) to not go out of bounds
- tune the numbers in the if statements so that the robot sees the ball from further away
- make the robot use all 8 ball sensors instead of just 1
- make the robot not miss the ball (maybe slow down as you get close to the ball or get close to facing the right direction)
MAKE SURE TO CREATE A CASE FOR THE BATTERY and a handle for your robot. Having the battery dangle around can fry your robot and lead to fire hazards.
Again, you are not alone. This is hard stuff!
Even the best teams in the world struggle to keep their robots in the field and score.
If you feel stuck, make sure to talk to others. They are all happy to help. Or even ask me :)