There are things I don't know...

Howdy

I tried to move drive motor control from TeleOp to PeriodicTasks, by sampling joystick data in TeleOp, pushing it to globals, then reading the globals in the periodic loops. Terrible results, laggy response, Y-axis data got around to working, X-axis virtually ignored.

With probes in place, I can see the data getting to the Arcade Drive instance, but the outputs were junk, moreson on the X-axis than the Y. I really thought a ~20mS loop shoveling data asynchronously to a 10mS loop would be no problem.

TeleOp and Autnomous VI fragments attached. Any thoughts?

TIA,
Tim

teleop1.png
Periodic1.png


teleop1.png
Periodic1.png

Why don’t you just read the joysticks directly in Periodic Tasks like you are already doing for button 1?
The Globals seem to add a completely unnecessary step.

I’d pull the Joystick Refnum outside the While loop. No reason to keep doing that over and over.

I agree with Mark that going through the globals is not necessary and not necessarily the safest way to write it, but what you have shown should also work fine.

Can you be more specific about what the variable values were? Were they junk as in they were lagging or in that they were garbled? One thing that may be handy would be to plot them on a chart on the front panel in each location. That will change the timing a bit, but will help determine what the relationship is.

My suspicion is that something else is writing to the globals in another location. Right-click and Find will help locate them.

Greg McKaskle

Thanks for the help. I have learned a few things

a) comm data from the DS is latched. This pushes more code out of TeleOp and nto PeriodicTasks, which seems like a good thing

b) The robot project remembers too much - on the Dashboard in Test mode, I saw old and new motors after I had changed the names. Blasted the build directory, old refs went away.

c) I see good axis data (after eliminating the globals) going into WPI Arcade Drive, but the wrong stuff out. I am beginning to suspect that Arcade Drive and Tank Drive cannot coexist on the same hardware connections at the same time. Tomorrows testing will probably reveal that ya cannot switch between Arcade and Tank on the fly.

I can’t tell what you are trying to do? Autonomous? regular tele-op?

I marked my comments with **.

a) comm data from the DS is latched. This pushes more code out of TeleOp and nto PeriodicTasks, which seems like a good thing

** During autonomous, joystick and cypress values are latched to retain the last value of the disabled period. Additionally, it is possible to read joystick and other data multiple times from anywhere in the program you want. To me, this doesn’t push code out of teleOp, but it does allow you to place it in Periodic.

b) The robot project remembers too much - on the Dashboard in Test mode, I saw old and new motors after I had changed the names. Blasted the build directory, old refs went away.

** SmartDashboard doesn’t have a way to delete variables, so if you were to leave it running and change the robot code to have new SD variables, it would show old and new until you restarted the dashboard. But there shouldn’t be any need to rebuild or blast.

c) I see good axis data (after eliminating the globals) going into WPI Arcade Drive, but the wrong stuff out. I am beginning to suspect that Arcade Drive and Tank Drive cannot coexist on the same hardware connections at the same time. Tomorrows testing will probably reveal that ya cannot switch between Arcade and Tank on the fly.

** I still don’t understand what was wrong in the first place. Globals are thread safe and are perfectly fine for asynchronous transfer of data provided you don’t cause your own race condition by having multiple writers that aren’t coordinated. Arcade and Tank simply perform different math on the axis before updating the motors. Plenty teams use tank for TeleOp and Arcade for Autonomous. You should be able to open a 2 or 4 motor DriveSet and use either arcade or tank on it at will. They have no effect except to update the drive motors.

Greg McKaskle

I appreciate the attention to the problem.

I was trying to set up the drive motor nanny in Periodic to be agnostic to the source of its inputs. Thus, globals set in Autonomous or Teleop, read in Periodic. There seems to be something weird about how I get to this point that messes things up.

Thanks Greg! Help from deep inside is appreciated (I finally looked you up :slight_smile:
I’m at ***

*** I am working slowly through transforming a “base arcade” project into where I ended up in trouble, testing far more often than I could before (the proto-robot is spending spring break in my living room). Today the input reads and motor control with style switching moved from Teleop to Periodic, and so far are behaving. Slightly different from the bad path (far fewer globals), but hopefully arriving at something we can use effectively next week.