Go to Post If Will uses the word "dope", doesn't wear a larger FIRST logo, takes up half of the St. Louis arena, if there was not enough seating in the pits, if the music was killed during finals, it was all justified tonight. - Barry Bonzack [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-03-2014, 21:15
AlexBrinister AlexBrinister is offline
Registered User
AKA: Alex Brinister
FRC #1768 (RoboChiefs)
Team Role: Alumni
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Bolton, MA
Posts: 93
AlexBrinister will become famous soon enough
Re: Visual C++: Getting socket server to run parallel to other processes

Personally, I would write a program using MinGW (POSIX) C/C++ but that's just me. Visual C++ threading links:
Microsoft MFC
Stack Overflow - MFC Simple Example
Some other tutorial

Now, if you're going to do this on your ODROID, the story is different because it runs Linux so you have to use the POSIX Standard for threading. Also, wouldn't you have to port your OpenCV program to Linux if you used VC++? I don't know how different it is...

Here are some useful tutorials on network programming and concurrency in a POSIX environment:
YoLinux: POSIX Threads
Sockets in Linux
Linux Magazine - Linux Socket Programming
YoLinux - Sockets

Also, I would use UDP for something like a camera feed because if you use TCP and you drop a few packets, you will get old information because TCP guarantees delivery of all packets. Therefore, the packets you drop will come back and your camera feed will be off. Depending on the amount of data lost, your latency could be significant so I recommend UDP to take care of that problem. If you want to look at some vision code my team wrote last year, you can check out the project home page on our Github page. We used both C networking and POSIX threads.

Good luck!

Alex Brinister

Last edited by AlexBrinister : 02-03-2014 at 21:18. Reason: Port to ODROID?
  #2   Spotlight this post!  
Unread 02-03-2014, 21:43
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Visual C++: Getting socket server to run parallel to other processes

Quote:
Originally Posted by AlexBrinister View Post
Personally, I would write a program using MinGW (POSIX) C/C++ but that's just me. Visual C++ threading links:
Microsoft MFC
Stack Overflow - MFC Simple Example
Some other tutorial

Now, if you're going to do this on your ODROID, the story is different because it runs Linux so you have to use the POSIX Standard for threading. Also, wouldn't you have to port your OpenCV program to Linux if you used VC++? I don't know how different it is...

Here are some useful tutorials on network programming and concurrency in a POSIX environment:
YoLinux: POSIX Threads
Sockets in Linux
Linux Magazine - Linux Socket Programming
YoLinux - Sockets

Also, I would use UDP for something like a camera feed because if you use TCP and you drop a few packets, you will get old information because TCP guarantees delivery of all packets. Therefore, the packets you drop will come back and your camera feed will be off. Depending on the amount of data lost, your latency could be significant so I recommend UDP to take care of that problem. If you want to look at some vision code my team wrote last year, you can check out the project home page on our Github page. We used both C networking and POSIX threads.

Good luck!

Alex Brinister
I'm not the greatest fan of MinGW. I love VC++ because I suck at compiling things like OpenCV. My first successful Linux build was today, which I had to get 326 dependencies and use ccmake for the configurer. At least I now have a 2.4.8 bleeding edge build now. The problem comes that there are only 2 IDEs that I really like and understand, Visual Studio and QT Creator. I have kept close to my code and porting from VC++ to C++ should not take more than 15 minutes. One of my main goals since the beginning is cross-compatibility with the code. I spent a long time getting OpenCV to work properly and I like my setup. Also, with a netboot processor, I doubt i can get much performance out of MinGW.
  #3   Spotlight this post!  
Unread 02-03-2014, 22:08
AlexBrinister AlexBrinister is offline
Registered User
AKA: Alex Brinister
FRC #1768 (RoboChiefs)
Team Role: Alumni
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Bolton, MA
Posts: 93
AlexBrinister will become famous soon enough
Re: Visual C++: Getting socket server to run parallel to other processes

Fair enough. It's just that MinGW supports Linux/POSIX stuff that I'm used to. I have never used VC++.

That being said, if you use an ODROID, your code will have to be POSIX-compliant. The advantage of working in MinGW is that your code would not need to be ported over. You'd already have Linux-compatible code.

That being said, if you are using your ODROID, programming on it would be easiest of all. Though in Linux, VC++ doesn't exist so you should probably learn another IDE like Eclipse or something. I am an everyday Linux user so my preffered environment is VIM and a terminal! QCreator does though...

If you use CMake, compiling should be really easy. You just need to write your own CMakeLists.txt file. Or does ccmake generate one for you?

In the end, it's your choice. Running your vision code on a Linux box gives you the speed and reliability you need for any kind of server applicance such as this. Management is really easy through tools like SSH or Telnet. And it's also an excellent learning experience because in industry, Linux is used virtually everywhere because of its reliability.

Good luck with your code!

Alex Brinister
  #4   Spotlight this post!  
Unread 02-03-2014, 22:32
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Visual C++: Getting socket server to run parallel to other processes

Quote:
Originally Posted by AlexBrinister View Post
Fair enough. It's just that MinGW supports Linux/POSIX stuff that I'm used to. I have never used VC++.

That being said, if you use an ODROID, your code will have to be POSIX-compliant. The advantage of working in MinGW is that your code would not need to be ported over. You'd already have Linux-compatible code.

That being said, if you are using your ODROID, programming on it would be easiest of all. Though in Linux, VC++ doesn't exist so you should probably learn another IDE like Eclipse or something. I am an everyday Linux user so my preffered environment is VIM and a terminal! QCreator does though...

If you use CMake, compiling should be really easy. You just need to write your own CMakeLists.txt file. Or does ccmake generate one for you?

In the end, it's your choice. Running your vision code on a Linux box gives you the speed and reliability you need for any kind of server applicance such as this. Management is really easy through tools like SSH or Telnet. And it's also an excellent learning experience because in industry, Linux is used virtually everywhere because of its reliability.

Good luck with your code!

Alex Brinister
I use ccmake to generate the CMakeLists.txt. It does a good job because it finds what is on the computer and automatically enables it. It took me 15 minutes to get everything set up after I found the resources.

VC++ is basically C++ with some nice extras. However, I wrote my program mostly in strict C++.

I like RDP because i actually get a headed system that i can work on. I also like UART debugging because you even get those kernel messages in realtime

I guess this is really my opinion, but Linux is one of the best implemented kernel, apart from BSD, and if all the man-hours were used to make a good distro like Ubuntu, we would see Linux EVERYWHERE. Pretty soon, Windows will go extinct because my computer cannot stay on for more than a week before starting to completely glitch out.

Has anyone ever used an ODROID? What was your experience and were you able to overclock to 2GHz? That should be 1.5x as fast as my i3 dual core 1.4GHz.

Also, we don't have an ODROID, but we might try to get access to one.
  #5   Spotlight this post!  
Unread 03-03-2014, 08:58
AlexBrinister AlexBrinister is offline
Registered User
AKA: Alex Brinister
FRC #1768 (RoboChiefs)
Team Role: Alumni
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Bolton, MA
Posts: 93
AlexBrinister will become famous soon enough
Re: Visual C++: Getting socket server to run parallel to other processes

My team hasn't had experience with the ODROID but we have used an Intel NUC (Next Unit of Computing). It offered us a huge boost in image processing and allowed us to do a lot with our OpenCV application. The NUC is rated at 1.70 GHz so its slower than an overclocked ODROID. I think that should be plenty fine for what you want to do with your image processing. The downside to the NUC is that it becomes a really expensive part of the control system so if you're tight on money, it certainly isn't a good choice.

Since you wrote your program in standard C++, the only part you will need to change is the threading/socket model.

Alex Brinister
  #6   Spotlight this post!  
Unread 03-03-2014, 11:24
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Visual C++: Getting socket server to run parallel to other processes

Yeah. I have taken a look at the i5 NUC and it only seems worth it if we are sponsored one by Intel. An i5 would actually be faster because it is hyperthreading, meaning it actually behaves like a quad core system, and an x86_64 system is very fast. One advantage of ARM is that the processors are well priced and you don't end up shelling out $400 on a processor. I believe that is because of the licensing; ARM inc. doesn't seem to charge as much as the x86 equivalent, in the forms of licensing. Also, since the system is a PoP, it is much smaller, faster and more efficient, even at lower bus speeds. The NUC is manufactured by Intel, and (no offense to anyone) Intel has their hardware very pricey. I believe the base model, with a Celeron is $200. Plus, you need to get mSATA SSD and some RAM. The only time an NUC is great is when you absolutely require Windows.

The ODROID, in the other hand, is quite cheap, with the U3 of ~$60. That is quite cheap compared to the NUC, because the U3 has quite a powerful chipset!

My code is Visual C++, but the conversion to Linux C++ should be simple because I don't really use the extra features that VC++ adds. Otherwise, I also have the ability to run my code in Mono/Wine.

Also, the fact that most ARM chips are unlocked is splendid. These computers need only about a 30 minute uptime at competitions, so overclocking at ~2-2.1GHz is not just something to dream about, but a possibility!

If we get an SBC, I will actually have a freshman do the work for me because it is on my list to teach a freshman artificial intelligence, and more advanced computer science, and some precalc is fun too. I have been working on some courseware that I wish to deploy to kids in Elementary school because what is more better than an army or uber-intelligent middle-schoolers? .

I will also have the Freshman port my code to Linux because that will force him/her to read through the code and get a basic understanding of how it works!

Last edited by yash101 : 03-03-2014 at 11:26.
  #7   Spotlight this post!  
Unread 03-03-2014, 22:56
AlexBrinister AlexBrinister is offline
Registered User
AKA: Alex Brinister
FRC #1768 (RoboChiefs)
Team Role: Alumni
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Bolton, MA
Posts: 93
AlexBrinister will become famous soon enough
Re: Visual C++: Getting socket server to run parallel to other processes

Interesting usage of freshman slave labor...

Does your freshman know socket/thread programming? If not, then you should probably go over that with him because threading can get really complicated really fast and when you have multiple reads and writes going on at the same time through your sockets (which seems to be your plan) , you need to have a sound asynchronous environment that won't fail you during a match.

Yeah the NUC is way too pricey to run Linux. I think the team had money to throw away and we chose to throw it away on our vision processing (which we didn't even fully use in competition).

Alex Brinister
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:41.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi