|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Autonomous Time Delay
Ok so im trying to figure out how to get an autonomous for work. I tried to get the robot to drive forward with the code below:
drive.tankDrive(1.0,1.0); Time.delay(3); drive.tankDrive(0.0,0.0); When i run the autonomous the robot just jerks forwards quickly and sometimes it won't even give a response. I tried changing the number in the time delay but it made no difference. Any ideas? |
|
#2
|
|||
|
|||
|
Re: Autonomous Time Delay
What code is in the Time.delay function? Through my quick 10 second look, there is no Time.delay() function is Java...
Could it be doing time in milliseconds? |
|
#3
|
|||||
|
|||||
|
Re: Autonomous Time Delay
It might be due to a motor safety if you are using one and it hasn't been Disabled.
That will shutdown the motors during time delays longer than about .1 seconds. |
|
#4
|
||||
|
||||
|
Re: Autonomous Time Delay
Time.delay(3) should be Timer.delay(3.0)
|
|
#5
|
|||
|
|||
|
Re: Autonomous Time Delay
I'd recommend using a CommandGroup and using its timeout function.
Let's say you have a command for AutoDriving called AutoDrive that takes parameters for left and right speeds. In the CommandGroup, you'd write something like this: PHP Code:
|
|
#6
|
||||
|
||||
|
Re: Autonomous Time Delay
You can also use Wait(). For example, Wait(2.0) to wait 2 seconds. Like Mark said, you need to disable safety, or the motors wont run.
myRobot.SetSafetyEnabled(false); |
|
#7
|
|||
|
|||
|
Re: Autonomous Time Delay
Thanks disabling safety fixed it
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|