Camera problems

We just added some camera code to a frc robot code that was working just fine until we added the code for the cameras it is not for anything that is to advanced it is just for basic vision processing using Microsoft life came 3000 . Hear is the are code.

#include <frc/Joystick.h>
#include <frc/PWMVictorSPX.h>
#include <frc/TimedRobot.h>
#include <frc/drive/DifferentialDrive.h>
#include <frc/Spark.h>
#include <rev/SparkMax.h>
#include
#include <cameraserver/CameraServer.h>
#include <wpi/raw_ostream.h>

class Robot : public frc::TimedRobot {
frc::Spark m_leftMotor{9};
frc::Spark m_rightMotor{8};
frc::DifferentialDrive m_robotDrive{m_leftMotor, m_rightMotor};
frc::Joystick m_stick{0};
rev::SparkMax m_intake{7};

public:
void TeleopPeriodic() {
#if defined(linux)
frc::CameraServer::GetInstance()->StartAutomaticCapture(0);
frc::CameraServer::GetInstance()->StartAutomaticCapture(1);
#else
wpi::errs() << ÔÇťVision only available on Linux.\nÔÇŁ;
wpi::errs().flush();
#endif
// Drive with arcade style
m_robotDrive.ArcadeDrive(m_stick.GetY(), m_stick.GetX());

if(m_stick.GetRawButton(.25) == true)

{
m_intake.Set(1);
}
if(m_stick.GetRawButton(2) == true)
{
m_intake.Set(-.25);
}
if(m_stick.GetRawButton(1) == false && m_stick.GetRawButton(2) == false)
{
m_intake.Set(0);
}
}
};

#ifndef RUNNING_FRC_TESTS
int main() { return frc::StartRobot(); }
#endif
and hear is all of the errors that we are getting
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐ERROR´╗┐: ioctl VIDIOC_S_PARM failed at UsbCameraImpl.cpp:840: Device or resource busy (UsbUtil.cpp:156) ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐WARNING´╗┐: USB Camera 1: could not set FPS to 30 (UsbCameraImpl.cpp ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐ ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐WARNING´╗┐: USB Camera 0: could not allocate buffers (UsbCameraImpl.cpp:556) ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐ERROR ´╗┐´╗┐ 1 ´╗┐´╗┐ ´╗┐ERROR´╗┐: Button indexes begin at 1 in WPILib for C++ and Java ´╗┐´╗┐ ´╗┐´╗┐´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐ERROR´╗┐: Button indexes begin at 1 in WPILib for C++ and Java ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐ ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐ERROR´╗┐: ioctl VIDIOC_REQBUFS failed at UsbCameraImpl.cpp:555: Device or resource busy (UsbUtil.cpp:156) ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐WARNING´╗┐: USB Camera 0: could not allocate buffers (UsbCameraImpl.cpp:556) ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐WARNING´╗┐: USB Camera 1: could not allocate buffers (UsbCameraImpl.cpp:556) ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐WARNING´╗┐: USB Camera 1: could not set format 1 res 160x120 (UsbCameraImpl.cpp:821) ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐ERROR´╗┐: ioctl VIDIOC_S_PARM failed at UsbCameraImpl.cpp:840: Device or resource busy (UsbUtil.cpp:156) ´╗┐
´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐´╗┐WARNING´╗┐: USB Camera 1: could not set FPS to 30 (UsbCameraImpl.cpp:841)
can some one help us with these problems because every thing that we have tried has not fixed the problem at all.

StartAutomaticCapture should not be in TeleopPeriodic. That means it is trying to start the capture every 20 msec. Those should only be called once, so in the init methods.

5 Likes

Was this previously working as well? GetRawButton takes an integer input to indicate which button you care about.

Keep in mind, when it comes to software, ÔÇťworkingÔÇŁ should imply ÔÇťtestedÔÇŁ.

Homework question for you to consider: Why would this produce the error about Button indexes begin at 1?

Also, FYI, you can use ``` sequences to mark sections of code for better formatting. See here for more info.

3 Likes

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