|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Autonomous Moving Backwards
Can you guys help me with making our robot drive backwards and turn right in autonomous mode
|
|
#2
|
||||
|
||||
|
Re: Autonomous Moving Backwards
What sensors are you using? What language?
Generally it's done by creating commands to drive or turn in X direction for a set distance (via encoder) or time, then chaining those commands together in a command group. This only applies in the text languages, I'm not sure how it works in LabVIEW |
|
#3
|
||||
|
||||
|
Re: Autonomous Moving Backwards
We use java for our programming
jaruar1 is our left drive motor jaguar2 is our right drive motor |
|
#4
|
||||
|
||||
|
Re: Autonomous Moving Backwards
Quote:
There is a gyro and an accelerometer included in the Kit of Parts. The gyro is an analog sensor that detects change in angle. Mounting this on the robot parallel to the ground allows you to tell the robot to turn until it reaches 90 degrees (right.) If you do not use an encoder, gyro, or any other sensor to detect the robot position then the only alternative is a timer based autonomous. You can specify through logic (while statement for SimpleRobot & if then statement for IterativeRobot) to turn on the motors at specific times and turn it off when it shouldn't be running. Example code of how a timer based autonomous could run. In the example the robot drives backwards for 1 second, sits still for 1 second, and then turn right in place for 1 second. Code:
Timer timer = new Timer();
Jaguar leftDrive = new Jaguar(1);
Jaguar rightDrive = new Jaguar(2);
autonomousInit() {
timer.start();
timer.reset();
}
autonomousPeriodic() {
double currentTime = timer.get() * MathUtils.pow(10, -6);
if (currentTime < 2) { //if time is less than 2 seconds
leftDrive.set(-0.5); //drive left motors backwards
rightDrive.set(-0.5); //drive right motors backwards
} else if (currentTime >= 2 && currentTime < 3) { //time between 2&3 secs.
leftDrive.set(0);
rightDrive.set(0);
} else if (currentTime >= 3 && currentTime < 4) { //time between 3&4 secs.
leftDrive.set(0.5); //set left forward to turn right
rightDrive.set(-0.5); //set right backward to turn right in place
}
}
Last edited by MagiChau : 24-02-2013 at 19:59. |
|
#5
|
||||
|
||||
|
Re: Autonomous Moving Backwards
Just out of curiosity Magi, what does MathUtils.pow(10, 6) do?
|
|
#6
|
||||
|
||||
|
Re: Autonomous Moving Backwards
It raises the first parameter (10) to the second parameter (-6) power. So the result is 10^-6. I probably should use scientific notation instead. I am multiplying the time by this assuming the javadocs is correct that the timer returns the time in micro seconds.
Last edited by MagiChau : 24-02-2013 at 19:59. |
|
#7
|
||||
|
||||
|
Re: Autonomous Moving Backwards
Quote:
|
|
#8
|
||||
|
||||
|
Re: Autonomous Moving Backwards
Oops, fixed it now.
|
|
#9
|
||||
|
||||
|
Re: Autonomous Moving Backwards
Our team is not using encoders for the drive system only the shooter this year. I just want the robot to drive backwards when the first 3 shots are fired. That takes about 9 seconds i have it for and then it will switch to low gear. then i want it to just drive straight back for the rest of the autonomous period.
|
|
#10
|
||||
|
||||
|
Re: Autonomous Moving Backwards
Quote:
You could also create a commands for driving, shooting, etc. and then string them together in a command group and have them execute in-order. That would require a bit less tuning to get right, though it might take longer to initially program. |
|
#11
|
||||
|
||||
|
Re: Autonomous Moving Backwards
Be careful that you do not cross the center-of-the-field line
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|