Saturday, October 19, 2013

Cross compiling is a go... maybe

So I have gotten openCV code to be cross compiled. When I run the file command against the testArchitecture executable it is recognized as an ARM program. So how did I do it?
Alright well I left my BBB alone for about a week and just decided to think on it. Than I decided to follow these instructions AGAIN but this time in the ~ directory to hopefully give it a clean location. Also I decided to be intelligent I did not run make install seeing as installing ARM files on my intel machine will obviously cause bad things. Well openCV was made this time, and with the BBB links that I had earlier I went onto eclipse and most of the errors were gone. Sadly there were still one or two left.

There was this error saying "ld: cannot find /lib/pthread.so" which I promptly googled and found this forum post explaining how to fix it. The error came up for one or two more files but the exact same solution applied in all cases. It appeared to be some really weird issue with how things like pthread were installed / initally compiled. It seems like they have the simlink going to the wrong directory.

Anyway after fixing those last few bugs the program was working... HOORAY. But, when ran on the BBB we still got a seg fault... so close. This time is different though, the warnings that derek molloy mentioned before "VIDIOC_QUERYMENU: Invalid argument" gets spit out. That means that at least to some extent openCV is running on the BBB. That means cross compiling is actually working! So where is the seg fault at? After placing a lot of couts in the code I finally found the line that was causing the seg fault.
Moments moment = moments((cv::Mat)contours[index]);
 So this is where I am at. I'm not really sure why but it appears that maybe the Moments class was not ported to ARM for my compiler. So while most of it is in ARM this is either using Intel architecture or is just completely lacking, either way the compiler should pick this up but is not.

My current plan of attack on this is to try finding a new way to identify the center of contours not using Moments but this is doubtful seeing as this is the purpose. I found the openCV documented way to use contours and well it uses Moments and here is the link. Or the much more likely (painful way) to solve the problem is to assume that the BBB did not copy over the libraries pertaining to the Moments class. That means we should look through the includes and libs I have on Ubuntu to try and see if any pertaining to openCV that should be ARM but are instead Intel. Than we copy over the needed ones from the BBB and maybe all is well.

On a different note I have recognized a needed change for my control mechanisms. Currently I have linerally related x location to turning and area to speed. This is not a good idea. Instead I have designed a integral relationship for the speed and a cubic relationship for the direction. This should be much smoother and even be able to handle things such as changes in speed and sharp turns. Unlike the linear relationship which would likely create a death oscillation once it initially gets off desired. By death oscillation I mean, oh I'm off by -1, fix, now I'm off by 2, fix, off by -5 etc etc until the car is forced to stop from the heartbeat or a serious accident. I have not written code for this design yet but I have basic psedo code laid out and will hopefully make the needed changes in the coming days, priority stays on fixing openCV though.

I will hopefully be posing a video of the car driving in the coming few days. I ordered an incorrect part initially and so I tried to get one from hobbyworks locally but apparently the bullet connectors are an online connector only... Anyway I ordered the part it's coming from Switzerland will hopefully be here in the next few days. Than I can finally drive this car and really see what I'm dealing with.

As always I will keep you posted when something interesting happens. The progress is slow but it's steady.
Also I suggest anyone interested in these subjects read this link. It's an interesting concept and makes me want to pick up a PIC32 for my next project.

No comments:

Post a Comment