I was wondering if there was a way to simulate code and get readouts of joystick inputs ect. without connecting to the cRIO. IE a simulated robot, because when i go to run code it is asking for a response from the cRIO and I was wondering if there was a way around that. Mainly because I just want to see if my code will actually do what it is supposed to do. If you do know please post IN DETAIL as I am not 100% attune with LabView yet.
As you might expect, there are many levels at which you can simulate.
If you are wanting to run your VI and see if the basic logic is correct, you can do that sort of thing pretty easily at the subVI level. If you want WPILib to work, even just the joysticks, that is not something that is available … yet. It would be cool though.
To test a subVI, you can go to the bottom left of a window, right click on the target string next to the scrollbar, and choose to execute on the My Computer target instead. This should open a duplicate of the VI that will run locally. For simple subVIs, you can then type in numbers, run, and view the outputs. You can set breakpoints, single step, execution hilight, etc. More complicated VIs may be broken due to missing VIs, which you can disable and insert your own constants or calculated values instead. This will not simulate the entire robot, but will let you run leaf level code.
You can take this a bit further by dragging your code in the project window up to the My Computer target. Again, the WPILib and other components aren’t implemented for the PC, so you will have breakage or empty values returned, but it is useful for some things. Don’t forget to drag the VIs back to the cRIO target, and be sure not to confuse anyone by leaving them in both places.
We do this frequently to test logic. I will save a copy of the vi with PC at the end of the name, as in LineFollerPC.vi, and make changes by replacing the WPILib vi’s with indicators/controls as needed. If you do as Greg suggested and drag it up the My Computer target, it will run ok.
The LabVIEW project window has top-level entities called targets. A target is a computer or microcontroller that you write code for. The wizard-built projects for FRC have two targets, My Computer, that is of type PC, and a cRIO, that is of type PPC cRIO.
A VI can belong to one or more targets, and depending on where in the project you click to open it, you are selecting where you want it to execute.