Thursday 17 November 2016

Computer Visioning - IPcam + Gstreamer adventure = new Camera

Intro

This started as an re-run of my Face Tracking project, but with updated software. New software list:
  • OpenCV v3.1
  • Gstreamer v1.8
  • V4l2loopback v0.8
  • On Ubuntu 16.04 - x64
But this proofed to be harder then the first time. Except for OpenCV, I used the default package repository. Also building OpenCV + Gstreamer 1.0 + V4l2 + Python + OpenGL, was easy enough. There is a lot of how to do this to find...

But then I had this problem:
(Sorry, the video the turned sideways. But from the 3 frames, One is falling behind. Very clearly...)

Things to try

Here is list of methods I used to read the IPcam stream in OpenCV

Gstreamer to Loopback
cv2.VideoCapture("v4l2src device='/dev/video1' ! videoconvert ! appsink sync=false max-buffers=2 drop=true name=sink emit-signals=true")
Gstreamer in OpenCV
cv2.VideoCapture("souphttpsrc location=http://192.168.50.107/videostream.cgi?user=admin&pwd=12345 do-timestamp=true is_live=true ! queue ! appsink")
Http directly in OpenCV
cv2.VideoCapture("http://192.168.50.107/videostream.asf?user=admin&pwd=12345&resolution=64&rate=0")
Then getting frustrated, this was another idea. As the default web interface had no delay, I tried to capture this browser frame and sending that to loopback with Gstreamer:
ximagesrc use-damage=false xid=0x3a00689 ! ffmpegcolorspace ! videoscale ! v4l2sink device='dev/video1'
+
cv2.VideoCapture(1)
But this also resulted in IOctrl failure...
Here are some v4l2loopback issue that seemed related: #97 - #93 - #83
This is the script I used for testing, this I compared to the IPcam interface.
Code Snip

Solution

So Finally I concluded that the (cheap) IPcam would not work. But I did wanted to keep the pan/tilt freedom. I could rip everything out, replace the camera and the board with an Arduino like this.
Back
Front
But my choice was to keep the original hardware, so I can POST web requests for the pan/tilt movement, upgrade the camera with the PlayStation 3 Eye, which has some impressive quality!
Main Board
Motor Wiring
The Head Taken Apart
Replaced the Camera

The PlayStation 3 Eye also has an microphone array, giving a nice extra. 





If you want to do the same, I can not stress enough to pay a lot of attention to the order of how the camera is put to gether!! As some part are to small to fit the USB port I was forced to cut the PS-Eye wire....But forgot the ring that holds the base and head together, so I had to take it all apart again!

The Result

Friday 28 October 2016

Building Robot DIY Power Supply

Goal

Having multiple off shelf devices can make some things easier. But have a car battery of 12 volt doesn't fit on all of them. Converting 12 volt to a number of required volts:
  • +5v for IP camera's and Arduino's
  • +5v positive and -5v negative for robot arm (?linkje naar project?)
  • +7,5v for network switch
  • +12v (no conversion) for motors (shoulders, feet, neck) and used for Pico PSU for secondary computer.
  • +19 for laptop power-supply (E-Bay car adapter)
The last few devices were simple, just direct (as motor uses 12 volt) or a convertor from E-bay that uses 12 volt.
The first four did pose a challenge as they did take up Ampere! A quick count came to 8 Amp!! And overload must be avoided, specially the arms could use good part. So have a 10 and 5 schema to be sure. The motors will draw directly from the batteries.

Drawing Board

First found an 10 A negative and 10 A positive schema for converting the 12 to 5 volt. Then a simple regulator (7,5 volt) schema. All thanks to CircuitOnline, a great dutch elektro website.
The positive side
To extract positive and negative, two 12 volt batteries are required. If only one battery, you can use a volt divider but this will lower the voltage.
The negative side.
But with heavy loads you will need heavy resistors! So to use two batteries, just remember that combined gives double the current! As the robot has enough space for two batteries and the battery weight will increase stability, the choice was easy.

The additional 5 Amp
5A print

The choice was to used an older PC power-supply as case. It has a fan, lots of holes and spacey.
Everything inside
Running some tests
Ready for first test!




For details on first attempt see below. But it is fine to skip that.
After First Attempt, measuring the damage...

First Attempt

All apart again!
When using the MJ2955 or MJ3055, I forgot to use mica (isolation)...Because if using the same they can share the ground (which is the body on MJ2955). But with MJ3055 this causes short circuit!
MJ3055, which was fried 
Then by accident, forgot to wire ground first...This resulted in a lot of smoke and me order the same list...again!!!



Result

So this cost some additional time, but also made me redesign and clean up wires.
In the end everything was fine. All measurements were in the green and the power-supply was good to go!
Here it is finished and close. Not yet install in the body.

Wednesday 6 January 2016

Robosapien V2 rewiring

RoboSapien V2 Wire Fix and other Mods.




Some time ago I found this old but still very cool power toy.
And as a gift I wanted for my son...and a bit for myself.
I got it second hand and this was clear, it had some cracks and heavy nicotine odor...
But it worked and was complete with manual book and no battery leaking damage.

Soon I did notice some uncontrollable movements and battery drains.
When searching the internet of any tricks, hacks and modifications I found something disappointing.
The wires running through the legs are of very bad quality, more V2 models have it!
Somehow the other wires are fine, but the leg ones are not...
A foot connector cable
Total break down!
Here are some examples of how bad they become. To the point of causing short circuit.
 We (me and son) had a clear to do, rewire the legs.

Gathering information

Lucky we were one of many that committed to this job, as is a common problem.
So first taking apart the robot is a challenge, it covers are very fragile and so both upper leg parts are lost and now looking for a 3D model replacement.
Second point is that the arms can fall off after removing the chest covers (unlike with the V1 model).
Once the covers are gone and the wires are untangled, as they cross halve way the body.
Write down how all the wires fit in to place.
All the info can be found on the internet (see references), but it saves time to already have it.
Then remove the legs from the body.

We did not have the same size cables as we used the from an old computer PSU.
They come in many colors and long size, remember not making the length to long (as they might jam once the covers are back) OR short!!
The foot board
Also we needed to recycle the plugs so had to carefully take them apart and replace them with the new wires.

Unfortunately at the foot(s) base the wires are soldered thus taking more time.


Left Foot Connector
Besides time consumption, the job did not take more than a day (thanks to my little helper!).
Right Foot Connector
Foot with still old wires
the Motor Board

Finally the wires are fixed and everything is working again.

References:

Here are a few websites that helped me or can be helpful.
  1. Very useful -> For info on the Mainboard, it also have links to other internal parts.
  2. In case you (like me) forgot to write Foot Wiring information.
  3. Java is not my thing, but I found Robosapien Java Code, might be useful.
  4. Some basic Robosapien Information.
  5. For building you own remote, the IR codes.
  6. Info for connecting external power got here.
  7. Then I found RoboCommunity but this site doesn't seem to work correct or host very useful info.  But please have a look for yourself.

Last point, some extra mods:

After the wire update I did want to have look at the possibility for an external power source.
As described on one of the reference website (#) it is possible (2 pictures)...

The Ground (GND) on Mainboard

On the left you were the GND is connected.
 
Closeup of the Ground on Mainboard
And a close up of it. This GND can be used by both the 6 & 9 volt.
6 volt (orange)

Next are the two input points for the 6 and 9 volt, remember that the 9 volt can take up some amp, I did no          measurement but have a 5 AMP hooked up.
9 volt (brown)

An upgrade on this I plan to have the battery charge when external power is connected.
However this will require some additional wires (3 extra) to the batteries.

The idea did cross my mind for having wireless charging in foot(s) but you will lose weight what can make the body unstable!




Something else I still need to look in to is to replace the IR communication between remote and robot with a RF, like with a remote car.
So there is not dependency on clear line of sight.
But I will document this upgrade on a different post.