|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Autonomous Mode
While in autonomous mode runs do TelOp and Timed Tasked also run. I would really like to be able to use are code from TelOp and Timed Tasked to do autonomous but i am not sure that would work
|
|
#2
|
|||||
|
|||||
|
Re: Autonomous Mode
I believe your timed tasks will run, but teleop will not.
|
|
#3
|
||||
|
||||
|
Re: Autonomous Mode
Quote:
![]() |
|
#4
|
||||
|
||||
|
Re: Autonomous Mode
thanks for the quick response. I was thinking that was true but wanted to double check.
|
|
#5
|
||||
|
||||
|
Re: Autonomous Mode
Just so you have an idea on what runs and when, take a look into the Main.vi. You shouldn't need to edit anything in it, but you will see that autonomous only executes once, while periodic tasks runs at startup and teleop runs 20 times a second. There is of course more to it, but it'll give you a good idea of what code and loops are running at any given time.
|
|
#6
|
||||||
|
||||||
|
Re: Autonomous Mode
What we usually do (and what I would recommend), is that you put any software that you intend to use in both teleop and auton in the periodic tasks VI. You can then pass data from auton and teleop to periodic tasks with global variables.
That may not make sense at first so I'll give an example. Let's say you have a lifting mechanism to lift the totes. You decide that it would be ideal to command your lift to a height (using presets on buttons) and use a PID to control the lift to the commanded height. At the same time, it would make sense for autonomous to command the lift to a height and use a PID to control the lift to the commanded height. Since both your autonomous strategy and your teleop strategy both rely on commanded heights and a PID, it would make sense to move your lift control code to periodic tasks so it can be shared by autonomous and teleop. You could then create a global variable called "LiftHeightCommand" that is the set point of the PID. In teleop, do your button processing to decide on the commanded lift height and assign the output of your logic to LiftHeightCommand. In autonomous, just set LiftHeightCommand directly. |
|
#7
|
|||
|
|||
|
Re: Autonomous Mode
Good advice already. I'll add just one thing.
If the code will execute quickly. If it is reading sensors and comparing to some limit, for example, you can also make that code into a subVI and call the subVI from auto, tele, and periodic too if that makes sense. If the code will wait for a mechanism to move, or time a mechanism's movement, you do not want to put it into teleOp, or it will prevent the next joystick inputs from being read on time. Greg McKaskle |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|