Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Moving autonomous programs to teleop (http://www.chiefdelphi.com/forums/showthread.php?t=112210)

jhellr13 27-01-2013 21:44

Moving autonomous programs to teleop
 
I am looking for some help with automating some tasks in teleop by using code from autonomous.

For example, lets say I have an autonomous mode where the first while loop is to drive straight using encoders for a certain distance, then move to another loop where the robot turns in a circle using the encoders, and then moves to a while loop where the motors are stopped.

Now lets say that I want to use that code during teleop if i press a button. Do I just copy the code from autonomous and place it in a case structure attached to the button in teleop? Does it have to go in periodic tasks instead? Does each while loop have to be in a flat sequence as well?

Help please? Thanks

Greg McKaskle 27-01-2013 21:50

Re: Moving autonomous programs to teleop
 
TeleOp is designed to return to the scheduler and be called again every 20ms. If you put code there that takes longer than 20ms to run, it will cause the robot to miss joystick values. I'd recommend putting the code into Periodic tasks and using a global to cause it to start and stop when appropriate, auto or teleop.

Greg McKaskle

jhellr13 27-01-2013 21:54

Re: Moving autonomous programs to teleop
 
Quote:

Originally Posted by Greg McKaskle (Post 1223055)
TeleOp is designed to return to the scheduler and be called again every 20ms. If you put code there that takes longer than 20ms to run, it will cause the robot to miss joystick values. I'd recommend putting the code into Periodic tasks and using a global to cause it to start and stop when appropriate, auto or teleop.

Greg McKaskle

Thanks! I'll try that tomorrow. Could you elaborate on what you mean by using a global? Do you mean make a global boolean variable in teleop to check if the button is pressed, then read the global in periodic tasks and perform the action?

Greg McKaskle 28-01-2013 05:54

Re: Moving autonomous programs to teleop
 
That would work. Or make a global that is set in teleOp based on button state and other logic and Periodic reads it to determine what to do next.

Greg McKaskle


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

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