|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Joystick recording for Auton.
Hello all.
So I am working on an off season project that involves writing a program (JAVA) that allows the robot to record joystick values and then be able to play them back in auton. Such as what Team 1717 did in the book, The New Cool (awesome btw). I was first thinking to just have the program, print all the values in an text file however then ran into the problem how the heck do you do that on a cRIO? In addition saw this thread earlier: http://www.chiefdelphi.com/forums/sh...ad.php?t=91305 As anyone used ^ successfully? Or done have done this before? Thanks |
|
#2
|
|||||
|
|||||
|
Re: Joystick recording for Auton.
In the past, we have used file operations to log various values like gyro headings or motor current readings.
File operations for FRC are just as they are in Java SE. This is our DataLogger class: Code:
import java.io.*;
import javax.microedition.io.Connector;
/**
* Data Logger Class
* @author Jeremy Germita
*/
public class DataLogger {
private PrintStream m_printStream;
private DataLogger m_instance;
/**
* Constructor
* @param fileName the filename to write to
*/
public DataLogger(String fileName) {
try {
OutputStream m_output = Connector.openOutputStream(fileName);
m_printStream = new PrintStream(m_output);
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
/**
* Get instance of datalogger
* @param fileName the filename to write to
* @return the instance of the DataLogger
*/
public DataLogger getInstance(String fileName) {
if(m_instance == null) {
m_instance = new DataLogger(fileName);
}
return m_instance;
}
/**
* Print data, followed by a newline character to the printstream and flush it
* @param data the data to print
*/
public void println(String data) {
m_printStream.println(data);
m_printStream.flush();
}
/**
* Print data to the printStream and flush it
* @param data
*/
public void print(String data) {
m_printStream.print(data);
m_printStream.flush();
}
/**
* Close the printStream
*/
public void close() {
m_printStream.close();
}
}
The cRio's file paths are in this format: Code:
file:///Your_File_Is_In_The_Root.txt As mentioned in the previous thread, be wary of writing data too many times. For recording joystick values, I recommend reading values (and writing to the file) every 50-100ms, or every 2-4 loops in autonomous/teleop/disabledPeriodic. Your Mileage May Vary. Last edited by Jeremy Germita : 27-06-2011 at 02:15. Reason: forgot imports |
|
#3
|
|||||
|
|||||
|
Re: Joystick recording for Auton.
One of the things you will probably find if you go the route of playing back joystick commands is that your bot is going to do somewhat different things each time! Maybe one time it will drive further, or not turn quite the same amount, as the time before. Why is this?
When you are recording a joystick command during teleop, that command is usually being sent as a PWM value (you can think of this as an "average voltage") to a motor. But what happens if you record the data with a 12.8V battery, then play it back with a 12.5V battery? Or if your wheels have worn a bit. Or if it's warmer than when you first recorded. Or if there's a slight uneven spot in the carpet. Etc. Etc. You will get slight differences that might mean the difference between hanging that ubertube and dropping it to the left of the peg! I very much recommend you do what you set out to do, as it is a great learning exercise. But if you are not satisfied with the repeatability of the solution, don't stop there! You will learn about great tools such as sensors (encoders + gyros) and control algorithms (PID controllers) if you keep investigating. Imagine if you recorded the wheel speeds instead of the joystick or PWM values. If you know you want to go 5 feet per second, and have a sensor that can measure your current speed, there are techniques to force your wheel to go 5 feet per second regardless of battery, environment, wear, etc. |
|
#4
|
|||
|
|||
|
Re: Joystick recording for Auton.
Wow, I love this idea. Would love to hear any results as far as repeatability goes.
|
|
#5
|
|||
|
|||
|
Re: Joystick recording for Auton.
One tip: use an actual timer or encoders. Do not rely on a "counter' where you increase the value every clock cycle. From my experiments, the counter method is reliable only about 90% of the time. In the 10%, the values end up being so dramatic that I would never trust it in competition.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|