/*
* The MIT License
*
* Copyright (c) 2008-2009 MIT 6.270 Robotics Competition
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include <joyos.h>
#include <lib/pid.h>
#include "competition.h"
#include <lib/geartrain.h>
/*NOTES
Motor controls
-255 = full reverse
0 = no power
+255 = full foward
even speed right = 160
left = 200
Gyro
Center = 0
CW Rotation = -THETA
CCW Rotationion = +THETA
Encoders
450 ticks = 1 wheel rotation
tested values
kp = 6.5
ki = 4.5
kd = 0
*/
uint8_t team_number[2] = {23,0};
// usetup is called during the calibration period. It must return before the
// period ends.
int usetup (void)
{
//set_auto_halt(0);
setup_gyro();
return 0;
}
int umain(void)
{
/*
Scores the two red balls on the side closest and then get the flag box
*/
printf("\nBETA"); //Prints "ZETA" on LCD screen, and waits for the go button
//go_click(); //to be clicked
char pos = find_pos();
printf(" %c", pos);
pause(300);
if(pos == 0x52) //Not n, e, s, or w
{
printf("\nERROR POSITION");
beep(260.0, 1000);
}
orient_gyro(pos);
backup_till_stall(1);
drive_straight_gyro_PID(33.65, 0.0);
turn_encoder_PID(-90.0);
printf("\nNOM NOM more!");
ball_collect();
drive_straight_gyro_PID(115, -90);
ball_score();
drive_straight_gyro_PID(20, -135);
jerk_fb(12);
pause(2000);
ball_hold();
drive_straight_rev_encoder_PID(20);
turn_encoder_PID(135);
ball_score();
drive_straight_gyro_PID(130, 0);
drive_straight_gyro_PID(60, 90);
ball_hold();
turn_encoder_PID(-90.0);
drive_straight_gyro_PID(30, 0);
motor_set_vel(FlagMotor, 255);
drive_straight_rev_encoder_PID(83);
return 0;
}