Esp32CameraRover2 icon indicating copy to clipboard operation
Esp32CameraRover2 copied to clipboard

Speed control is broken on Esp32Cam if ENABLE_CAMERA is not defined

Open Ezward opened this issue 4 years ago • 1 comments

There was a previous commit that create a new preprocessor symbol, ENABLE_CAMERA, that must be defined for the camera support to be fully compiled into the rover's C++ code. By default this is defined in platformio.ini. When it is not defined, the camera api is turned into function that just return failure, exception for getCameraPropertiesJson() which is the method underlying the status/ endpoint. When camera is enabled, it return all the camera properties and an enabled property with value of "true". When camera is disabled, it only returns enabled with value of "false". So that's the context. The bug is that if ENABLE_CAMERA is not defined, then speed control does NOT work. The issue seems to be the interrupts are not firing, so the encoder never counts any ticks. This is likely because the camera internals may turn on interrupts, but if we don't initialize it, they never get turned on.

  • One way to confirm this is to disable the camera AND encoder interrupts; to do this, comment out these two lines in platformio.ini;
    -D USE_ENCODER_INTERRUPTS=1
    -D ENABLE_CAMERA=1
  • This will then make the rover C++ code using polling to read the encoder; this is not very accurate, but if it works it would prove the issue is with interrupts.
  • If it is interrupts, then we probably have to make a call to enable interrupts ourselves.

Ezward avatar Feb 07 '21 00:02 Ezward

I did the experiment where I disabled the camera and used polling for the encoder ticks. If found a bug in the code related t polling and once that was fixed, the code again worked. So we can correctly read the pins, but we are not getting interrupts from the pins. So it does seem to be an interrupt issue.

Ezward avatar Feb 07 '21 00:02 Ezward