Help Programming Autonomous Independent VI

Hello! I have been tasked with programming our team’s robot for Rapid React, and I am completely new to LabVIEW. Unfortunately, no one on our team has previous experience with FRC because everyone who did has already graduated. Instead of copying the previous year’s code (which placed all robot drive code in Teleoperated.vi), I decided to try follow some advice I saw online and code almost the entire thing in Periodic Tasks.vi. I definitely bit off more than I can chew, but the drive controls work perfectly and they do everything I wanted them to do. For whatever reason, I can’t seem to figure out Autonomous. I attempted to copy the code from last year, but it did not work (I suspect it is because I used Periodic Tasks.vi). I then tried to experiment using Flat Sequences, but only the drive motors work. The ball shooter turns on for a split second, which is obviously not what I want it to do. Here is the code I made using a Flat Sequence Structure:

1 Like

Could you show us your periodic tasks vi?

Yes, here it is.

I added some notes for myself and also to make the learning process a bit easier for the next programmer. I realize they make the code look messy but for now that is what I am working with.

It looks like whatever values you set in Autonomous will immediately get overwritten by your value sets in Periodic Tasks. In that top loop.

The problem is you need to set values taken from the joysticks only in Teleop.vi, because that’s when the joysticks are active.
During Autonomous the joystick values are not passed through from the Driver Station and are always zero, and you want the values set during Autonomous to be the only place values are being set.

Summary:

  • Set the actuator (motors/pneumatics/servos) values you want to be active during Teleop in Teleop.vi (pretty much the contents of the top loop-not the loop itself though.)
  • Set the actuator values you want active during Autonomous in Autonomous Independent.vi
  • Have Periodic Tasks.vi operate only on the values already in your global variables, like you do in your second and third loops. Don’t set or change actuator values in there.
1 Like

Ah, okay. That makes a lot of sense, but I did not know how to get around that. I will definitely give this a try. Thanks!

I have a question though. After I move the contents of that loop to Teleop.vi, those joystick values will no longer be written to Robot Global Data when Autonomous is enabled, correct? Does that mean that I need to Index the values again inside of Autonomous, or should I simply use the Set Motor Output functions instead of a flat sequence, like this:

Autonomous Independent.vi and Teleop.vi never run at the same time.
i.e., when the robot is in Autonomous mode

  • Autonomous Independent.vi is running
  • Teleop.vi is not running

When the robot is in Teleop mode it’s the reverse with Autonomous Independent.vi killed, and Teleop.vi doing all the work.

Your Auto as you had it in your first post in the flat sequence should work.

You do NOT want to directly set any motor outputs in Autonomous, because they are already being set in Periodic Tasks.vi.
The same problem will occur with Autonomous setting the motor output and immediately being clobbered by Periodic Tasks resetting the same motor.

Only set any motor one place in your code to avoid conflicts like that.

Directly setting motors in Autonomous Independent.vi will only work if you also only set the motors in Teleop.vi, because Autonomous Independent.vi and Teleop.vi never run at the same time to clobber each other.
Once you moved the motor sets into Periodic Tasks (runs all the time in all modes) you can’t set motors anywhere else.

Thank you so much! I haven’t tested it out yet but I am very confident that it will work. I will test it out later and see if it works. Thanks again for your help.

Edit: It worked perfectly. Thanks again!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.