Ezward / Esp32CameraRover2

EzRover is a framework for building and programming inexpensive differential drive robots. The framework includes closed loop speed control, pose estimation and go to goal behavior. Behaviors can be added in JavaScript. The first hardware instantiation uses an ESP32cam, an L9110S DC Motor Driver and a cheap Robot Car chassis.
MIT License
35 stars 7 forks source link

Make camera support optional #4

Closed Ezward closed 3 years ago

Ezward commented 3 years ago

The code can be downloaded onto a normal ESP32 board, but it will crash when it attempts to initialize the camera. It would be a nice feature to be able to build without camera support so the basic rover can run on an ESP32.

Ezward commented 3 years ago

I did part one of this; the c++ code now uses the preprocessor symbol ENABLE_CAMERA to enable camera support. It is defined in platformio.ini by default, so camera is enabled by default. Remove that line from platformio.ini and you should be able to download to a normal ESP32. You may want to pick a different board type in platformio.ini rather than esp32cam.

Note that if you are using a regular ESP32, you will probably have enough pins to support both the wheel encoders and the serial port. You may need a minor code change to make that work; I believe there are one or two places that will define SERIAL_DISABLE if USE_WHEEL_ENCODERS is defined; you would want to make those two symbols orthogonal.

This commit only addresses the C++ code. The Web camera UI will still be present, but non-functional. A later commit will hide the camera ui if the camera is not enabled.

Ezward commented 3 years ago

@cgrrty When you get a chance, please pull the latest code and let me know if this fix works on the esp32. I found a bug in the esp32cam if we turn off the camera; the encoder interrupts to not work. This can be compensated for if we also undefine USE_ENCODER_INTERRUPTS, then the encoder pins will be polled and this makes speed control and pose estimation continue to work. I don't think that will be necessary on a normal esp32; please let me know when you get a chance. Then I can close this bug.

PS: latest code hides the camera UI if the camera is disabled.

Ezward commented 3 years ago

@cgrrty Have you been able to build and run the code on an ESP32 yet?

cgrrty commented 3 years ago

Hi Ezward After trying, the compilation can be passed, and it can be run. 20210214202735 20210214202820

Ezward commented 3 years ago

Closing as done. Thanks.