how to cancel when volunteering for first (frc/ftc/fll)

A friend asked me how to switch from one volunteer event to another on firstinpires.org. It isn’t intuitive at all.

The answer:

  1. Logon to firstinspires.org
  2. Click “My dashboard”

If you were already assigned to the role

  1. Expand “assigned event volunteer roles”
  2. Click “Role options” pull down
  3. Click message coordinator and write a message that switched to Saturday

If you were not yet  assigned to the role

  1. Expand “pending applications”
  2. Click “Role options” pull down
  3. Click “withdraw application”
  4. Click “withdraw”
  5. Hope it worked. The role still appears in your list so you aren’t automatically withdrawn (not great usability)

first impressions of VS Code (visual studio code)

FIRST Robotics is using VS (Visual Studio) Code as the default IDE next year so I’ve developed a sudden interest in learning it :).

My overall impressions

It is much faster to get started with VS (Visual Studio) Code than Eclipse. And for the simplified use cases for FIRST robotics this makes sense.

Initial install

I installed it about two months ago. That was easy. I went to the website and downloaded. I didn’t have time to do anything then so my only experience was when I double clicked a .java file when preparing for my QCon Java 11 presentation. It’s a nice editor so cool that it opened out of the box. Not so cool that it changed my defaults for opening files without telling me.

Also nice that VS Code prompts with a suggestion to install the Java extension pack when I opened the Java file.

Upgrading

Since I didn’t do anything, the first order of business was to upgrade to the latest version. VS Code makes this easy. One  a Mac, you go to code > check for updates. It downloads quietly in the background. Then you go back to Code and choose restart to download.

Like Eclipse, the release notes automatically open. However, since I’m completely new to the tool, everything is new to me so I didn’t read it.

Plugins

The FIRST website suggests some plugins. To start with, I installed:

  • Java extension pack – includes the plugin for Maven
  • C++
  • WPILib – this is a custom download (vs being part of marketplace at this time).

I like that it uses a Marketplace like Eclipse. I also like that you just click “reload” to have the downloaded plugins take effect (rather than having to restart the whole IDE). I also like that the extensions menu has an install from VSIX option. Really easy to install a plugin that you downloaded from the internet.

I’ll install more plugins after getting the lay of the land.

Documentation

The VS Code getting started is good. I like that it includes the keyboard shortcuts for opening the command palette.

  • shift+command+P = mac
  • shift+ctrl+P = windows

It was harder to find the windows keyboard shortcuts than expected. The website help “knows” I’m on a Mac so tells me about the Mac ones. But I’m going to be helping students on multiple operating systems. (It was clear in the FIRST robotics docs, but I would have liked this to be clear on the Microsoft website as well)

Creating a first project

I used the WPI wizard to create a new project. It was easy to use and fast. The file structure is standard for a Gradle project so it felt familiar. I opened the Robot.java file and tried to make a change. Then VS Code started “downloading the internet.” This is also normal for Gradle. I was just expecting it to happen on file creation or first build rather than when I pressed ctrl+space for autocomplete.

I like that you can use the command palette to run commands without having to use the mouse or memorize a lot of keyboard shortcuts.

Playing a little

Many of the keyboard shortcuts are standard so autocomplete and closing tabs works as expected. If a file has warnings it (and the package name) are in green. Similarly, errors are in red. I imagine this is customizable if someone is red/green colorblind. I’m surprised the defaults are ones where this is a problem.

How to open multiple projects

I immediately wanted to compare two projects in the same workspace. This is easy. You go to file > add folder to workspace. This creates a “multi root” project.

 

building motion profile generator with gradle and/or eclipse

Last year, I blogged about how to build Smart Dashboard with Gradle for FRC. Today, a student asked me how to build Motion Profile Generator using gradle. It’s similar, but seemed like a good time to update the post for this specific project.

You can use pure command line when reading/following this. Alternatively, you can use Eclipse as little or as much as you like. I include the Eclipse “gotchas.” (Spoiler: It’s faster to just use the command line)

Pulling from git

You can pull the code from git in any way you’d like. Common ways are:

  • From the command line (or git bash): git clone https://github.com/vannaka/Motion_Profile_Generator.git
  • From Eclipse, go to the git perspective, and paste in the URL.
  • Download the project from github as a zip file. (Please don’t choose this option. It is better to use git properly. The only reason I’ve ever done the zip option is if I need to look at a code on a computer where I can’t install anything.)

Running Gradle at the command line

The discussion was centered around building Motion Profile Generator. If you aren’t involved with a FIRST Robotics Competition team, this is used to help with autonomous programming. As with many Gradle projects, the project comes with Gradle right in the project. So all you have to is:

  1. cd to directory you cloned Motion Profile Generator in
  2. chmod 700 gradlew
  3. ./gradlew build

Make sure you have internet before running this the first time. If you want to build directly from Eclipse, see my Eclipse Gradle post and skip to the BuildShip section.

Where is the output when building SmartDashboard?

Running gradle creates a build directory. You can look at it on the file system. Or if you are using Eclipse,

  1. Configure the filters so show the Gradle build folder
  2. Add/remove the JRE library as described here to get rid of the Eclipse errors about access restrictions.
  3. Hit refresh before looking for it.

I don’t care how gradle works, I just want to run the program!

No  worries. Just:

  1. cd build/libs
  2. java -jar Motion_Profile_Generator-v3.0.0.jar

Ok now I’m curious, what gets generated?

This build directory  contains a number of things:

  • distributions – a zipped up and tarred up version of Motion Profile Generator which includes the jar file, all need dependencies and the script to kick it off.
  • classes – the compiled .class files
  • libs – a jar file with the compiled code in this project
  • resources – the JavaFX file (user interface files)
  • scripts – to launch Motion Profile Generator
  • tmp – would you really expect to find something important in a directory named tmp?

What does the Gradle build file do?
Gradle is a build tool. The build.gradle file in Motion Profile Generator contains Groovy code that declares what the build should do. Both Gradle and Maven follow “convention over configuration” which means that a lot is implied! I went over most (but not all) of this out loud in the classroom.

A plugin is like a helper tool that Gradle is going to use in order to build. For example, ‘java’ is going to compile among other things.  Most of these plugins are in common use. Gradle needs to download files in order to run. This includes some default plugins. These files are hosted in a repository for binary files. A really common one is Maven Central. This is used by both Maven and Gradle builds to obtain binaries. This build file is really simple. It says that Gradle needs to know how to build a standalone java application.

plugins {
    id 'application'
    id 'java'
}

This tells Java to put some information in the manifest. In particular, which class should run automatically when you try to run the jar. It also includes a version number for reference.

mainClassName = "com.mammen.main.Main"
version = "v3.0.0"

Remember the convention over configuration thing I mentioned earlier? Convention says the source code is in the nested directories src/main/java. This project decided to put the source code directly in the src directory. Therefore the project needs to inform Gradle of this non-standard location.

sourceSets {
    main.java {
        srcDirs = ['src']; include '**/*.java'
    }

    main.resources {
        srcDirs = ['src']; exclude '**/*.java'
    }
}

Normally, Gradle projects include references to dependencies on the internet. This project decided to supply them directly in a lib directory. Again, a non-standard thing to inform Gradle about. (I think this decision is because Pathfinder has extra files)

dependencies {
    compile fileTree(dir: 'lib', include: '*.jar')
}

Next the script specifies that we should create a jar file and an uber jar file including the special files..

jar {
    from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
    // Set up manifest to point the main class to the right class.
    manifest {
        attributes 'Main-Class': mainClassName
        attributes 'Version': version
    }
	from ("lib/native_libs") {
		into ("")
	}
}

The end! The very last thing is to declare which version of Gradle this entire script should be run with.

task wrapper(type: Wrapper) {
    gradleVersion = '3.3'
}

Output from building in gradle

I’m including the output from a “good” run in case you have problems and want to compare. This is for the first time you run it. After that the download steps won’t be in the output and it will run much faster.

JeanneBrskysMBP:Motion_Profile_Generator nyjeanne$ ./gradlew build
Downloading https://services.gradle.org/distributions/gradle-4.7-bin.zip
.......................................................................

Welcome to Gradle 4.7!

Here are the highlights of this release:
 - Incremental annotation processing
 - JDK 10 support
 - Grouped non-interactive console logs
 - Failed tests are re-run first for quicker feedback

For more details see https://docs.gradle.org/4.7/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

> Task :compileJava
/Users/nyjeanne/git/Motion_Profile_Generator/src/com/mammen/main/ProfileGenerator.java:4: warning: OutputFormat is internal proprietary API and may be removed in a future release
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
                                                ^
/Users/nyjeanne/git/Motion_Profile_Generator/src/com/mammen/main/ProfileGenerator.java:5: warning: XMLSerializer is internal proprietary API and may be removed in a future release
import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
                                                ^
/Users/nyjeanne/git/Motion_Profile_Generator/src/com/mammen/main/ProfileGenerator.java:435: warning: OutputFormat is internal proprietary API and may be removed in a future release
            OutputFormat format = new OutputFormat(dom);
            ^
/Users/nyjeanne/git/Motion_Profile_Generator/src/com/mammen/main/ProfileGenerator.java:435: warning: OutputFormat is internal proprietary API and may be removed in a future release
            OutputFormat format = new OutputFormat(dom);
                                      ^
/Users/nyjeanne/git/Motion_Profile_Generator/src/com/mammen/main/ProfileGenerator.java:439: warning: XMLSerializer is internal proprietary API and may be removed in a future release
            XMLSerializer xmlSerializer = new XMLSerializer(
            ^
/Users/nyjeanne/git/Motion_Profile_Generator/src/com/mammen/main/ProfileGenerator.java:439: warning: XMLSerializer is internal proprietary API and may be removed in a future release
            XMLSerializer xmlSerializer = new XMLSerializer(
                                              ^
Note: /Users/nyjeanne/git/Motion_Profile_Generator/src/com/mammen/ui/javafx/MainUIController.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 warnings

BUILD SUCCESSFUL in 24s
6 actionable tasks: 6 executed