Iterative Project

Hello. Now that the season is over for my team I am trying to become more familiar with java for next year. I am starting to work with more sensors (IR, encoders, gyros, etc), vision processing, smart dashboard, and network tables more. I was wondering if anyone can post some iterative projects that i can look through to learn more about these things. It would be greatly appreciated. Thanks.

Hi:

Our team uses Java too. I don’t have access to the code right now, so I can’t share it, but is there a reason you’ve chosen ‘Iterative’ rather than ‘simple robot’?

In case you didn’t know, Iterative methods get called over and over again. This means you can’t use while loops. One thing to keep in mind is that Iterative uses less of the cRIO’s resources than Simple Robot. We know because we’ve used both this season! Simple Robot, as the name implies is more straight forward than iterative. The method gets called once, and you CAN use while loops…I prefer simple robot over iterative, but will most likely have to learn to love it because of the difference in system resource consumption.

Here’s come java for you:
while(!asleep){
sheep ++;
}

I understand what you are saying because of the experience i have with the two. I used simple last year and iterative this year. I leaned a lot with simple then decided to start iterative. Now I want to learn sensors and vision processing in the off season for iterative and use Command Base next year. Im starting from the basic and going to the advanced.

Personally, I’ve had bad experiences with CommandBase. Things never really worked out and I found it very messy with all the commands scattered around. (Especially in C++)

Here is a link to one of my more recent copies of the code. Vision processing is done on the DS with RoboRealm which I find far superior to OpenCV since it can be tweaked almost instantaneously. Not all the comments are up-to-date, so some parts may be confusing. Also, our drivetrain motors this year are reversed for some reason. (I’m just a programmer so swapping signs worked. :)) This is my first year with Java and any constructive criticism is greatly appreciated. :slight_smile:

Thank you

Im curious about something with your vision tracking. At the MAR event you guys needed the older axis camera. What was the difference between the old one and the new one when using robo realm? Good luck at St Louis.

We needed the older one mainly because the FOV was different. Unfortunately no one had the Axis 206 so we borrowed an Axis m1011 instead. Because of a different FOV, our distance calculations were slightly off which meant that I had to redo our formula for aiming.

Ok. Thanks again and good luck with your competition.

I have a question about simple project. I was messing around with it and how do you start stuff when the robot is initialized. Kind of like how iterative has RobotInit, TeleopInit, and AutonomousInit. Does the simple robot project have something like this?

SimpleRobot leaves it up to the programmer to determine how to structure things. The most common way is to put your own while loop in operatorControl. Anything before the while loop is run at the beginning, just like TeleopInit. See The "Hello world" of FRC robot programming | Getting started with Java | 2014 FRC Control System

Do I just put the Drive system in the while loop to update it or everything.

Yes.

The standard usage of Simple Robot is something like this:


public OperatorControl(){
   while (isOperatorControl() and isEnabled()){
    try {
         Thread.sleep(10L);
    } catch (Exception e){
       e.printStackTrace();
    }
   //insert code here, to be called every time through the while loop
   }
}

Ok thanks i will start working on this more

IterativeRobot should be used because of its usage data reporting and management. Using SimpleRobot for anything else than custom robot structures really shouldn’t be used. Using thread sleeps shouldn’t really be needed because IterativeRobot waits for new data from the robot which is the only time data should really need to be processed.

I’d also recommend looking into Command-based, it may look hard at first but once you get the hang of it its so much neater and easier to write.