Toggle between two cameras

Hello -

I’ve written two Axis M1011 cameras into our code. We’ve deleted the Kinect Skeleton tab and replaced it with a Camera 2 tab which houses our visual display.

Now, from my understanding, we cannot use the mouse during the competition, so how can I make a button on a joystick switch between camera tabs?


What rule do you read as saying that?

If you still want to use a joystick button, it is possible to switch tabs in LabVIEW under program control. Right-click the tab control in the block diagram and choose Create -> Property Node -> Value. Change it from a read to a write, and now you have a way for the program to choose the visible tab.

You can send a “which tab to display” value in the Dashboard data from the Robot, and have your custom Dashboard use that value to decide which tab to show.

Ah, thanks. I’ve managed to create a “Value” block, however I have no clue how to tell it what I want to do…any assistance?

EDIT - I’ve changed it from read to write. Now, how do I give it input? (Joystick buttons, for example)

Any help?

You can certainly use the mouse to switch tabs, and it requires no programming. You may want to change the font to be much larger so that it is easier to hit.

If you want to have another way to switch the tabs, you just program it in. First can you describe how you want to switch – keys, etc?

Greg McKaskle

While the keyboard/mouse shortcuts are viable options, I was hoping to streamline the process by opening a joystick and using a button. That way the shooter has quick access to both camera feeds…

I’m gonna go ahead and as a relevant question as well - is there a way to get the joystick values to the dashboard without travelling to the robot and back? Reasons being the obvious delay introduced, as well as the waste of resources (however tiny). We could have used it last year, and this year I’m also thinking of a control system utilizing it. In both cases, the delay of going through the robot makes it useless.

DominickC - if you’ve found the correct property node input to control the active tab, and want to use a joystick button to control it, then what you need to do is, first, make sure you have the joystick value in the cluster you’re sending to the dashboard from the cRIO. Then, you can simply use this value in the dashboard project and connect it to the property node to switch the tab. :slight_smile:

Here’s what I’ve come up with.

Within teleop, I’ve opened a reference to Joystick 3, and wired the output of button 1 to my bundle. (Pretend I flattened it to a string before it went to the bundle, I realized I left that part out). I then sent it to the Driver’s Station.

Within the Driver’s Station, I’ve unbundled it. Now, where do I wire the output to?



I’ve just wired the value of the joystick being unflattened to the value Vision, which created an orange wire. Will this work for me?

Probably not. Instead, right-click the Value input and create a constant to it. Create another copy of this constant, and then make sure that each one is set to the tab you want. Then, you can use use the Select function (or case structure, or any other way you want) to choose between the constants.

Hope this helps!

Ah, NOW I get it! Thanks Alan, Greg and NeatNit!

I have never tried to open a joystick connection in multiple apps using DirectInput, which is what the DS uses.

I’m leaving town in an hour, so I’ll describe it and I look forward to hearing the results.

In the LV dashboard project code, try using the Connectivity>>Input Device functions to open a joystick and read back the buttons. Please note that these VIs aren’t quite as flexible as the stuff used for the DS, so once you open a connection, it is not possible to reposition the USB port of the joystick until the DLL leaves memory. This shouldn’t be an issue except during development when it causes head-scratching.

Greg McKaskle

Hey i found this intresting i just programmed a second camera in and got it within the tabs, Dominick, can you please show me how you programmed in the toggle between the two cameras. With pictures please :confused: help please and THANK YOU. Pm me if you can

I’m going to run with the assumption that you’ve got a second camera running in an additional “Camera” tab.

First, you’ll need to pass a boolean from a joystick or some other input to the DS. This is done via “High Priority User Data”.

Then, on the block diagram, right click on each of your “Viewer” icons, then navigate to Create>>Property Node>>Value. You’ll have to change each of these property nodes to write by right clicking on them.

Take the boolean you received and create a case structure. In the true case, wire the “Camera Image” enum to the first viewer property node. In the false case, wire the remaining enum to the second viewer property node.



Thanks for your help! :slight_smile:

I actually tried that back during the competition season when I needed to halt vision output while the robot had the shooter spun up, when I did it, I got a slew of errors. The first of which was the lack of an ‘lvinput.dll’ (or similar, can’t remember what it was beyond that it was accompanied by an error code). At the time, I attributed this to two pieces of software wanting the same hardware, and a slightly foggy mentor (who was recovering from a head injury) agreed. We scrapped it and reworked the dashboard to have a key binding that could toggle vision on and off.

I would say that the easiest would be to get some kind of proxy driver that would let you make two software joysticks out of one software joystick, but that’s me. I am firing up labview now, and I will give it a try using this method again.