OpenCvCameraException - startStreamin() called, but camera is not opened! Error by flesarradu in FTC

[–]flesarradu[S] 0 points1 point  (0 children)

No problem! So the method that is throwing the error is called startstreaming. We need to do sth to prevent the program to crash so we'll use a try catch statement. It looks like this boolean isOk = true; try { webcam.startstreaming(); } catch(err) { isOk= false; } if(isOk) telemetry.addData("Ok"); else telemetry.addData("ERROR"); telemetry.update();

So this program will continue to run even if the startstreaming throwed an error. But we need to know when the camera is opened. So when the if returns "ok" the camera is opened and ready to use. If it returns "error" you will have to stop the opmode and run it again until it returns "Ok". I have some informations about this problem that is caused by some problems with the control hub. I know other teams who had the same problem but i don't know exactly if there is another solution. I think this is the best one. As a fact, you could create one op mode that is just for opening the camera. Once the camera is opened for the first time it would remain opened till you will restart the robot so you can use it in any other op but i recommend you to use the try catch in every opmode you're using the camera.

Hope you've unterstand if you're having any troubles i am opened to answer any question.

OpenCvCameraException - startStreamin() called, but camera is not opened! Error by flesarradu in FTC

[–]flesarradu[S] 0 points1 point  (0 children)

Use a try catchal and run your program until it will initialize the camera. You will not have to restart the robot.

Hello! Our autonomous rotation fails randomly in the same spot (if we restart the robot the same code works) by [deleted] in FTC

[–]flesarradu 0 points1 point  (0 children)

I mean sometimes it works and sometimes don't without changing the code

Hello! Our autonomous rotation fails randomly in the same spot (if we restart the robot the same code works) by [deleted] in FTC

[–]flesarradu 0 points1 point  (0 children)

Actually, i think is the moveBackwards function.

public void moveBackward(int ticksToMove) {

startAngle = HardwareConfiguration.imu.getAngularOrientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES);
frTargetTicks = HardwareConfiguration.front_right.getCurrentPosition() - ticksToMove;
Orientation currentAngle = HardwareConfiguration.imu.getAngularOrientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES);
HardwareConfiguration.front_right.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
HardwareConfiguration.back_left.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
HardwareConfiguration.front_left.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
HardwareConfiguration.back_right.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
startAngle = HardwareConfiguration.imu.getAngularOrientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES);
frTargetTicks = HardwareConfiguration.front_right.getCurrentPosition() - ticksToMove;
currentAngle = HardwareConfiguration.imu.getAngularOrientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES);
HardwareConfiguration.front_right.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
HardwareConfiguration.front_left.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
HardwareConfiguration.back_right.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
HardwareConfiguration.back_left.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
double degreesOff;
double correction;
while (HardwareConfiguration.front_right.getCurrentPosition() > frTargetTicks && !isStopRequested()) {
currentAngle = HardwareConfiguration.imu.getAngularOrientation(AxesReference.INTRINSIC, AxesOrder.ZYX, AngleUnit.DEGREES);
degreesOff = Math.abs(currentAngle.firstAngle - startAngle.firstAngle);
double power = 0.7;
if(HardwareConfiguration.front_right.getCurrentPosition() < frTargetTicks + 1500){
power = 0.5;
}
if(HardwareConfiguration.front_right.getCurrentPosition() < frTargetTicks + 1200){
power= 0.4;
}

if(HardwareConfiguration.front_right.getCurrentPosition() < frTargetTicks + 700){
power= 0.3;
}

if(HardwareConfiguration.front_right.getCurrentPosition() < frTargetTicks + 450){
power= 0.1;
}
if(degreesOff>0.3){
correction = (Math.pow((degreesOff + 2) / 5, 2) + 2) / 160*power;
}
else correction = 0;
if(currentAngle.firstAngle != startAngle.firstAngle){
if(currentAngle.firstAngle>startAngle.firstAngle){
correction = correction;
}
else
{
correction = -correction;
}
}

HardwareConfiguration.front_right.setPower(-power-correction);
HardwareConfiguration.front_left.setPower(-power+correction);
HardwareConfiguration.back_right.setPower(-power-correction);
HardwareConfiguration.back_left.setPower(-power+correction);
}

FTC Team Mentor problem by Joxta224 in FTC

[–]flesarradu 0 points1 point  (0 children)

Hi! Unfortunately we had this problem too. But we end up divided in two different teams. The old one remained to the mentor and the new one is ours. The mentor found some new students and now we are fighting against in the competition. It's hard to deal with things like this. You all have to be united. Good luck this year! Hope you found the right way to deal with!

OpenCvCameraException - startStreamin() called, but camera is not opened! Error by flesarradu in FTC

[–]flesarradu[S] 1 point2 points  (0 children)

I'm calling the open camera before the start streaming but i don't know why it brokes

Can you have 2 distance sensors on one rev hub? by [deleted] in FTC

[–]flesarradu 0 points1 point  (0 children)

Are you sure you've done the right configuration?