Go to Post Honestly though, having a cave would be one of the greatest places to build a robot. There's already lack of light and lots of floor space! Well, if you have a good cave sponsor, that is. - Bryce Clegg [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 11-12-2013, 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
Using Multiple Languages

I was wondering whether it would be worth using multiple language on a robot. Since I am no expert, I am wondering whether it is a good idea to use multiple languages on the robot. Our robot is to be programmed in Java. However, I would like to use C for offboard vision because it is very easy to get everything set up and to program OpenCV.

Other than that, does anyone know how to get Java running with OpenCV?

Thanks, and Happy Holidays/Happy KickOff!
  #2   Spotlight this post!  
Unread 11-12-2013, 22:29
calcmogul's Avatar
calcmogul calcmogul is offline
WPILib Developer
AKA: Tyler Veness
FRC #3512 (Spartatroniks)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Santa Maria, CA
Posts: 52
calcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nice
Re: Using Multiple Languages

The cRIO can only support one language image at a time, which can be changed via the cRIO Imaging Tool. However, you could also run an interpreted language like Python or another scripting language with a runtime written in whatever language the cRIO is imaged in. Other than that, there shouldn't be a problem using multiple languages since the cRIO and the coprocessor are two separate systems.

I'm not familiar with OpenCV as it pertains to Java. I'm sure someone else can point you in the right direction.
  #3   Spotlight this post!  
Unread 11-12-2013, 23:01
Domenic Rodriguez's Avatar
Domenic Rodriguez Domenic Rodriguez is offline
Registered User
FRC #0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
Domenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura about
Re: Using Multiple Languages

I've been looking into using another language on the robot along side Java as well, primarily for autonomous scripting. What I've found is that since FRC currently uses a Java ME environment (the Squawk JVM is J2ME CLDC 1.1), disappointingly most of the new cool JVM-backed languages are not compatible (such as Scala, Clojure, JRuby, etc). There are a couple of J2ME implementations of Lua floating around, but I was not able to get any of them working for FRC. It seems folks have more success with this from the C++ side of things with projects like RobotPy and Greyhound Lua. However, both of these are intended as a full replacement, not to be mixed and matched with C++ [citation needed].

There is always the possibility of writing your own scripting language, which would probably be a beneficial experience in and of itself. Additionally, Team 4334 created a scripting language called Gordian designed specifically for FRC; you might want to check it out.

As was already stated, using a different language on the driver station or whatever you are using for vision processing will be fine.
__________________

LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!

FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)

  #4   Spotlight this post!  
Unread 11-12-2013, 23:04
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: Using Multiple Languages

Quote:
Originally Posted by mathmogul View Post
The cRIO can only support one language image at a time, which can be changed via the cRIO Imaging Tool. However, you could also run an interpreted language like Python or another scripting language with a runtime written in whatever language the cRIO is imaged in. Other than that, there shouldn't be a problem using multiple languages since the cRIO and the coprocessor are two separate systems.

I'm not familiar with OpenCV as it pertains to Java. I'm sure someone else can point you in the right direction.
Thanks. I was looking at a comparison between just sticking with one language, sticking with one language, but making some exceptions, and allowing every language, even if it is as old as Forth!

I know that almost every software giant, like Google, Microsoft and Facebook (IDK about Apple, so I won't comment), use multiple languages to do their processes. Google has most of it's code written in Java, but uses quite a bit of python interleaved.

Our team has, for this year, stuck to using just Java, because our mentor's told us that it is the "best" language. While it isn't a bad language (I like Java, actually), There are some places where I think it is impractical to use Java. In this case, I am thinking solely about OpenCV. It is probably one of the most feature-packed CV library, but installing the Java connector seems like rocket science. Not only that, but SoCs typically have crappy JVMs, making it a hassle to run the code. OpenCV, for example, is written in C. That means that the Java interpreter needs to run the binaries continuously. In the case where you have limited resources like RAM, that seems quite impractical, the same reason why a Raspberry Pi + Minecraft Server don't always work out well, if you are a typical gamer!

Typically, linking multiple languages isn't the easiest thing to do. However, in this case, the cRIO is the i2C host server and the Pi is the i2C slave, obeying the instructions of the cRIO!

On a full-blown Debian system, I noticed that the JVM takes quite a bit of time to launch. It takes 1-5 minutes for Minecraft, Vanilla, to load on my MacBook. I think the reason why I get such load speeds is because the DSP of my Pi isn't powerful enough to max out my Hard Disk, another reason why I shouldn't waste my money buying an SSD for the Pi! That's why when you go on my site, when the chrome bar is moving backwards slowly, the HDD is being read, and the site is being generated/downloaded as the circle turns around!

This is just what I have noticed when programming.
  #5   Spotlight this post!  
Unread 12-12-2013, 01:58
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Using Multiple Languages

Both Java and LabVIEW can call a C library. With Java, you would use JNA. With LabVIEW, you would use Call Library Function.

We have never used different programming languages on the robot. We have used Java on the robot, and a LabVIEW dashboard to do vision processing.

Quote:
Originally Posted by yash101 View Post
I was wondering whether it would be worth using multiple language on a robot. Since I am no expert, I am wondering whether it is a good idea to use multiple languages on the robot. Our robot is to be programmed in Java. However, I would like to use C for offboard vision because it is very easy to get everything set up and to program OpenCV.
The choice as to whether to use multiple programming languages should be carefully considered. It significantly increases the complexity of your program. You can't afford to have only a single person that knows part of your code, so you need multiple people able to use both languages. Often I see a project use different languages because one person is an expert in one language and doesn't want to learn the language that everyone else is using. This doesn't end well.

When is it ok to use multiple languages? Here's a few rules of thumb:
When each language has clear benefits in a particular area, and a common language has significant detractors in those areas.
When everyone agrees that multiple languages are better.
When multiple people can work with multiple languages.
When there is a clear segmentation (for example, different processors).
When the interface between the languages is well defined and the amount of information to be shared is minimal.
When there is lots of time for troubleshooting.


Quote:
Originally Posted by DomenicR View Post
IHowever, both of these are intended as a full replacement, not to be mixed and matched with C++ [citation needed].
Here's one project designed to run LUA alongside C++. http://www.chiefdelphi.com/forums/sh...&highlight=lua

Quote:
Originally Posted by yash101 View Post
That means that the Java interpreter needs to run the binaries continuously.
What does this mean?
  #6   Spotlight this post!  
Unread 12-12-2013, 21:32
MaxMax161's Avatar
MaxMax161 MaxMax161 is offline
Allegedly Useful
AKA: Max Llewellyn
FRC #2791 (Shaker Robotics), FRC #1676 (Pascack π-oneers)
Team Role: Mentor
 
Join Date: Nov 2009
Rookie Year: 2008
Location: Montvale NJ\Troy NY
Posts: 174
MaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond reputeMaxMax161 has a reputation beyond repute
Re: Using Multiple Languages

In my experience it hasn't been worth the effort to try and do multiple languages on a single device in FIRST. I've found that with a little file IO and a few switches there's practically no need to do any code changes to autonomous. If I'm drawn to using another language for more than auton I might as well write the whole thing in that language.

However multiple languages on different devices is much less of an issue. For example a robot written in C++ or LabVIEW and a dashboard in Java can work well together, or a microcontroller with code written in XYZ communicating with a robot written in ABC aren't that difficult. Once you're communicating over the network to a separate device the difficulty of using a different language only comes from needing to be proficient in two languages.

tl;dr Is there a better way to accomplish what you want to accomplish with multiple languages on one device? Different devices mean multiple languages isn't really a big deal.
__________________
2791 Shaker Robotics (2013-present)
--Control Systems Mentor 2013-present
--Drive coach 2015-present

1676 The Pascack π-oneers (2010-2013)
--Drive coach 2011-2013
--Lead Programmer 2011-2013
  #7   Spotlight this post!  
Unread 12-12-2013, 23:32
faust1706's Avatar
faust1706 faust1706 is offline
Registered User
FRC #1706 (Ratchet Rockers)
Team Role: College Student
 
Join Date: Apr 2012
Rookie Year: 2011
Location: St Louis
Posts: 498
faust1706 is infamous around these partsfaust1706 is infamous around these parts
Re: Using Multiple Languages

We do not use multiple languages on our robot, but in our team. Our cRio is labview, computer vision is c or c++ (mentors encourage c++, for college studies)-whichever the student prefers, and our scouting system is in c#. I personally like the variety. It allows for a more well rounded programmer. If you don't enjoy labview, you can try out C++, C# or just plain old C. We have a mentor that learned labview through FIRST many many years ago, another is an electrical engineer that has been learning c++ with the rest of the students, and we have another mentor who develops code in c# for a living, so we have support in all three.
__________________
"You're a gentleman," they used to say to him. "You shouldn't have gone murdering people with a hatchet; that's no occupation for a gentleman."
  #8   Spotlight this post!  
Unread 13-12-2013, 07:12
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,756
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Using Multiple Languages

I think I'd rephrase this original question.

Do you have a problem that warrants bringing in an additional tool?

A computer language is a tool. Carrying multiple tools around and being proficient in them is useful and not uncommon. Using them simultaneously is far different and far harder than one at a time.

Getting to the details, mixing languages can really complicate things if the fundamentals of data types, memory ownership and lifetime aren't well understood and controlled. There are other issues too, like knowing which tool a particular error code was produced by. Basically, different design philosophies within the language and the libraries can make this much harder.

As others have mentioned, a safer way to do this is to isolate the tools to different computers, perhaps at sub-team boundaries.

Did you have a specific problem in mind?
Greg McKaskle
  #9   Spotlight this post!  
Unread 17-12-2013, 16:00
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Using Multiple Languages

Quote:
Quote:
Originally Posted by yash101 12-11-2013, 11:04 PM View Post
That means that the Java interpreter needs to run the binaries continuously.
Quote:
Originally Posted by Joe Ross 12-12-2013, 01:58 AM View Post
What does this mean?
I'm still wondering what it means.


  #10   Spotlight this post!  
Unread 17-12-2013, 17:17
brennonbrimhall brennonbrimhall is offline
Free Agent
AKA: Brennon Brimhall
no team
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Clifton Park, NY
Posts: 222
brennonbrimhall is a name known to allbrennonbrimhall is a name known to allbrennonbrimhall is a name known to allbrennonbrimhall is a name known to allbrennonbrimhall is a name known to allbrennonbrimhall is a name known to all
Re: Using Multiple Languages

Quote:
Originally Posted by yash101 View Post
I was wondering whether it would be worth using multiple language on a robot. Our robot is to be programmed in Java. However, I would like to use C for offboard vision because it is very easy to get everything set up and to program OpenCV.

Other than that, does anyone know how to get Java running with OpenCV?
Firstly, modern OpenCV uses C++. Yes, the OpenCV docs for Java integration are here for a CLI and here for Eclipse.

While vision processing is nice, its useless unless you can communicate the results back to the cRIO. You should focus on designing the mechanism by which you want the two systems to pass information back and forth. If that leads you to write both in the same language, great. If you end up using C++ and Java, great. (Assuming you're open to using multiple languages, of course; if you only know Java, that's a different case.) Making your code simple and reliable is much more important than what language it uses.

Quote:
Originally Posted by yash101 View Post
Our team has, for this year, stuck to using just Java, because our mentor's told us that it is the "best" language. While it isn't a bad language (I like Java, actually), There are some places where I think it is impractical to use Java. In this case, I am thinking solely about OpenCV. It is probably one of the most feature-packed CV library, but installing the Java connector seems like rocket science. Not only that, but SoCs typically have crappy JVMs, making it a hassle to run the code. OpenCV, for example, is written in C. That means that the Java interpreter needs to run the binaries continuously. In the case where you have limited resources like RAM, that seems quite impractical, the same reason why a Raspberry Pi + Minecraft Server don't always work out well, if you are a typical gamer!
I don't quite understand what you mean. All that Java should do is reference the precompiled binaries, making execution faster.
__________________
Team 20, 2012-2014: 4 blue banners, 5 medals, and 9 team awards.
Church of Jesus Christ of Latter-day Saints, 2014-2016: Missionary, Colorado Denver South Mission.
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:21.

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