Download presentation
Presentation is loading. Please wait.
1
Config File and Robot Telemetry Implementation
Frank Larkin Comcast Principal Engineer II / Lansdale Catholic Robotics (FRC272) FIRST Boot Camp December 11, 2016
2
Config File And Telemetry – C++
Started using Telemetry and config files back in 2009 See code examples at… All written using global variables. Will work fine but can be refined to use similar coding in Java Differences: Uses global variables Must be custom built each season. Does not use key/value pairs. Not sure how to do it in C++ (dictionary)
3
Config File -Java 2016 JavaDoc: // In robot class
Define variable values so they can be updated without changing code. Uses MAP data type to read in values and put them in Key/Value pairs. Any “key” not in the list uses the default supplied in the get request. // In robot class public void disabledInit() { telem.restartTimer(); config.load(); this.telem.loadConfig(config); } // In telemetry class public void loadConfig(Config config){ this.sp_FileName = config.getString("Tele_FileName", "telemetry"); this.sp_FilePath = config.getString("Tele_FilePath", "/tmp"); this.bp_TimestampFile = config.getBoolean("Tele_TimestampFile", false);
4
Config File - Java Define variable values so they can be updated without changing code. Example # Configuration data for the FRC Robot# all data must be in a pipe (|) delimited file. # Field | data | additional data or comments. #Auton Config d_AutonInitWaitTime | 1.5 | Delay before you move i_AutonBalistaPowerLevel | 1 d_AutonLowBarDriverArchadePower | .30 | Go a little slower d_AutonLowBarBreachDuration | 2.5 d_AutonMoatDriverArchadePower | .40 d_AutonMoatBreachDuration | 3 d_AutonRampartArchadePower | .40 d_AutonRampartBreachDuration | 3 d_AutonRoughTerDriverArchadePower | .40 d_AutonRoughTerBreachDuration | 3 d_AutonRockWallDriverArchadePower | .50 d_AutonRockWallBreachDuration | 3.6 #Shooter Stuff d_Balista_Lev1_ArmTime | .3 d_Balista_Lev1_GrabberDelay | .2 b_UsePIDControl | true d_Shooter_PID_PValue | 1.0 d_Shooter_PID_IValue | 0.0 d_Shooter_PID_DValue | d Shootrt_PID_FValue | 0.2 i_ShooterForwardPosition | | very low t0 pick up balls i_ShooterFlippedPosition | | very low t0 pick up balls
5
Telemetry Definition: Telemetry is an automated communications process by which measurements and other data are collected at remote or inaccessible points and transmitted to receiving equipment for monitoring. The word is derived from Greek roots: tele = remote, and metron = measure. Allows you to… Save all the important variables over time as your robot operates. Recall these after a round to know what was happening Know for certain what you were trying to do and what your Carbon Based Units were doing. Provides the raw data so you can display selected variables grouped together to understand what was happening. You can go into a discussion knowing what really happened vs. guessing. Instead of “I think it might have…” you will say, “I know exactly what…”
6
Variables Telemetry can save many simple forms of data Numbers:
All data is converted to and saved as a string. Numbers: Doubles: Analog values from sensors like IR or Sonic detectors. Range usually +/ (no problem if biggest) Integers: Normal and long what ever size. When viewed in Excel these are always shown as a decimal (.0) Strings: These will be you longest variables but help you read the tea leaves of you data. Booleans: True / False (several options) to write True/False every time To write True/Blank if value is True. Makes sheet less cluttered To write False/Blank if value is False.
7
How much data? How much space will it use on my robot?
Formula: asv * var * lps * sec = bytes of data Asv = average size of variables in bytes How big is each piece of data? Var = How many variables will you write? What is important? Numbers, strings, booleans Lps = Loops per second how many times per second will you loop through the code? You will write 1 row of data for each loop. Sec = How many seconds will you record. Normal round plus autonomous We do not record during disabled mode.
8
How much data? How much space will it use on my robot?
Formula: asv * var * lps * sec = bytes of data Asv = 5 characters (“1.00”, “True”, “Start of Arm”, “Ready”, “Fire” Var = Add all you classes variables to record. Input: 20, Sensors: 5, Shooter: 15, Output: 20 = 60 Lps = Loops per second Iterative does 50 loops per second best case Sec = How many seconds will you record. 3*60 = 180 seconds (really 2:15) 5 * 60 * 50 * 180 = 2,700,000 Bytes or 2.7 MB. (cake!)
9
How much data? (worse case)
How much space will it use on my robot? Formula: asv * var * lps * sec = bytes of data Asv = 10 characters (“1.00”, “True”, “Start of Arm”, “Ready to Retract”, “Fire on the Signal”, “I love little puppies”) Var = Add all you classes variables to record. Input: 40, Sensors: 30, Shooter: 60, Output: 40 = 170 Lps = Loops per second Iterative does 50 loops per second best case Sec = How many seconds will you record. 3*60 = 180 seconds (really 2:15) 10 * 170 * 50 * 180 = 15,300,000 Bytes or 15.3 MB. (Cake!)
10
LCTelemetry Class – The Guts of it
private String[] listRows; // rows are stored here private String[] listColumns; // Array of columnNames, think ladder. private Map<String, String> dictColumnData; // key-value pairs private int i_TotalRows; // how may rows have been created private int i_listColumnsIndex; //what is the next column I can write public final int ki_MaxColumns = 300; // Max Number of columns public final int ki_MaxRows = 50 * 60 * 3 // Max number of rows
11
LCTelemetry Class At start up builds a String Array of [ki_MaxColums]
These store your variable headers in spreadsheet order. Based upon the first pass. addColumn( String columnName) Add a column name (header) to the list saveInteger(String columnName, int value) saveDouble(String columnName, double value) saveString(String columnName, String value) saveBoolean(String columnName, Boolean value) saveTrueBoolean(String columnName, Boolean value) saveFalseBoolean(String columnName, Boolean value) writeRow() saveSpreadSheet()
12
Implementation – Creating the Columns (once)
Create telem handle and all headers/columns at once in Robot_Init() public void robotInit(){ … telem = new LCTelemetry(); // create telem handle. // add the telemetry fields. This is the order they will be in. auton.addTelemetryHeaders( telem ); sensors.addTelemetryHeaders( telem ); spinMoves.addTelemetryHeaders(telem); shooter.addTelemetryHeaders( telem ); inputs.addTelemetryHeaders( telem ); robotbase.addTelemetryHeaders( telem ); cameraControl.addTelemetryHeaders(telem); }
13
Implementation – Saving Data
Every class you write implements 2 public methods… public void addTelemetryHeaders(LCTelemetry telem ){ telem.addColumn("I Driver Arch Turn"); // add to listColumns telem.addColumn("I Driver Arch Power"); telem.addColumn("I Fire By Camera"); } public void writeTelemetryValues(LCTelemetry telem ){ // associate each column name (key) with data (value) in dictColumnData // dict means dictionary. Key / Value pair. Remember it this is important // the order does not matter here… why???? telem.saveTrueBoolean("I Fire By Camera", this.b_FireByCamera); // column MUST match telem.saveDouble("I Driver Arch Turn", this.d_DriverArchadeTurn ); telem.saveDouble("I Driver Arch Power", this.d_DriverArchadePower );
14
Implementation – Build and write a row
Periodic section builds the row data and then writes it() public void teleop_periodic (){ … // do all you other stuff up here. inputs.writeTelemetryValues(telem);// order does not matter shooter.writeTelemetryValues(telem); // order does not matter sensors.writeTelemetryValues(telem); robotbase.writeTelemetryValues(telem); cameraControl.writeTelemetryValues(telem); spinMoves.writeTelemetryValues(telem); telem.writeRow(); // very last thing you do }
15
Implementation – Build and write a row
telem.writeRow(); Builds a long string of the variables separated by tab character This enables an Excel spreadsheet to read it directly First it add 3 fields, It builds the in the order the columns are in listColumns. Time : in 2 decimal place precision since the beginning of recording. Battery Voltage Mode: “auton”, “teleop”, “disabled” Next it adds each variable based in listColumns (headers) This is used a key to pull from the dictionary. Missing field returns blank. When done it save it to the next spot in listRows
16
Implementation – saveSpreadsheet() (Manual)
Manually save the spreadsheet at the end of the round. Robot goes to disabled at end of round Have the operator and driver each press a button at the same time. public void disabled_periodic() { … if (inputs.driverTelem==1 && inputs.operatorTelem==1) telem.saveSpreadSheet(); }
17
Implementation – saveSpreadsheet() (Automatic)
Save spreadsheet when you transition from disabled to either auton or teleop_periodic. public void disabled_init() { telem.saveSpreadSheet(); // if there is data it is saved … } Spread sheet is restarted in the next mode. First “mode” tells us what type we are
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.