Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Autonomous Time Delay (http://www.chiefdelphi.com/forums/showthread.php?t=144061)

abilash123 02-17-2016 09:30 PM

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?

em202020 02-17-2016 10:42 PM

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?

Mark McLeod 02-17-2016 10:52 PM

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.

cgmv123 02-17-2016 11:44 PM

Re: Autonomous Time Delay
 
Time.delay(3) should be Timer.delay(3.0)

Yaseen 02-18-2016 11:44 AM

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:

addSequential(new AutoDrive(1.0,1.0), 3.0); 


SuperBK 02-18-2016 03:52 PM

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);

abilash123 02-18-2016 09:47 PM

Re: Autonomous Time Delay
 
Thanks disabling safety fixed it :D


All times are GMT -5. The time now is 08:02 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi