Welcome, Guest. Please Login.
Surveyor Corporation Surveyor SRV-1
Home Help Search Login

Surveyor Robotics Forum

Welcome to the user support forum for Surveyor SRV-1 robots, SRV-1 robot controllers and SVS stereo vision systems. To register for this forum, please send an email to support@surveyor.com which includes your desired forum user name, your registration email address, and a brief explanation of why you wish to join, and we will create a forum account for you.

Please note that there is a Search button in the forum toolbar for forum topics. Another effective search method for the entire surveyor.com site is to use Google, e.g. "xyz site://www.surveyor.com" where "xyz" is the search topic.



Pages: 1 2 
Send Topic Print
SDL-based stereo console (Read 15179 times)
admin
YaBB Administrator
*****




Posts: 3676
SDL-based stereo console
09/26/08 at 1:46pm
 
Starting with Mosalam's SRV_SLAM.cpp SDL console, as discussed here -  
 
    http://www.surveyor.com/cgi-bin/yabb2/YaBB.pl?num=1221211446
 
I created a stereo version of the console and converted it to C -
 
    http://www.surveyor.com/stereo/stereo.c
 
For those who haven't built this before, you need SDL, SDL_image and SDL_net.
    http://www.libsdl.org/download-1.2.php
    http://www.libsdl.org/projects/SDL_image/
    http://www.libsdl.org/projects/SDL_net/  
 
Here's my compile string for Mac OS/X -
 
gcc -g -O2 -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE  -Wl,-framework -Wl,Cocoa -Wl,-bind_at_load  -L/usr/local/lib -lSDLmain -lSDL -lSDL_net -lSDL_image -o stereo stereo.c
 
For Linux, I used -
 
gcc -g -O2 -I/usr/include/SDL -L/usr/lib -lSDLmain -lSDL -lSDL_net -lSDL_image -o stereo stereo.c
 
I haven't built a Windows version yet.
 
The console works well except for one problem - it locks up pretty easily on reading the an image through the network, never returning from the SDLNET_TCP_Recv() call (line #161 or #168).  For whatever reason, it runs a lot longer from gdb.  
 
I would like to find a way to query the socket first to see if there is data - that might solve the problem.  Anyhow, I'm open to suggestion.
 
Back to top
 
« Last Edit: 09/26/08 at 1:54pm by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
hesham
YaBB Newbies
*




Posts: 26
Re: SDL-based stereo console
Reply #1 - 09/27/08 at 9:26am
 
You have used the old version of the SDL-based client. I fixed this problem in the later versions. SDLNet_CheckSockets() is the function you need to check if there is something on the network buffer or not, and you can set a timeout for it. And in the new version (which hopefully this evening I'll tidy up and upload) I've also changed the code to send the 'I' command when there is nothing in the buffer, so in case the robot doesn't respond to an 'I' command it sends more till gets the response.
 
I'll upload the new version here:
http://code.google.com/p/client-srv1/
 
I got a soldering iron and now have everything needed to add the stereo vision board. If I don't damage it, by tomorrow it should be ready and I can adopt the code for the stereo board.
 
By the way, did you work on the overlay for the mouse control commands. Currently I have 2 or 3 fps (ad hoc), so actually there is no need to have a real hardware overlay, but in case later I use a wireless router and get a high fps maybe really the overlay is needed. But I was thinking of changing the shape of the cursor, forward/left/downwards/right arrows when the pointer is in the corresponding area.
Back to top
 
« Last Edit: 09/27/08 at 9:27am by hesham »  
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: SDL-based stereo console
Reply #2 - 09/27/08 at 9:49am
 
I did discover the SDLNet_CheckSockets(socSet1, TIMEOUT) call in your code, and this seems to have resolved the problem.  I am also comparing image headers to actual number of bytes read, so there is validation of the image, similar to what you did in your parsing code.  It does seem to be handling timeouts and most of the error conditions, though a bad frame is still getting through occasionally and causing a crash, so I need to look a bit more closely at my error checking.
 
My updated version is here -
    http://www.surveyor.com/stereo/stereo.c
 
That's a great idea about changing the cursor.  I do have code to check for mouse clicks ...
 
           case SDL_MOUSEBUTTONUP:
               if(event.button.button == SDL_BUTTON_LEFT){
                   printf("X: %d Y: %d\n", event.button.x, event.button.y);
               }
               break;
 
but at the moment I only print out the mouse coordinates rather than initiating any action.
 
=================
 
update - I made one small change to the control loop which seems to have fixed the image errors - the console has been running continuously for an hour.  the next remaining step is to add error recovery code in case the TCP connection completely breaks
Back to top
 
« Last Edit: 09/27/08 at 10:39am by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: SDL-based stereo console
Reply #3 - 09/27/08 at 10:45am
 
Has anyone tried to build this code on Windows ?  I haven't figured out how to link to the SDL libraries from mingw, and will probably have the same issues with the Microsoft compiler.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
Lefteris
Senior Member
****




Posts: 274
Re: SDL-based stereo console
Reply #4 - 09/27/08 at 1:43pm
 
I built it using a codeblocks project and adding the appropriate dependecies.
Back to top
 
 

http://www.realintelligence.net - The real intelligence project || http://lefteris.realintelligence.net - My blog
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: SDL-based stereo console
Reply #5 - 09/27/08 at 1:45pm
 
I'm not familiar with codeblocks, but would like to hear more.  Perhaps you could post the setup files ?
 
I'm hoping for just a command-line based version without a gui that can run on Windows, but certainly want to see what else is possible.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
Lefteris
Senior Member
****




Posts: 274
Re: SDL-based stereo console
Reply #6 - 09/27/08 at 2:52pm
 
Well I use codeblocks just for its ease of use and since it is a good IDE. It allows you to even make a new SDL project (which automatically links to the appropriate dlls, if existent in your machine).
 
Alternatively you can check the project's options. I am including two screenshots. One of the linker settings and one of the compilers one's. I have also added wxWidgets library but pay no attention to it.
 
Codeblocks Linker settings
Codeblocks compiler settings
 
But if you really want a good guide, I have something even better than my silly screenshots! LAzy foo's tutorials contain a setting up SDL tutorial for any OS, and any IDE (including command line only).
 
Here is the link
 
You can see that it has guide for many IDEs and command line. Also, note that even though it might not have guides for all SDL libraries you have to do for SDLimg and SDLnet whatever you do with SDLmain.
Back to top
 
 

http://www.realintelligence.net - The real intelligence project || http://lefteris.realintelligence.net - My blog
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: SDL-based stereo console
Reply #7 - 09/27/08 at 3:41pm
 
Thank you !
 
I was able to use the info on the lazyfoo.net link to figure out the missing pieces.  Here's the result -  
 
mingw32-gcc -O2 -o stereo.exe stereo.c -I/mingw/include/sdl -L/mingw/lib -lmingw32 -lSDLmain -lSDL -lSDL_image -lSDL_net
 
I posted a version of stereo.exe (hardwired to 192.168.0.15) and the required DLL's at  
    http://www.surveyor.com/stereo/mingw-stereo.ziip
 
For whatever reason, console output (printf) isn't displayed as with OS/X or Linux, and I'm still seeing occasional lockups.  However, the lockups probably require more robust status checking on the health of the TCP connections, and the console output issue hopefully not difficult to resolve.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
shunt2000
YaBB Newbies
*




Posts: 20
Re: SDL-based stereo console
Reply #8 - 09/27/08 at 4:58pm
 
Just FYI and maybe it will save someone else some time...  
 
I created a makefile to use under Linux and then I have Visual Studio 2008 loaded and downloaded the VC8 versions of SDL 1.2:
 
http://www.libsdl.org/release/SDL-devel-1.2.13-VC8.zip
 
I extracted this to the root of C and then downloaded the VC8 versions of the image and net libraries:
 
http://www.libsdl.org/projects/SDL_image/release/SDL_image-devel-1.2.6-VC8.zip
http://www.libsdl.org/projects/SDL_net/release/SDL_net-devel-1.2.7-VC8.zip
 
I extracted those to an arbitrary location and copied the contents of the include and lib folders to the main library (C:\SDL\SDL-1.2.13\lib and C:\SDL\SDL-1.2.13\include on my machine). I had to add C:\SDL\SDL-1.2.13\lib to my path and then added those locations to the VC++ Project Settings in Visual Studio.
 
If anyone wants the Linux makefile or a Windows version of the base code that hesham released in VS 2008, I'd be happy to email it to them.
 
Back to top
 
 
  IP Logged
shunt2000
YaBB Newbies
*




Posts: 20
Re: SDL-based stereo console
Reply #9 - 09/30/08 at 6:07am
 
Has anyone tried to change the quality of the camera with the SDL-based code?  I tried to change the quality to the highest setting (1) but the code crashes and I am not sure why yet.  The next step down works fine.  I have some image processing routines I want to run against the RGB image but I want to see if I can get the blocking artifacts from the JPEG compression reduced.  There are almost none with the setting at 2 but I wanted to check it out at the highest setting too.
 
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: SDL-based stereo console
Reply #10 - 09/30/08 at 6:37am
 
What version of firmware are you running on the Blackfin ?  There was a bug in the JPEG code for quality = 1 which we fixed a few months ago.  If you update to the latest posted version - http://www.surveyor.com/blackfin/srv-blackfin.090608.zip, it should resolve the problem.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
shunt2000
YaBB Newbies
*




Posts: 20
Re: SDL-based stereo console
Reply #11 - 09/30/08 at 6:40am
 
Great, thanks!  I am using the one from August but I failed to look closely at the details of the latest release.
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: SDL-based stereo console
Reply #12 - 10/01/08 at 1:13pm
 
An update to stereo.c has been posted -
    http://www.surveyor.com/stereo/stereo.c  
 
Error checking has been improved and network reads are now interleaved so this version is LOT faster.  Any feedback will be greatly appreciated.
 
Thanks !
Back to top
 
« Last Edit: 10/01/08 at 1:19pm by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
spikey
YaBB Newbies
*




Posts: 43
Re: SDL-based stereo console
Reply #13 - 11/25/08 at 2:53am
 
I've been trying to convert this stereo console for a single camera console. I think I've managed to do it but I'm experiencing some lookups from time to time, I don't really know what causes it... I haven't done anything with SDL before so I don't really know what I'm doing here, but I'm trying to learn.
 
is there a more up to date version of this console, or is this the latest one?
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: SDL-based stereo console
Reply #14 - 11/25/08 at 7:42am
 
There is a slightly newer version of stereo.c - I just uploaded it to
    http://www.surveyor.com/stereo/stereo.c
 
There is a single camera version upon which the stereo code was originally based.  See -
    http://www.surveyor.com/cgi-bin/yabb2/YaBB.pl?num=1221211446
    http://code.google.com/p/client-srv1/source/browse/trunk/client_srv1.cpp
 
I do see occasional lockups with the stereo.c code, so additional error checking on the data stream is probably required.  If you track down the problem, please let us know.
Back to top
 
« Last Edit: 11/25/08 at 7:47am by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
Pages: 1 2 
Send Topic Print