Created
March 18, 2011 12:37
-
-
Save jschoolcraft/875988 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Robot-C is supported. Just FYI | |
| Has something called Task Control, up to 4 concurrent tasks, with priority... | |
| could do something like: | |
| StartTask(RaiseBasket, 10) | |
| StartTask(MoveToWallGoal, 10) | |
| To move to the goal and make sure the basket is Raised | |
| RaiseBasket | |
| while(limitSensor != 1) // it hasn't been touched | |
| keep raising the basket | |
| // this will have you start in a more controlled fashion | |
| ControlledAcceleration(desiredTicks) | |
| while(tickCount < desiredTicks) | |
| for(int i = 1; i <= 4; i++) | |
| // let's set power to 1/4, 2/4, 3/4, 4/4 of full power | |
| motorPower = (desiredFullPower / 4) * i; | |
| motor[port2] =motorPower; | |
| motor[port3] =motorPower; | |
| wait1Msec(1000); // do that for 1 sec, then loop | |
| // or get more complicated and factor in ticks | |
| // could get to a point where wait 1 second | |
| // moves you to far | |
| ControlledDeceleration(desiredTicks) | |
| while(tickCount < desiredTicks) | |
| for(int i = 0; i < 4; i++) | |
| // let's set power to 3/4, 2/4, 1/4, 0/4 of full power | |
| motorPower = (desiredFullPower / 4) * (3 - i); | |
| motor[port2] =motorPower; | |
| motor[port3] =motorPower; | |
| wait1Msec(1000); // do that for 1 sec, then loop | |
| // or get more complicated and factor in ticks | |
| // could get to a point where wait 1 second | |
| // moves you to far | |
| Move(desiredTicks) | |
| while(tickCount < desiredTicks) | |
| motor[port2] = full power; | |
| motor[port3] = full power; | |
| wait1Msec(1000); | |
| // moveRangePercents = [15, 70, 15] | |
| MoveForward(desiredTicks) | |
| if (currentTicks <= desiredTicks * 0.15) | |
| ControlledAcceleration(desiredTicks * 0.15) | |
| if (currentTicks > desiredTicks * 0.15 && currentTicks < desiredTicks * 0.70) | |
| Move(desiredTicks * 0.70) | |
| if (currentTicks >= desiredTicks * 0.70) | |
| ControlledDeceleration(desiredTicks * 0.15) | |
| To factor in ticks & time you likely need to figure out how many ticks you can travel for some time period. | |
| It's just an exercise in measurement... | |
| setTickCounter = 0; | |
| moveTimeInMS = 5000; | |
| motor[port2] = 127/4 * 1; | |
| motor[port3] = 127/4 * 1; | |
| wait1Msec(moveTimeInMS); | |
| tickCount/moveTimeInMS == ticks/ms @ 1/4 power | |
| just do the above for 127/4 * 1, 2, 3, 4 to get 1/4, 2/4, 3/4, 4/4 power measurements | |
| then you'll know how far (in ticks) you go at a given speed | |
| you can compare how far you have remaining, and adjust wait times during | |
| acceleration and deceleration |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment