Installing FRCSim Manually (Mac OSX)
This guide shows how to install and test FRCSim on Mac OSX.
This only works for java!
Install Eclipse
Download and install the Mars version of Eclipse for Java developers. After installing, to start Eclipse open a Terminal and type:
eclipse
Install WPILib Eclipse Plugins
Install Homebrew
Unfortunately the one thing Mac OSX is missing is a package manager (e.g. Ubuntu apt-get). There are several open source package managers available, but I usually use Homebrew. The instructions can be found on the web but basically involves one simple command (provided you already have Ruby installed):
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install wget, unzip, and cmake
The UNIX command wget is handy for fetching content from the web. While there are alternatives on Mac, I prefer to install wget using Homebrew. We will also install unzip and cmake while we are at it.
brew install wget
brew install homebrew/dupes/unzip
brew install cmake
Install XQuartz
Gazebo uses UNIX X-Windows, and so you will need an open source version of X. XQuartz provides a version of X-Windows complete with a packaged Mac install.
Install Gazebo
Gazebo is your robot simulator. Using Homebrew to install Gazebo is as simple as:
brew tap osrf/simulation
brew install gazebo6
To verify it runs, execute the following command from Terminal after the install completes:
gazebo
Install Gazebo Plugins
WPI provides a prepackaged download of the worlds, models and plugins required to simulate robot samples from previous years. The download has a few Ubuntu specific components which we will address below. But let's start by getting it installed. First, browse to http://first.wpi.edu/FRC/roborio/maven/release/edu/wpi/first/wpilib/simulation/simulation/ and locate the latest release (2017.2.1 at the time of writing), click the folder and locate the .zip file, then right click and "Copy link location". You will use this link in place of "ZIP_URL" below.
cd ~/Downloads
wget ZIP_URL
mkdir ~/wpilib/simulation
unzip ~/Downloads/simulation-1.0.0.zip -d ~/wpilib/simulation
Building GZ Msgs
To compile and install gz_msgs for our platform, follow these steps:
cd ~/wpilib/simulation/gz_msgs
mkdir build
cd build
cmake ..
make install
I received a few compiler warnings on building that were safely ignored.
Install Sample Robot Models
These instructions directly parallel their Ubuntu equivalent.
cd ~/wpilib/simulation
wget -O models.zip https://usfirst.collab.net/sf/frs/do/downloadFile/projects.wpilib/frs.simulation.frcsim_gazebo_models/frs1160?dl=1
unzip models.zip
mv frcsim-gazebo-models-4/models ~/wpilib/simulation/
mv frcsim-gazebo-models-4/worlds ~/wpilib/simulation/
Build FRC Gazebo Plugins for Mac OSX
The plugins you unzipped to ~/wpilib/simulation/plugins are compiled for Ubuntu Linux. You will need to replace these with Mac versions.
Compiling your own versions
cd ~/wpilib/simulation
mkdir allwpilib
git clone https://usfirst.collab.net/gerrit/p/allwpilib.git
cd allwpilib
./gradlew -PmakeSim frc_gazebo_plugins
cp ~/wpilib/simulation/allwpilib/build/install/simulation/plugins/* ~/wpilib/simulation/plugins
Enable Joystick Controllers
If you have a game controller you'd like to use with your simulator, you will need the Mac OSX versions of the jinput.jar. You can do this by downloading the latest jinput build, and moving the files (jinput.jar, jinput-osx.jnilib, jinput-test.jar) into the ~/wpilib/simulation/lib directory. For example:
cp ~/Downloads/*jinput* ~/wpilib/simulation/lib
Add Simulation to the Default Path
You will find it convenient to have ~/wpilib/simulation in the path. To do this:
open ~/.bash_profile
Add the following line at the end of your bash_profile:
export PATH=$HOME/wpilib/simulation:$PATH
Save and reload your environment to ensure the current terminal has the right path:
source ~/.bash_profile
Test Simulator with GearsBot
Follow these steps to test the robot simulator using the GearsBot sample:
Edit the Model
The robot models you installed are unfortunately hard-coded to the Ubuntu plugins. To run a sample, you will need to perform a one-time edit to change the file names for the libraries. To do this for the GearsBot sample, use a text editor to edit the file ~/wpilib/simulation/models/GearsBot/model.sdf, and replace all ".so" references with ".dylib". This will ensure the model looks to the appropriate libraries.
Create an Eclipse Project
Start Eclipse:
eclipse
Click File -> New -> Other from the menu and type "robot" the search bar. Choose "Example Robot Project" and click Next, scroll to the bottom (CommandBased Robot), select "GearsBot" and click Next.
You will be asked for your team number, which it will use in your Java package path. Give the project a name (e.g. GearsBotTest) and click Finish.
Prevent the Fixed Plane Defect
There is a defect that will quite likely be fixed by the time you follow these instructions. In my case I was seeing the robot go below the fixed plane when run in autonomous mode (it didn't snap to the plane). But just in case, search your project for any reference to "usePIDOutput", and change all references of this:
protected void usePIDOutput(double d) {
motor.set(d);
}
to
protected void usePIDOutput(double d) {
if (!Double.isNaN(d)) {
motor.set(d);
}
}
Start FRCSim
Let's start the GearsBot world from a terminal:
cd ~/wpilib/simulation
./frcsim worlds/GearsBotDemo.world
Start the Driver Station
Let's start the Driver Station from another terminal:
cd ~/wpilib/simulation
./sim_ds
Run the Eclipse Project
Now let's get the GearsBot project working. From Eclipse click on Run -> Run and choose "WPILib Java Simulation" as your target. This will start the code and initiate communication between the Gazebo simulator and Driver Station.
You can test using autonomous mode by clicking on the Autonomous option in the Driver Station and clicking the Enable button.
If you have plugged in a game controller, you should also be able to enable Teleop mode to test manually driving around your sim world using your robot.

The wget command is not standard for OS X command line. OS X provides the similar command curl. Here is an easy way to add an alias for wget that uses curl: http://www.thecave.info/using-curl-as-a-wget-for-mac-replacement/
Follow with: source ~/.bash_profile
Ed Miller (mentor Team 955)