Making up for the lack of posts in a while, there will be a stream of updates to the variety of projects I'm currently working. In this post, the focus will be on VEX.
The past few weeks for VEX was focused on assisting the other teams with their individual robots to prep them for the Hong Kong competition that is happening right now. Most of the work done is completely rebuilding the base utilizing the aluminum structure kits. Also adding a drive train to boost the speed up, a ratio of around 1.5:1 is used. Furthermore, the lift is completely redesigned to utilize a distorted parallelogram that scores into the high goal at the back whilst scoring the low goals in the front. This lift design is original in the sense that it builds upon the extremely common double-parallelogram so common in 2012 VEX Gateway competition. Pics will ensue as soon as I start taking them.
Helping the other team is mostly with the coding part, for example implementing the level based arm code which brings the arm to predetermined angles. The code I made is extremely flexible as in you can input any angle that you want the arm to go to and the arm will obey those commands. Source code will be at the bottom of the post.
Now that these two teams are off in their competitions, now it is the time to start preparing for the World Championships in April 2012. We have decided to construct from ground up with reliability in focus this time. Due to the fact that our last competition, our lift failed when it didn't back in Taiwan. Furthermore we have decided to add more unique systems which I cannot reveal at this time due to security reasons. Pics will follow after time.
Here is the source code of those two functions:
1: void lift(int target) //function to bring the arm to a certain degree, auto corrects itself so is always within 5 degrees of target.
2: {
3: actual = SensorValue[angle]; //integer to store the angle of the arm, uses a variable for debugging purposes
4: if(actual < target && target) //while the current angle of the arm is less than the target angle, also if target != to 2020
5: //since this statements provides a counterforce, we don't want a counter force at the very bottom, thus this doesn't execute if its going to the bottom
6: {
7: while(actual < target && abs(target - actual) > 50 && vexRT[Btn8D] == 0 && vexRT[Btn8DXmtr2] == 0) //while the current is less than the target, as well as it exceed the threshold, (allows us to break the loop)
8: {
9: setArmMotors(127); //moves the arm up
10: actual = SensorValue[angle]; //keeps re-writing the current angle of the arm
11: StartTask(drive);
12: StartTask(conveyor_belt);
13: }
14: if(vexRT[Btn8D] == 1) //if the break button was pressed, sets the preset to 0 (2020)
15: lift_cycle = 0;
16:
17: setArmMotors(10);
18: }
19: else if(actual > target && abs(target - actual) > 50 && target != 2020) //however if the current angle is greater than the target, exceeds threshold, and is not equal to 2020
20: {
21: while(actual > target && abs(target - actual) > 50 && vexRT[Btn8D] == 0 && vexRT[Btn8DXmtr2] == 0) //runs a while loop
22: {
23: setArmMotors(-100);
24: actual = SensorValue[angle]; //re-writes the current angle of the arm
25: StartTask(drive);
26: StartTask(conveyor_belt);
27: }
28: if(vexRT[Btn8D] == 1) //if the break button was pressed
29: lift_cycle = 0; //set the lift_cycle to preset 0, ground level
30: if(target == 2020)
31: setArmMotors(0);
32: else
33: setArmMotors(10);
34: }
35: }
36:
37: void arm() //function in charge of managing the arm presets
38: {
39: if(lift_cycle == -1) //ensures that the preset can never go below zero
40: lift_cycle = 0;
41: if(vexRT[Btn8D] == 1 || vexRT[Btn8DXmtr2] == 1) //a break button that goes directly to ground level
42: lift_cycle = 0;
43: if(vexRT[Btn6U] == 1 || vexRT[Btn6UXmtr2] == 1) //switches thru the presets
44: {
45: lift_cycle++; //adds one to the lift_cycle
46: if(lift_cycle == 4) //ensures it doesn't go over three
47: lift_cycle = 0;
48: }
49: if(vexRT[Btn6D] == 1 || vexRT[Btn6DXmtr2] == 1) //switches thru the presets
50: lift_cycle--; //subtracts
51:
52: switch(lift_cycle) //switches the lift cycle to call different levels
53: {
54: case 0: //ground level
55: lift(2020); //default zone
56: break;
57:
58: case 1: //low goals
59: lift(2650);
60: break;
61:
62: case 2: //medium goals
63: lift(3000);
64: break;
65:
66: case 3: //talls goals
67: lift(3500);
68: break;
69: }
70: }
No comments:
Post a Comment