Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   How to program autonomous (http://www.chiefdelphi.com/forums/showthread.php?t=142783)

icar 01-29-2016 04:11 PM

How to program autonomous
 
Hello
What is a good and efficient way to program a time based autonomous program in an iterative robot base class? More specifically, could anyone show me what an example code would look like if I for example wanted to make my tankdrive, four motor robot, drive forward for two seconds and then turn for one second and then stop?
Any help would be greatly appreciated.

rich2202 01-29-2016 04:31 PM

Re: How to program autonomous
 
Read about the Timer Class.

Set a timer when you start your motors.
Each loop (autonomous periodic), check the timer.
When you reach the desired time mark, do something.

FYI: You might also want to put encoders on your motors, and check the distance (revolutions) the encoders say you went.


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

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