Go Down

Topic: Cheap caterpillar robot platform restrained at custom office (Read 11615 times) previous topic - next topic


Back on getting Arduecat working, after having learned a lot on taking 90fps or higher framerate videos from Raspberry camera and process with gstreamer pipeline and/or raspiraw.

I did experiment on what a good camera position would be from a forward ground range perspective. This prototype position gave 4-90cm range:

This is normal view with light:

And this is complete darkness view, lighted only by 3W infrared LED attached to Raspberry camera, no big difference:

I created a fixed mount for the camera of Lego pieces, two being screwed to robot platform with 2 screws each. This time the visible forward range was even 4-115cm:

Next step: recabling Pi Zero and Raspberry Due -- this time servo controlling camera gradient will be controlled from Raspberry Pi Zero and not Arduino Due. Quite some space left on robot after mounting Arduino Due with motor controller at back of robot platform with just two screws.



Few days ago I did start recabling, lipo, step-down converter and Pi Zero W:

While that is not needed later for autonomous robot driving, gstreamer udp pipeline allows to stream 320x240 video with 48fps wirelessly to laptop (right click the image to see the gstreamer pipeline details).

Today I refreshed my knowledge on how to control SG90 servo motor from Raspberry. The SG90 needs 5V connected to VCC, and 3.3V from GPIO18 PWM control line is enough to control. While controlling via "gpio" commands can be done as normal user, doing PWM with wiringPi library in C requires to be run via sudo (Sys mode allowing to run as "pi" user is not fast enough for PWM). This is the code I used:
Code: [Select]
pi@raspberrypi03:~ $ cat blink.pwm.c
#include <wiringPi.h>

int main (void)
  wiringPiSetupGpio();                 // with wiringPi lib with GPIO numbering
  pinMode (18, PWM_OUTPUT);            // PWM on GPIO18
  pwmSetMode(PWM_MODE_MS);             // mark space PWM mode
  pwmSetClock(192); pwmSetRange(2000); // 50Hz

  for (;;)
    pwmWrite (18,  80); delay (1000);
    pwmWrite (18, 150); delay (1000);
  return 0;
pi@raspberrypi03:~ $

First I did test that with a separate SG90, then I cabled the SG90 on the robot:

This smartphone video (with audio) shows the running blink.pwm:

I did record a 10s 640x480@90fps video during running of blink.pwm with Raspberry camera as well:

Main reason was to measure how long it takes for the servo to move between 80 and 150 position: roughly 20 frames or 0.22s.

Next step: self calibration of camera tilt using camera and servo motor.


Automatic camera calibration works, details in this posting:

After calibration ended a single b/w frame (used in calibration) gets written to SD card:


Lately I did make huge progress in getting (5$) Raspberry v1 camera video capturing beyond 90fps, up to 750fps
(with robot moving at 5m/s target speed 90fps would give a frame only every 5.6cm):

This is still work in progress although the many commits on github already. The latest stretched 640x480_s mode at 180fps might be interesting. Because only every other line gets captured, perhaps a derived 320x240 mode with full fov will be the better choice at 180fps (a frame every 2.8cm). Or taking only every 4th row for stretched mode 320x240_s at 360fps.

Next will be work on curve feature extraction on frames taken at high framerates
(Otsu's method does not help, kernels seem promising):

The current plan is that (5$) Pi Zero will analyze the frame, determine length, slope and x-offset of first staight line segment of curve, whether starting curve will go left/right and its curvature, ... and send only this small amount of data over to the Arduino Due on the back of caterpillar robot. That will then feed this information into Arduino playground PIDLibrary for doing high speed line following motor control.


Go Up