Go to Post Ask questions; don't be afraid to talk to "powerhouse" teams. - CalTran [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 27-06-2011, 01:57
Mk.32's Avatar
Mk.32 Mk.32 is offline
Registered User
AKA: Mark
FRC #2485 (W.A.R. Lords)
Team Role: Engineer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: San Diego
Posts: 770
Mk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud ofMk.32 has much to be proud of
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
__________________
Engineering mentor: Team 2485: WARLords 2013-

Team President: Team 3647 2010-2013
  #2   Spotlight this post!  
Unread 27-06-2011, 02:13
Jeremy Germita's Avatar
Jeremy Germita Jeremy Germita is offline
Co-Advisor/Lead Engineering Mentor
AKA: wood is good. plastic is fantastic.
FRC #5012 (Gryffingear) / (Antelope Valley FIRST Teams)
Team Role: Coach
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Lancaster, CA
Posts: 285
Jeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond reputeJeremy Germita has a reputation beyond repute
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();
    }

}
You simply provide the file path in the constructor and you can write data to that file using the print/println methods. A note: you must call the close method after you write the data.

The cRio's file paths are in this format:
Code:
file:///Your_File_Is_In_The_Root.txt
If you need any help in reading that information from the file, I can dig up that code for you as well.

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.
__________________
Drive Coach Team 5012 Gryffingear / Antelope Valley FIRST teams / EWCP - (2013 - Current)
Student / Driver / Programmer / CAD - FRC Team 399: Eagle Robotics / FTC Team 72: GarageBots - (2009 - 2013)
Los Angeles Region FTC FTA/CSA/Head Ref
[FF] FIRST Pick
2014 FTC Los Angeles Regional Compass Award Winner.

2017 - San Diego Regional / Sacramento Regional / Las Vegas Regional
2016 - Los Angeles Regional Creativity + Winners (1197, 987, 5012) / Las Vegas Regional Team Spirit + SF (5012, 5851, 5049) / Galileo Subdivision
2015 - Inland Empire QF (597, 5012, 4413) / Las Vegas Imagery + Winners (148, 987, 5012) / Newton Subdivision and World Champions (118, 1678, 1671, 5012)
2014 - Inland Empire Rookie All Star + Highest Rookie Seed + SF (2339, 1967, 5012) / Las Vegas Rookie All Star / Galileo Division Imagery

Last edited by Jeremy Germita : 27-06-2011 at 02:15. Reason: forgot imports
  #3   Spotlight this post!  
Unread 28-06-2011, 22:24
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
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   Spotlight this post!  
Unread 28-06-2011, 22:45
Jogo Jogo is offline
Registered User
FRC #0353 (Pobots)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2007
Location: NY
Posts: 83
Jogo is on a distinguished road
Re: Joystick recording for Auton.

Wow, I love this idea. Would love to hear any results as far as repeatability goes.
  #5   Spotlight this post!  
Unread 02-07-2011, 22:09
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
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.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Closed Thread


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 18:50.

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