I have had the dubious pleasure of working with the CMUCam2 and making it useful for my team's purposes. I've mostly managed to succeed, and now the camera follows the green target just fine. However, there appears to be a problem with initializing the camera. The problem is not with the actual initializing, since it does work, but there is a delay of several seconds. During this delay, the drive motors, connected on PWMs 1 and 2, begin spinning in opposite directions. They will continue to run until I shut the FRC off or turn Disable on. This happens whether it's in OI or Autonomous mode. I should note that this is not an issue with the camera not being connected (explained here
) since I do eventually talk to the camera, but rather an issue during initialization.
I went ahead and put the camera into debug mode (articulated here
) and noticed that during the delay in which the camera is initializing, the camera shows an exchange like this:
This is how it goes for several seconds until it finally starts exchanging real data. Even when it starts exchanging real data, sometimes it will do so without ever receiving any ACKs from the camera (the same as the issue here
) and the control loop will just hang once it gets to the camera Capture function (a known issue
). Resetting the FRC usually fixes the problem, though.
Through some careful debugging I discovered that the drive motors started acting crazy only once the InitCamera() function was called. This explains why they act crazy in either Competition State, since InitCamera() is in the Initialize block. At first I suspected that perhaps there was something weirdly hardcoded about PWMs 1 and 2 that made the code expect those to be the camera servo outputs (I have them on 3 and 4, not directly on the camera board, and they work fine), but switching the drive motors to other PWMs (I tried 6 and 7 *without* changing the OI code to reflect the change) seems to have no effect; they go crazy still. I noticed the servos themselves don't seem to be affected, though. Is it possible that there is a wiring issue with the Victor 884s that is causing the drive motors to be uniquely affected? The driving functions appear to be functioning perfectly normally once the motors stop spinning out of control.
Obviously this issue is a showstopper for the camera. The random spinning at initialization throws the robot into an unknown state and makes autonomous programming for the competition 1000 times more difficult. I noticed that moving the InitCamera() function into the Autonomous block makes the issue go away for OI mode while still allowing for camera function, but it doesn't fix the problem with the motors in Autonomous mode. I'm hoping that the issue merely amounts to ignorance on my part and that someone else out there has had the same issue and knows the solution. Thanks.