ESP32 CAM for FPV and RC

VladTheImpaler
Posts: 16
Joined: Fri Jul 05, 2019 4:35 am

ESP32 CAM for FPV and RC

Postby VladTheImpaler » Fri Jul 05, 2019 4:39 am

Tracked vehicle sending video stream and controlling motors via http:
Image

Project:
https://github.com/PepeTheFroggie/ESP32CAM_RCTANK

User avatar
HermannSW
Posts: 89
Joined: Fri Oct 27, 2017 6:58 am
Location: Eberbach, Germany
Contact:

Re: ESP32 CAM for FPV and RC

Postby HermannSW » Sat Jul 20, 2019 2:54 pm

Nice project.

I have three of the left type 20$ caterpillar robot platforms, the displayed one in state as received.
Plan was to add ESP32-CAM with (big) lipo and try your project for RC and FPV:
Image

Recently I received a 7$ toy line following tank, and it even can follow 15mm thick black lines although datasheet says 4-10mm. It did weigh 39.9g inclusive 4 LR44 batteries:
https://www.aliexpress.com/item/32841858244.html

Today I did remove gun turret and battery shield, weight dropped to 34.8g and line following still worked (see below). I realized that the 65mm×40mm top view would allow the 40mm long ESP32-CAM module as well. I added the module and a small 150mAh lipo, and caterpillar robot luckily followed the line. For above photo I did remove the 4 LR44 batteries, and was surprised that total weight 39.2g is still less than the starting weight.

The idea is to remove the line following electronics as well, but keep the motor drivers, and use ESP32-CAM to control the platform. This will be a really tiny (65mm×40mm×60mm L×W×H) RC+FPV platform based on your ESP32CAM_RCTANK github repo 👍

https://www.youtube.com/watch?v=dEJWOhJ ... e=youtu.be
Image

VladTheImpaler
Posts: 16
Joined: Fri Jul 05, 2019 4:35 am

Re: ESP32 CAM for FPV and RC

Postby VladTheImpaler » Sat Jul 20, 2019 4:32 pm

Very intresting idea.
Keep us updated pls.

--------------------------------------------

Better code for tracked vehicle motor control, smooth transition for proportional turning at any speed. Your robot will net it.
https://www.youtube.com/watch?v=uahyMLQUDqo

Code: Select all

    //gas (speed) is 0 to +1000 forward, o to -1000 reverse 
    //dir (direction) is -500 to +500
    
    rmot = gas+dir; // -1500 to +1500
    lmot = gas-dir; // -1500 to +1500

    if (rmot > 10)
    {
      motorA1 = constrain(+rmot / 4, 0, 255); 
      motorA2 = 0;
    }
    else if (rmot < -10)
    {
      motorA1 = 0;
      motorA2 = constrain(-rmot / 4, 0, 255);
    }
    else 
    {
      motorA1 = 0;
      motorA2 = 0;
    }
    
    if (lmot > 10)
    {
      motorB1 = constrain(+lmot / 4, 0, 255); 
      motorB2 = 0;
    }
    else if (lmot < -10)
    {
      motorB1 = 0;
      motorB2 = constrain(-lmot / 4, 0, 255); 
    }
    else
    {
      motorB1 = 0;
      motorB2 = 0;
    }
    
    writeMotors();

VladTheImpaler
Posts: 16
Joined: Fri Jul 05, 2019 4:35 am

Re: ESP32 CAM for FPV and RC

Postby VladTheImpaler » Sun Jul 21, 2019 2:19 pm

@HermannSW where did you buy the fast thing?

Testing grayscale 160x120 brightness values. The idea is to detect a line with the esp32 cam and have the vehicle following it.
Here the brightness of the line in-between the 2 grey lines (scanline) is displayed.
Clipboard01.jpg
Clipboard01.jpg (47.59 KiB) Viewed 391 times
What is a clever way of calculating where the black spot is?

Small update:
running 3 correletors for 4,8,16 pixel wide black lines in-between the 2 grey lines. Here the 8 pix correletor reult:
Clipboard02.jpg
Clipboard02.jpg (57.11 KiB) Viewed 362 times
Source attached.
Attachments
ESP32CAM_LINE.zip
(2.71 MiB) Downloaded 10 times

User avatar
HermannSW
Posts: 89
Joined: Fri Oct 27, 2017 6:58 am
Location: Eberbach, Germany
Contact:

Re: ESP32 CAM for FPV and RC

Postby HermannSW » Mon Jul 22, 2019 12:41 pm

VladTheImpaler wrote:
Sun Jul 21, 2019 2:19 pm
@HermannSW where did you buy the fast thing?
22$ with free shipping at aliexpress:
https://www.aliexpress.com/wholesale?Se ... aterpillar

It looks fast, especially if doing U-turn at full speed by just changing direction of one motor but keep its speed:
Image


I don't know why you have this range of lines you are searching in. And I don't know why you take greyscale image. Anyway your correlators seem to do what is needed.

I will use Raspberry camera for this, because they provide for 90fps/180fps 640x480 frames for v1/v2 camera and raspivid[yuv]. And with my high speed raspiraw work I can get 640xH frames at up to 665fps/1007fps. Raspiraw gives raw Bayer data, and I will take lower left green pixel for each 2x2 area, resulting in 320x240 grey8 frame.

I place the camera high above the robot platform in order to see range of 4cm-105cm in front of robot:
Image

I do grey8->b&w conversion of frame first, then the line is big connected component of pixel neighborhood graph that can be found by breadth first search. 1m before robot is "near" future, that will hopefully allow the robot to start high speed U-turns as described in time.

P.S:
Why high framerate captures for robot control?
Because my target platform is not the 2.5m/s caterpillar robot just pointed to, but a T101, with 330rpm motors replaced by 1500rpm motors. With caterpillar wheel diameter of 65mm that robot will do 5m/s (18km/h), and with 90fps a frame will be captured only every 5.6cm, which might not allow fast enough control.

Who is online

Users browsing this forum: Bing [Bot] and 8 guests