There are many points to be gaining in the autonomous period.
The first program is a a simple drive forward program for two to three seconds and stop. The second program is more advanced and uses the TensorFlow blocks to detect the gold mineral. These are simple general purpose programs that can be used from either lander position.
The idea is start parked under the lander and to simply drive through the sample field and stop at the crater’s edge. There’s a 1 in 3 chance that the gold mineral will be in the centre position and you’ll score 25 points. Likely that fails, but you can still score 10 points for parking on the crater’s edge.
Talk to your alliance partner, if they have a better autonomous program for the sample field on the crater side, then you can start facing your depot and drive through that sample field instead.
Here’s an image of Blocks program to do that. Click on it for the full size image.
The program was copied from the Block sample program for teleop driving, you can start with that or an empty op mode. The program starts by setting one of the drive motors to run in reverse since the motors are mounted on opposite sides of the robot. That would run when you pressed the init button on the driver station. The program then waits for the start button on the drive station to be pressed.
This program assumes you do not have encoder wires attached to your motors. In that case we can drive based on time. We initialize an Elapsed Time variable called Timer and use that to drive until we reach 2750 milliseconds (or 2.75 seconds). So inside the opModeIsActive loop we test the Timer variable and apply power to the drive motors if we Timer hasn’t reached 2750. Once it does reach 2750 we stop the motors.
Drive towards crater:
Drive towards depot:
The power level and the 2750 elapsed time figure were chosen by testing the robot. We didn’t want the robot to try and drive over the crater wall since this robot has trouble doing that and often gets stuck on the crater or the blocks inside the crater. So the robot moves gently up to the mineral and pushes it up to the crater and hopefully stops with a wheel or edge of the robot over the outside edge of the crater which is all you need to be IN the crater.
This program could be modified to drop a team marker in the depot. Simply drive a bit further, then if the robot had a servo, after driving forward, the server could be activated to release or drop the team marker into the depot and earn 15 points, and a possible 25 from the sample field.
Driving could be made more accurate by using motor encoders. Then you can set Run to Position for the motor and have it use the encoder to stop after a certain number of rotations. That should be more accurate than time based driving.
This program is a little more complicated, but more reliable at scoring the sample field. It’s based on the Rover Ruckus Tensor Flow blocks example program, with the BlockAutoDrive code for driving.
This robot is using a web cam, use the camera based TensorFlow initialization block if you’re using the camera on the phone. The Tensor Flow blocks indicate the number of detected objects (such as gold or silver minerals). When it detects three objects it attempts to determine where the gold mineral is located. The program also sets the power levels for the motors and the run time for the motors, which will attempt to drive towards that gold mineral. The power levels and time to run were based on testing the robot and adjusting the power level and times.
This program will fail to run if it can’t locate three objects. Sometimes the camera can’t see all three objects, I had to press Init on the program and the Tensor Flow block would show a screen image of what the camera could see, then use that to line up the robot so it could see all three minerals. Furthermore, off field objects can also interfere with the Tensor Flow object detection, a yellow/gold banner on the wall was actually detected as an object in my testing and had to be removed for the program to work. The program could be modified so that if it can’t find 3 minerals after a few second have elapsed, it should just drive forward and hope to randomly score the gold mineral and end up in the crater.