Two Cameras and switching

I am sorry for posting another two camera post, but we are close to figuring out what we want to accomplish, however, we hit a snag translating the ideas put forth on other posts here and on wpilib to python.

We have cameras working on our robot currently, but want to be able to use our joystick to switch between the two on the robot before sending the signal out.

We have the example working.

from cscore import CameraServer

def main():
    cs1 = CameraServer.getInstance()
    cs2 = CameraServer.getInstance()

    usb1 = cs1.startAutomaticCapture(dev=0)
    usb2 = cs2.startAutomaticCapture(dev=1)


This is run from our file using…


The issue is, we are confused as to how to limit the output stream to one camera, and in which file ( or
to implement the chooser.

server = frc::CameraServer::GetInstance()->GetServer();

does not seem to be implemented in robotpy (at least not in the same way).

As you’ve noticed, this is difficult in RobotPy because cscore stuff resides in a different process (

The easiest way to deal with this is to have your joystick code to set a value in NetworkTables, and then have your vision code use a NetworkTables callback to change it when signaled.

1 Like

Thank you,
That makes sense. How do I create only one output stream to the dashboard? With the above code, we set two streams. How do we enable both cameras, but create only one output stream (I think we can figure out how to then use the network tables to switch between the two cameras)?

On a totally unrelated note, we are also working on using a Pigeon IMU. Is there a way to disable the test for sim when we build and push our code? We are relying on the py -3 test to validate our code. I know we should wrap Pigeon (and rev) code in conditional statements to ensure stability and usability in the simulator, but in order to keep our code as streamlined as possible, we may skip it.

Thanks again for developing this. We would not have as many student developers on the team without Python support. It is incredible.

Sorry, missed that part of your question. I added an example earlier in the season:

There is a --skip-tests option for deploy. I’ve been meaning to implement some minimal pigeon support… which APIs are you missing? Comment on and maybe I’ll do that tomorrow.

1 Like

That seemed to work (at least in the simulator). I will test on a Rio tomorrow.

I saw that you pushed a new commit to a new Pigeon branch of the CTRE library. I do not mind testing it, but how would we go about installing the branch? I assume we would need to compile it correct?

The simulator doesn’t actually test vision code.

To run the branch I pushed, you would need to build it, correct (but not compile it). I’ll probably push a release later today, I generally try to keep PR’s open for a period of time in case there are any code review related comments.

1 Like

While I know the simulator does not check vision code (especially in Windows), it does test the network tables piece, and though the addresses will change, I was able to verify that the camera stream would switch with a button press.

Thank you. The recent update allows us to use sim again without commenting out our gyro. So, with those changes, is it possible to add a Pigeon to our If so, any advice as to how to add it?

I added it to the documentation when I made the changes :slight_smile:

1 Like

Thanks, I cannot believe I missed it. By the way, it works perfectly.

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