darwinop / webots-cross-compilation

porting behavioral settings from a webots darwin onto a real darwin
www.robotsource.org
5 stars 9 forks source link

Webots (Darwin-OP) and OPENCV #239

Open david781 opened 11 years ago

david781 commented 11 years ago

I want to integrate opencv and webots for extracting and processing images acquired from Darwin-OP camera. I need help regarding this issue.

david781 commented 11 years ago

I have tried to integrate it in Visual Studio 2010 as mentioned in the manual but it is giving lots of errors.

fabienrohrer commented 11 years ago

Hi David,

About OpenCV, you need to get and install the library, and then modify the Makefile (or the VS project) to link the controller with OpenCV. Finally, the camera values have to be sent to OpenCV. I'm unfortunately not expert in OpenCV, and I can't explain you how to do that.

About VS, I think that the doc is quite well done. Probably the issue you encounter, and which is not explained in the documentation, is that the DARwIn-OP controllers are linked with internal libraries (managers.dll for example). You have probably to deal with this.

Sending us the error messages would be helpful.

Sincerely, Fabien

fabienrohrer commented 11 years ago

Note that OpenCV is released in Webots inside the Aldebaran-Nao package: resources/projects/robots/nao/aldebaran/naoqi-runtime/lib/

Even no need to install it ^^

david781 commented 11 years ago

Regading Integration between VS10 and WEBOTS.

I am receiving following errors

Error 2 error LNK2019: unresolved external symbol "public: void thiscall Robot::Walking::LoadINISettings(class minIni *)" (?LoadINISettings@Walking@Robot@@QAEXPAVminIni@@@Z) referenced in function "public: thiscall managers::DARwInOPGaitManager::DARwInOPGaitManager(class webots::Robot ,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (??0DARwInOPGaitManager@managers@@QAE@PAVRobot@webots@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPGaitManager.obj Error 3 error LNK2001: unresolved external symbol "private: static class Robot::Walking * Robot::Walking::m_UniqueInstance" (?m_UniqueInstance@Walking@Robot@@0PAV12@A) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPGaitManager.obj Error 4 error LNK2019: unresolved external symbol "public: bool __thiscall Robot::Walking::IsRunning(void)" (?IsRunning@Walking@Robot@@QAE_NXZ) referenced in function "public: void thiscall managers::DARwInOPGaitManager::stop(void)" (?stop@DARwInOPGaitManager@managers@@QAEXXZ) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPGaitManager.obj Error 5 error LNK2019: unresolved external symbol "public: void thiscall Robot::Walking::Stop(void)" (?Stop@Walking@Robot@@QAEXXZ) referenced in function "public: void thiscall managers::DARwInOPGaitManager::stop(void)" (?stop@DARwInOPGaitManager@managers@@QAEXXZ) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPGaitManager.obj Error 6 error LNK2019: unresolved external symbol "public: void thiscall Robot::Walking::Start(void)" (?Start@Walking@Robot@@QAEXXZ) referenced in function "public: void thiscall managers::DARwInOPGaitManager::start(void)" (?start@DARwInOPGaitManager@managers@@QAEXXZ) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPGaitManager.obj Error 7 error LNK2019: unresolved external symbol "public: bool thiscall Robot::Action::LoadFile(char )" (?LoadFile@Action@Robot@@QAE_NPAD@Z) referenced in function "public: thiscall managers::DARwInOPMotionManager::DARwInOPMotionManager(class webots::Robot *)" (??0DARwInOPMotionManager@managers@@QAE@PAVRobot@webots@@@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPMotionManager.obj Error 8 error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits,class std::allocator > const & cdecl managers::DARwInOPDirectoryManager::getDataDirectory(void)" (?getDataDirectory@DARwInOPDirectoryManager@managers@@SAABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: thiscall managers::DARwInOPMotionManager::DARwInOPMotionManager(class webots::Robot )" (??0DARwInOPMotionManager@managers@@QAE@PAVRobot@webots@@@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPMotionManager.obj Error 9 error LNK2001: unresolved external symbol "private: static class Robot::Action \ Robot::Action::m_UniqueInstance" (?m_UniqueInstance@Action@Robot@@0PAV12@A) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPMotionManager.obj Error 10 error LNK2019: unresolved external symbol "public: void thiscall Robot::Action::Stop(void)" (?Stop@Action@Robot@@QAEXXZ) referenced in function "public: virtual thiscall managers::DARwInOPMotionManager::~DARwInOPMotionManager(void)" (??1DARwInOPMotionManager@managers@@UAE@XZ) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPMotionManager.obj Error 11 error LNK2019: unresolved external symbol "public: bool thiscall Robot::Action::IsRunning(void)" (?IsRunning@Action@Robot@@QAE_NXZ) referenced in function "public: virtual thiscall managers::DARwInOPMotionManager::~DARwInOPMotionManager(void)" (??1DARwInOPMotionManager@managers@@UAE@XZ) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPMotionManager.obj Error 12 error LNK2019: unresolved external symbol "public: bool thiscall Robot::Action::LoadPage(int,struct Robot::Action::PAGE )" (?LoadPage@Action@Robot@@QAE_NHPAUPAGE@12@@Z) referenced in function "public: void __thiscall managers::DARwInOPMotionManager::playPage(int,bool)" (?playPage@DARwInOPMotionManager@managers@@QAEXH_N@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\DARwInOPMotionManager.obj Error 13 error LNK2019: unresolved external symbol "public: thiscall managers::DARwInOPVisionManager::DARwInOPVisionManager(int,int,int,int,int,int,int,int)" (??0DARwInOPVisionManager@managers@@QAE@HHHHHHHH@Z) referenced in function "public: thiscall webots::VisualTracking::VisualTracking(void)" (??0VisualTracking@webots@@QAE@XZ) J:\VCwebots\controllers\visua_tracking\visua_tracking\VisualTracking.obj Error 14 error LNK2019: unresolved external symbol "public: bool __thiscall managers::DARwInOPVisionManager::getBallCenter(double &,double &,unsigned char const )" (?getBallCenter@DARwInOPVisionManager@managers@@QAE_NAAN0PBE@Z) referenced in function "public: void thiscall webots::VisualTracking::run(void)" (?run@VisualTracking@webots@@QAEXXZ) J:\VCwebots\controllers\visua_tracking\visua_tracking\VisualTracking.obj Error 15 error LNK2019: unresolved external symbol "public: void thiscall Robot::MotionManager::SetJointDisable(int)" (?SetJointDisable@MotionManager@Robot@@QAEXH@Z) referenced in function "public: void thiscall Robot::JointData::SetEnable(int,bool,bool)" (?SetEnable@JointData@Robot@@QAEXH_N0@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\JointData.obj Error 16 error LNK2001: unresolved external symbol "private: static class Robot::MotionManager * Robot::MotionManager::m_UniqueInstance" (?m_UniqueInstance@MotionManager@Robot@@0PAV12@A) J:\VCwebots\controllers\visua_tracking\visua_tracking\JointData.obj Error 17 error LNK2019: unresolved external symbol _ini_getd referenced in function "public: double thiscall minIni::getd(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &,double)const " (?getd@minIni@@QBENABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0N@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\ColorFinder.obj Error 18 error LNK2019: unresolved external symbol _ini_getl referenced in function "public: long thiscall minIni::getl(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &,long)const " (?getl@minIni@@QBEJABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0J@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\ColorFinder.obj Error 19 error LNK2019: unresolved external symbol _ini_putd referenced in function "public: bool __thiscall minIni::put(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &,double)const " (?put@minIni@@QBE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0N@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\ColorFinder.obj Error 20 error LNK2019: unresolved external symbol _ini_putl referenced in function "public: bool thiscall minIni::put(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &,int)const " (?put@minIni@@QBE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0H@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\ColorFinder.obj Error 21 error LNK2019: unresolved external symbol "public: static void cdecl Robot::ImgProcess::Dilation(class Robot::Image *)" (?Dilation@ImgProcess@Robot@@SAXPAVImage@2@@Z) referenced in function "public: class Robot::Point2D & thiscall Robot::ColorFinder::GetPosition(class Robot::Image )" (?GetPosition@ColorFinder@Robot@@QAEAAVPoint2D@2@PAVImage@2@@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\ColorFinder.obj Error 22 error LNK2019: unresolved external symbol "public: static void __cdecl Robot::ImgProcess::Erosion(class Robot::Image )" (?Erosion@ImgProcess@Robot@@SAXPAVImage@2@@Z) referenced in function "public: class Robot::Point2D & __thiscall Robot::ColorFinder::GetPosition(class Robot::Image *)" (?GetPosition@ColorFinder@Robot@@QAEAAVPoint2D@2@PAVImage@2@@Z) J:\VCwebots\controllers\visua_tracking\visua_tracking\ColorFinder.obj Error 23 error LNK1120: 21 unresolved externals J:\VCwebots\controllers\visua_tracking\Debug\visua_tracking.exe

david781 commented 11 years ago

I have used the demo code of "visual tracking" present in webots

fabienrohrer commented 11 years ago

Hi David,

This is a linking error.

Let's take only the first line: unresolved external symbol "public: void __thiscall Robot::Walking::LoadINISettings(class minIni *)"

This function is defined in the Robotis framework: WEBOTS/resources/projects/robots/darwin-op/libraries/darwin/darwin/Framework/include/Walking.h

So this means that the Robotis shared library (WEBOTS/resources/projects/robots/darwin-op/libraries/darwin/darwin.dll) is not linked with your project.

Sincerely, Fabien Rohrer

david781 commented 11 years ago

Hi,

I have tried to link the "darwin.dll" file to the VC++ code but was unable to do so. Can you guide me how to link this process. Now I am only trying to integrate webots and darwin-op in VC++.

Regards, David.

david781 commented 11 years ago

Now the error is:

VisualTracking.obj : error LNK2019: unresolved external symbol "public: thiscall managers::DARwInOPVisionManager::DARwInOPVisionManager(int,int,int,int,int,int,int,int)" (??0DARwInOPVisionManager@managers@@QAE@HHHHHHHH@Z) referenced in function "public: thiscall webots::VisualTracking::VisualTracking(void)" (??0VisualTracking@webots@@QAE@XZ) 1>VisualTracking.obj : error LNK2019: unresolved external symbol "public: bool __thiscall managers::DARwInOPVisionManager::getBallCenter(double &,double &,unsigned char const *)" (?getBallCenter@DARwInOPVisionManager@managers@@QAE_NAAN0PBE@Z) referenced in function "public: void __thiscall webots::VisualTracking::run(void)" (?run@VisualTracking@webots@@QAEXXZ) 1>darwin-VS.exe : fatal error LNK1120: 2 unresolved externals

omichel commented 11 years ago

darwin.dll is a C++ library generated from gcc. Therefore it won't link / integrate with Visual C++. You should either:

1) use gcc 2) recompile darwin.dll with Visual C++

-Olivier

fabienrohrer commented 11 years ago

Please refer to http://www.cyberbotics.com/forum?message=2293 and please, next time, use only one thread :-)

nelson308 commented 11 years ago

I experienced the same thing as david781. there's 2 unresolved externals.. i'm using "visual tracking" demo code... is there any solution?

arasalt commented 10 years ago

Hello Fabien and Oliver, I experienced the same thing as david781, nelson, there's 2 unresolved externals... I have tried to recompile the dll file into lib file, after including the darwin.lib there occurred a lots of errors. Some of them referring to the libraries of Linux. But this libraries are not included in windows system with VS. Is there any solution? Does anyone succeeded in the following issue? If yes, please, share your solutions.

darwinop commented 10 years ago

Hi everyone I've experienced a similar situation not too long ago. On my Windows PC I upgraded the Msys from 4.6 to 4.8 and it solved the problem. Maybe Msys is a much better alternative than VS (my opinion).

arasalt commented 10 years ago

Hello darwinop, Would you please tell more details about your configurations and which installers you have been using? I tried to use x86_64-w64-mingw32 and it failed, as well as standard mingw library: Here are some errors which it gave me: ../VisualTracking.cpp:25: undefined reference to webots::Robot::Robot()' ../VisualTracking.cpp:27: undefined reference towebots::Robot::getBasicTimeStep() const' ../VisualTracking.cpp:29: undefined reference to `webots::Robot::getLED(std::string const&)' and etc further more of undefined references,

This was my build command: g++ "-LC:\Program Files (x86)\Webots\resources\projects\robots\darwin-op\libraries\darwin" "-LC:\Program Files (x86)\Webots\lib" "-LC:\Program Files (x86)\Webots\resources\projects\robots\darwin-op\libraries\managers" -o NewCotroller.exe main.o VisualTracking.o -ldarwin -lController -lmanagers

Thank you in advance!

darwinop commented 10 years ago

hi arasalt I originally had MinGW 4.6.2 and it was a simple matter of letting it update automatically. I wished I remembered the settings because I am now experiencing some issues

Recently my Windows PC crashed and I needed to do factory reset so naturally I had to reinstall MinGW. After recovery I have been experiencing the errors similar you have posted.

By the way are you getting some "Error 127"?

arasalt commented 10 years ago

No, I am not. What it tells you? I wish someone could explain those errors. I am being stacked at this problem for almost for a week... Have tried many different ways. My initial purpose was to combine Darwin-op with opencv either through VS or mingw.

darwinop commented 10 years ago

Hi arasalt I will keep working on this error but progress may be slower than you wished. I got other things going on that are of higher priority. If there is anything that may be of help I will post it here.

omichel commented 10 years ago

Hi,

Actually Webots comes with the right version of mingw in its Webots/mingw folder. This MinGW binary package includes a 32 bit MinGW-builds (gcc 4.8.0, dwarf exception handing, posix threading) toolchain. Sources are available from the MinGW-builds project or from download.qt-project.org. You need this one to be able to recompile the DARwIn-OP controller programs.

darwinop commented 10 years ago

I was able to recompile the the darwin.dll and managers.dll libraries in Windows. maybe this method can help.

I was very fortunate I was able to find an earlier installation file of MinGW (can provide upon request). this one is much simpler than the newer installation method. 1) I installed older MinGW "offilne" method. 2) Ran newer version of MinGW. 3) simply updated the packages

PLease let me know if this helps.

darwinop commented 10 years ago

@ arasalt

Please look at my previous post. In reference to Dr. Olivier's comments about expection handling and posix I think these are optional and can be installed with the newer installation file of MinGW.

omichel commented 10 years ago

You can download the mingw we use in Webots from here: http://download.qt-project.org/development_releases/prebuilt/mingw_32/x32-4.8.0-release-posix-dwarf-rev2.7z This one was used to successfully compile the DARwIn-OP libraries on Windows.

arasalt commented 10 years ago

Thank you everyone! Yesterday I finally successfully compiled the visual_tracking controller of the darwin with the latest MinGW from their main site! I have build my controller on Eclipse with the latest CDT plugin for C++ developers http://www.eclipse.org/cdt/downloads.php. I created a new Makefile project from existing source so that it was able to compile it with exiting references, if anyone wants to add any libraries he has to change the Makefile and reload the project again. However I had a problem with switching my new controller with on existing world, the Webots tells me that I don't have permission for that. Which of the webots version should be purchased in order to do that task. Would Webots edu be enough?

darwinop commented 10 years ago

hi arasalt

Its best if you copy your world outside of WEBOTS_HOME (i.s. inside My Documents). Remember that WEBOTS_HOME is: C:\Program Files\Webots (win32) C:\Program Files (x86)\Webots (win64) /Applications/webots (mac) /usr/bin/webots (linux)

is your robot a "Robot" or "Supervisor"? Please refer to the Webots guide if your robot is indeed a "Robot" then the EDU license is enough. A "Supervisor" will require a PRO license. DARWIN-OP model is under Robot so it should not be an issue.

omichel commented 10 years ago

Yes, I can confirm that Webots EDU is enough to fully program the simulated DARwIn-OP robot model (and possibly modify it).