View Single Post
  #23   Spotlight this post!  
Unread 05-17-2010, 11:19 AM
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
Re: Making autonomous accessible to all teams

Personally, I think that you need to learn how to walk before you run.

Autonomous can be done by recording what people do during a teleop match, programming it in, then excecuting it.

Using Java, you can use GRT's File IO class to do this. Make a String at the beginning of the class. At the end of each loop call:
Code:
fooString = fooString += "j1x1: " + joy1.getx1() + " joy1y1: " + joy1.gety1() + fired ? "    Fired" : "" + "      Time: " + edu.wpi.first.wpilibj.Timer.getUsClock();
Yes, i know i'm using a ternary operator here.

finally, set a button to call:
Code:
GRTFileIO.writeToFile("forAuto", fooString);
Then work on turning the log into a function, and volia.

Here is the GRTFileIO Class in case you need it:
Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.shadowh511.mayor.utils;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import javax.microedition.io.Connector;
import com.sun.squawk.io.BufferedReader;
import com.sun.squawk.microedition.io.FileConnection;

/*
 * I copied this code from the GRT Framework
 */

public class GRTFileIO {
	public static String getFileContents(String filename) {
		String url = "file:///" + filename;
		String contents = "";
		try {
			FileConnection c = (FileConnection) Connector.open(url);
			BufferedReader buf = new BufferedReader(new InputStreamReader(c
					.openInputStream()));
			String line = "";
			while ((line = buf.readLine()) != null) {
				contents += line + "\n";
			}
			c.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return contents;
	}

	public static void writeToFile(String filename, String contents) {
		String url = "file:///" + filename;
		try {
			FileConnection c = (FileConnection) Connector.open(url);
			OutputStreamWriter writer = new OutputStreamWriter(c
					.openOutputStream());
			writer.write(contents);
			c.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}