Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Scenarios for Learning Java (http://www.chiefdelphi.com/forums/showthread.php?t=129330)

dmaciel10123 05-05-2014 09:33

Scenarios for Learning Java
 
Hi guys. I'm posting this thread to ask for some robot scenarios to program. I'm doing this because I'm experienced with Java but have not worked with it in FRC. My team primarily uses LabVIEW, but I would like to learn to work with Java and C++ as well. I may also use some of the scenarios you provide to help teach other programmers from my team who also wish to learn to work with these languages. I'll probably work with the 2013 version of the FRC libraries so I can use jRIO to test.

Edit: when I say scenarios I mean list different actuators, sensors, and functions that the robot would use.

notmattlythgoe 06-05-2014 07:39

Re: Scenarios for Learning Java
 
Quote:

Originally Posted by dmaciel10123 (Post 1382749)
Hi guys. I'm posting this thread to ask for some robot scenarios to program. I'm doing this because I'm experienced with Java but have not worked with it in FRC. My team primarily uses LabVIEW, but I would like to learn to work with Java and C++ as well. I may also use some of the scenarios you provide to help teach other programmers from my team who also wish to learn to work with these languages. I'll probably work with the 2013 version of the FRC libraries so I can use jRIO to test.

Edit: when I say scenarios I mean list different actuators, sensors, and functions that the robot would use.

I'd say the beat one to start with is write a drive train. And having a complete robot to work with, reprogram the robot in java would be another good tool.

Cel Skeggs 07-05-2014 20:56

Re: Scenarios for Learning Java
 
Quote:

Originally Posted by dmaciel10123 (Post 1382749)
Hi guys. I'm posting this thread to ask for some robot scenarios to program. I'm doing this because I'm experienced with Java but have not worked with it in FRC. My team primarily uses LabVIEW, but I would like to learn to work with Java and C++ as well. I may also use some of the scenarios you provide to help teach other programmers from my team who also wish to learn to work with these languages. I'll probably work with the 2013 version of the FRC libraries so I can use jRIO to test.

Edit: when I say scenarios I mean list different actuators, sensors, and functions that the robot would use.

Ideas for what your code could control:
  1. Drive Code (as notmattlythgoe suggested)
  2. Shifting Code
  3. Some sort of collector
  4. A pneumatic actuator (perhaps an Arm)
  5. Autonomous modes - drive forward, 1 ball, 2 ball, 3 ball
  6. Kid Mode for Drive Code (for robot demos - pretty much a quick way to set the robot to drive slower so that kids can drive it)
  7. Kinect control for Autonomous
  8. Compressor status & pressure sensor readouts
  9. A shooting mechanism, probably based on whatever your team used this year.

If you can do all of that, you can program most of what a robot might require.

NWChen 07-05-2014 23:28

Re: Scenarios for Learning Java
 
Everything said before, and some:

JesseK 08-05-2014 08:03

Re: Scenarios for Learning Java
 
You wouldn't have to use Java at all on the robot to use it for the driver's station. There are some pretty nifty things you can do with data from the robot during the build season and during the competition season.

sthreet 09-05-2014 16:24

Re: Scenarios for Learning Java
 
Quote:

Originally Posted by JesseK (Post 1383720)
You wouldn't have to use Java at all on the robot to use it for the driver's station. There are some pretty nifty things you can do with data from the robot during the build season and during the competition season.

Is it alright if I ask how one language can communicate with another directly? I mean, I could make a file of some sort (txt?) and get the data from it, if both languages supported that, but something that would work better in realtime?

Cel Skeggs 10-05-2014 01:51

Re: Scenarios for Learning Java
 
Quote:

Originally Posted by sthreet (Post 1384134)
Is it alright if I ask how one language can communicate with another directly? I mean, I could make a file of some sort (txt?) and get the data from it, if both languages supported that, but something that would work better in realtime?

You can usually use TCP sockets to communicate between devices in general, and pretty much all modern languages support sockets.

Alternatively, you could use an existing protocol written on top of sockets, such as NetworkTables (comes with FRC robots and usable from at least C++ or Java, although there may be a LabVIEW interface as well) or a team's released network communication library (My team, for example, wrote an open source communication framework, although that's only in Java. I'm sure that you can find some others if you look through the code releases from various teams that have been popping up in the various Programming forums here.)

JesseK 10-05-2014 13:12

Re: Scenarios for Learning Java
 
Quote:

Originally Posted by sthreet (Post 1384134)
Is it alright if I ask how one language can communicate with another directly? I mean, I could make a file of some sort (txt?) and get the data from it, if both languages supported that, but something that would work better in realtime?

A byte is a byte is a byte, regardless of language.

Say you have an array of 14 Floats (have no idea why you'd have 14 of them in FRC). C++ has a way to cast/interpret all 14 floats into an array of bytes. Java has a way to cast/interpret the bytes to Floats. You can do this all yourself (faster to implement from scratch, doesn't depend on 'flavor of the month' frameworks, often easier to increase performance) or use something like Google protobufs (easier to understand and add new features, once you understand the framework).

Some frameworks even support sending a method call with parameters across the socket between multiple languages - such as CORBA and Java RMI. However in FRC this usually isn't necessary. Our messages are is a byte array of (1)An integer which identifies how to decode the byte array (message id that, when converted to hex, usually states what the message is - 0x60B0760 = 'Go Bot Go', i.e. the HOT message) (2) An integer which is the Message length - useful for custom generic messages where the id changes based upon bit flags so that bandwidth can be saved when necessary and (3) the rest of the message. The rest of the message is an array of bytes, and each 'float' or 'int' in the array is always a 4-byte value (i.e. no doubles or longs).

Our team tried the SmartDashboard & NetworkTables in 2012 for a few things, but it wasn't working out for what we wanted. That year and every year since, we have implemented our own network code. From what I hear, it's wonky and was somewhat unreliable (we still don't reliably get a message from the D/S to the robot without killing the robot...) so we won't open-source it. Next year, we have plan to evaluate alternative approaches.


All times are GMT -5. The time now is 22:40.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi