Go to Post We honor those who are unsung - those without a trophy or a plaque to show their efforts. Those who may or may not get those things... but will still be on the sidelines, helping to guide FIRST in all the right directions. - Amanda Morrison [more]
Home
Go Back   Chief Delphi > Technical > Control System
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 10-03-2015, 22:59
Crossle86's Avatar
Crossle86 Crossle86 is offline
Software Engineer
AKA: Richard Corn
FRC #4450 (Olympia Robotics Federation)
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Olympia, WA.
Posts: 92
Crossle86 is an unknown quantity at this point
Programmatically Determine Which Rio Code is on

Is there a way to determine in java which roboRio the code is runing on? We have several RR and want to run the same code on all of them with some differences determined at run time in the robot class constructor or init method. The robots carrying the RRs are very similar but not exactly the same.
Reply With Quote
  #2   Spotlight this post!  
Unread 10-03-2015, 23:20
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Programmatically Determine Which Rio Code is on

Our solution to the close-but-not-identical-robot problem many years ago was to put a jumper on one of the DIO ports. One robot read the input as "true", the other read "false". I think the code picked a different set of PID constants and sensor calibration points for each robot.

If you have several robots, you can use multiple Digital Inputs. Or you might use a simple resistor divider circuit on an Analog Input, with each robot having a unique "ID voltage".
Reply With Quote
  #3   Spotlight this post!  
Unread 10-03-2015, 23:50
dellagd's Avatar
dellagd dellagd is offline
Look for me on the field!
AKA: Griffin D
FRC #2590 (Nemesis) #2607 (The Fighting Robovikings)
Team Role: Mentor
 
Join Date: Sep 2011
Rookie Year: 2011
Location: PA
Posts: 890
dellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond repute
Re: Programmatically Determine Which Rio Code is on

Im sure there is probably some flag you could set that could then be read natively in your code, but something really simple might just be to put a text file on each roborio, each containing a unique identifier, like "Practice Setup" or "Competition Robot". Simply read this file in your robot code and you'll have which rio its running on.
__________________
Check out some cool personal projects in computers, electronics, and RC vehicles on my blog!

2016 MAR DCMP Engineering Excellence Award
2016 MAR Westtown Innovation in Control Award
2016 MAR Hatboro-Horsham Industrial Design Award
2015 Upper Darby District Winners - Thanks 225 and 4460!
2015 Upper Darby District Industrial Design Award
2015 Hatboro-Horsham District Winners - Thanks 2590 and 5407!
2014 Virginia Regional Winners - Thanks so much 384 and 1610, I will never forget that experience!
2014 Virginia Quality Award
2014 MAR Bridgewater-Raritan Innovation in Control Award
2014 MAR Hatboro-Horsham Gracious Professionalism Award
2013 MAR Bridgewater-Raritan Innovation in Control Award
2012 MAR Lenape Quality Award
Reply With Quote
  #4   Spotlight this post!  
Unread 11-03-2015, 04:30
Aren Siekmeier's Avatar
Aren Siekmeier Aren Siekmeier is offline
on walkabout
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Apr 2008
Rookie Year: 2008
Location: 대한민국
Posts: 735
Aren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond reputeAren Siekmeier has a reputation beyond repute
Re: Programmatically Determine Which Rio Code is on

Quote:
Originally Posted by dellagd View Post
Im sure there is probably some flag you could set that could then be read natively in your code, but something really simple might just be to put a text file on each roborio, each containing a unique identifier, like "Practice Setup" or "Competition Robot". Simply read this file in your robot code and you'll have which rio its running on.
This is what our implementation looks like. We've got several property files on the roboRio being read by the user code (written in Java) at startup defining the operator interface, the I/O wiring, and any parameters we want to tune. Then each roboRio (each robot or test bed) keeps its own property files depending on its own configuration.
Reply With Quote
  #5   Spotlight this post!  
Unread 11-03-2015, 09:16
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 327
fovea1959 will become famous soon enough
Re: Programmatically Determine Which Rio Code is on

We've done this with a 'name' field in a WPILIB Preferences object, we've done it with a jumper on the bot (like Alan), and we have worked off the network MAC address.

In our experience, Alan's is the best/easiest way if you have the spare DIO (you don't need a programmer around if you move roboRIO XXXX from the test chassis to the competition chassis). We made sure the competition robot required NO jumpers, we used jumpers to disable stuff on the test/practice robots. Murphy says you will lose the jumper if you need it at competition.

If you want to go from the MAC address (yes, there is a typo in one of the MACs):

Code:
public boolean havePneumatics = false;

    public void checkForPneumatics() {
        havePneumatics = false;
        try {
            for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) {
                NetworkInterface network = e.nextElement();
                System.out.println("network " + network);
                byte[] mac = network.getHardwareAddress();
                if (mac != null) {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < mac.length; i++) {
                        sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
                    }
    // Mule Board (wegscheid) MAC: "00-80-2F-17-EA-A4"
                    // MAC: "00-80-2F-17-EA-A5"
                    //Test bot (3630KOP) MAC: "00-80-2F-17-93-IE"
                    //Prototype (3620 Spare) MAC: "00-80-2F-17-EB-09"
                    // MAC: "00-80-2F-17-EB-08"
                    String macString = sb.toString();
                    System.out.println(" looking at MAC:" + macString);
                    if (macString.equals("00-80-2F-17-EB-09") || macString.equals("00-80-2F-17-EA-A4")) {
                        havePneumatics = true;
                        break;
                    }
                }
            }
        } catch (SocketException e) {
            e.printStackTrace();
        }
        System.out.println ("We have " + (havePneumatics ? "" : "no ") + "pneumatics");
                
    }
Reply With Quote
  #6   Spotlight this post!  
Unread 11-03-2015, 12:32
Crossle86's Avatar
Crossle86 Crossle86 is offline
Software Engineer
AKA: Richard Corn
FRC #4450 (Olympia Robotics Federation)
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Olympia, WA.
Posts: 92
Crossle86 is an unknown quantity at this point
Re: Programmatically Determine Which Rio Code is on

Thanks for the replies, all good suggestions. I was trolling for an API that would return a serial number or some such built in identifier and the mac address would fill that bill. However, I am leaning toward the configuration file using a java properties object. That would offer the most flexibility and future expansion.
Reply With Quote
  #7   Spotlight this post!  
Unread 12-03-2015, 09:56
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 327
fovea1959 will become famous soon enough
Re: Programmatically Determine Which Rio Code is on

as I recall, the serial number is accessible from LV, but it didn't get exposed to the Java or C++ APIs.
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 07:39.

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