Go to Post You don't see teams plastering the arena with signs saying "Show your spirit!" or "Be creative in your robot design!" or "Be sure to be innovative in your control!" - Mr. Van [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-21-2016, 11:36 AM
yonip yonip is offline
Registered User
FRC #0449 (The Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2014
Location: Silver Spring, MD
Posts: 24
yonip is an unknown quantity at this point
[Help] Including non source files in compiled jars (or alternatives)

So this year, I decided to add a .json file to hold the configuration for our robot.
Ideally, I'd like to use the following file structure:
Code:
src/main/java/<robot package then code here>
src/main/resources/cfg.json
But then cfg.json didn't appear anywhere in the compiled .jar
So I moved cfg.json to the robot package (com.usfirt.frc.team449.robot) but it still won't appear in the compiled jar.
So I decided to look up general ways to add non-source files to the jar, but the change that this requires would have to be in the build.xml that wpilib generates via the plugin (I believe that line 94 of that build.xml taht only copies .class files to the jar would do that).

I have noticed on other threads with people asking how to find a file on the roborio, that it would be better to scp or ftp the file into /home/lvuser. Is there any way to automatically do that during the build script (without copying half the wpilib build.xml, redundantly resolving the ip of the roborio and then ssh'ing)?

Currently our working solution is running a short program to print the cfg in one line so we can paste it into a variable used as a fallback when the file isn't fount in code.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-21-2016, 01:06 PM
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: [Help] Including non source files in compiled jars (or alternatives)

Quote:
Originally Posted by yonip View Post
I have noticed on other threads with people asking how to find a file on the roborio, that it would be better to scp or ftp the file into /home/lvuser. Is there any way to automatically do that during the build script (without copying half the wpilib build.xml, redundantly resolving the ip of the roborio and then ssh'ing)?
The reason SSHing to the RIO is done is because the file will be some small config file which will take ~1 second to edit or ~30 seconds to redeploy. Good if your tuning a PID loop or something.

If I had to guess (the robot is currently being worked on... and is written in Python now...)

Right click on your project in Eclipse and go to Properties -> Java Build Path -> Source and add the "yourProjectName/resources" folder
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
Reply With Quote
  #3   Spotlight this post!  
Unread 02-21-2016, 07:40 PM
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,547
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: [Help] Including non source files in compiled jars (or alternatives)

What is the advantage of including a JSON file in the jar, as opposed to a java class with constants?
Reply With Quote
  #4   Spotlight this post!  
Unread 02-21-2016, 08:09 PM
yonip yonip is offline
Registered User
FRC #0449 (The Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2014
Location: Silver Spring, MD
Posts: 24
yonip is an unknown quantity at this point
Re: [Help] Including non source files in compiled jars (or alternatives)

Quote:
Originally Posted by Arhowk View Post
The reason SSHing to the RIO is done is because the file will be some small config file which will take ~1 second to edit or ~30 seconds to redeploy. Good if your tuning a PID loop or something.

If I had to guess (the robot is currently being worked on... and is written in Python now...)

Right click on your project in Eclipse and go to Properties -> Java Build Path -> Source and add the "yourProjectName/resources" folder
Do you know if i can add the SSHing as something that can be done on every deploy, but also when i just need to update the file (for tuning, as you mentioned).

I have tried setting the resources folder as a source (as well as just putting the json in alongside the source files) but it doesn't end up in the jar and my program can't find it.

Quote:
Originally Posted by Joe Ross View Post
What is the advantage of including a JSON file in the jar, as opposed to a java class with constants?
So last year, when our team switched to java, we used a single java class with constants. However, that file (along with the file structure) was a mess to parse as the only way to sort the variables was by prefixing their name with their subsystem or whatever (example)
This year I worked on revamping the file system to enable code reuse by creating self-sufficient subsystem that could theoretically simply be added to a new robot project that has those subsystems, and only some configuration would have to be made.
The problem now is that each subsystem has its own map. Now our configuration is all over the place.
To solve this problem I created a program that parses the maps to create a single json file skeleton, that once trimmed and filled in (eventually automatically) will contain all of the configurations in one place, and ultimately would make finding conflicting ports or wrong values significantly easier.

TL;DR the json should, in the end, make configuration significantly easier and allow for code reuse structure in code.

Last edited by yonip : 02-21-2016 at 08:14 PM. Reason: adding json examples
Reply With Quote
Reply


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 08:59 AM.

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