merged from frcsim branch

verified to work on real robots
adds sim eclipse plugins, fixed JavaGazebo, made wpilibC++Sim build on windows
 - Java and C++ simulation robot programs run on windows
 - simulation eclipse plugin delivers models and gazebo plugins
 - Java Gazebo now respects GAZEBO_IP variables and can work across networks
 - hal and network tables win32 hacked to work on windows
 - smart dashboard broken on windows due to network tables hacks
 - wpilibC++Sim, gz_msgs, and frcsim_gazebo_plugins build with CMake
 - removed constexpr for cross platform compatibility
 - msgs generated using .protos as a part of build process
 - some spare and unused cmake/pom files deleted
 - simulation ubuntu debians removed entirely
 - refactored CMake project flags and macros
 - updated to match non-sim C++ API
 - fixed and updated documentation
 - servo added to simulation

Change-Id: Ia702ff0f1fee10d77f543810ad88f56696443b05
This commit is contained in:
peter mitrano
2015-04-26 19:19:57 -04:00
parent 4e46692191
commit 29d029fa61
211 changed files with 2143 additions and 6491 deletions

View File

@@ -1,6 +1,8 @@
package edu.wpi.first.wpilib.plugins.core.installer;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -45,7 +47,38 @@ public abstract class AbstractInstaller {
*/
protected abstract InputStream getInstallResourceStream();
public void installIfNecessary() {
/**
*
* @param sourcePath the file location of the zip file EX "/resources/simuation.zip"
* @param destinationPath the file location to unzip into EX "/home/peter/wpilib/simulation/plugins"
*/
public void installIfNecessary(String sourcePath, String destinationPath){
//we're installing from this directory
InputStream sourceStream;
try {
sourceStream = new FileInputStream(sourcePath);
File destFile = new File(destinationPath);
installIfNecessary(sourceStream, destFile);
} catch (FileNotFoundException e) {
WPILibCore.logInfo("source zip file was not found: "+sourcePath);
}
}
/**
* This function will delete an old wpilib subfolder if necessary and then copy
* the resource stream to the intended directory.
*
* @throws InstallException if bad things happen ...
*/
public void installIfNecessary(){
installIfNecessary(getInstallResourceStream(), installLocation);
}
/**
* I'm thinking maybe instead of final things,
* create a UnzipJob class to extend Job and have these as parameters to the constructor*
*/
public void installIfNecessary(final InputStream sourceStream,final File destination) {
final Job installJob = new Job("Install " + getFeatureName()) {
@Override
@@ -56,14 +89,14 @@ public abstract class AbstractInstaller {
if (!isInstalled()) {
WPILibCore.logInfo("Install necessary for " + getFeatureName());
try {
install();
install(sourceStream,destination);
} catch (InstallException e) {
WPILibCore.logError("Error installing "+getFeatureName(), e);
return new Status(IStatus.ERROR, WPILibCore.PLUGIN_ID,
getErrorMessage(e));
}
}
updateInstalledVersion(version);
WPILibCore.logInfo("Installed" + getFeatureName());
@@ -98,6 +131,7 @@ public abstract class AbstractInstaller {
}
/**
*
* This function has been updated to guarantee that the wpilib folder date
* is older than the jar file being run, which ensures up to date tools.
*
@@ -108,38 +142,41 @@ public abstract class AbstractInstaller {
}
/**
* This function will delete an old wpilib subfolder if necessary and then copy
* the resource stream to the intended directory.
*
* @throws InstallException if bad things happen ...
* @TODO this function is very long and complicated. If all it does is unzip, it shouldn't be so hard.
*
* @param sourceStream input stream of zip file
* @param destination desired location for output of unzipping
* @throws InstallException
*/
protected void install() throws InstallException {
if(installLocation.exists()) {
if(!removeFileHandler(installLocation, true)) {
protected void install(InputStream sourceStream, File destination) throws InstallException {
if(destination.exists()) {
if(!removeFileHandler(destination, true)) {
MessageDialog.openError(null, "Error",
String.format("Could not update the old wpilib folder.%n"
+ "Please close any WPILib tools and restart Eclipse."));
}
//removeFileHandler(installLocation, false);
}
installLocation.mkdirs();
destination.mkdirs();
final String osName = System.getProperty("os.name");
try {
if (osName.startsWith("Mac OS X") || osName.startsWith("Linux")) { // Unix-like OSes must preserve the executable bit; call unzip
// Unix-like OSes must preserve the executable bit; call unzip
if (osName.startsWith("Mac OS X") || osName.startsWith("Linux")) {
final File tmpFile = File.createTempFile(getFeatureName()+"-", ".zip");
try {
// Copy to temporary file
try (final InputStream zip = getInstallResourceStream();
try (final InputStream zip = sourceStream;
final FileOutputStream fout = new FileOutputStream(tmpFile)) {
copyStreams(zip, fout);
}
// Call 'unzip'
final String[] cmd = {"unzip" , "-o", tmpFile.getAbsolutePath(), "-d", installLocation.getAbsolutePath()};
WPILibCore.logInfo("unzip "+tmpFile.getAbsolutePath()+" -d "+installLocation.getAbsolutePath());
final Process unzipProcess = DebugPlugin.exec(cmd, installLocation);
final String[] cmd = {"unzip", "-q", "-o", tmpFile.getAbsolutePath(), "-d", destination.getAbsolutePath()};
WPILibCore.logInfo("unzip "+tmpFile.getAbsolutePath()+" -d "+destination.getAbsolutePath());
final Process unzipProcess = DebugPlugin.exec(cmd, destination);
try (final InputStream is = unzipProcess.getInputStream()) {
copyStreams(is, System.out); // Copy output to console
}
@@ -153,11 +190,11 @@ public abstract class AbstractInstaller {
tmpFile.delete();
}
} else {
ZipInputStream zip = new ZipInputStream(getInstallResourceStream());
ZipInputStream zip = new ZipInputStream(sourceStream);
ZipEntry entry = zip.getNextEntry();
while (entry != null) {
WPILibCore.logInfo("\tZipEntry " + entry + ": " + entry.getSize());
File f = new File(installLocation, entry.getName());
File f = new File(destination, entry.getName());
if (entry.isDirectory()) {
f.mkdirs();
} else {
@@ -176,6 +213,7 @@ public abstract class AbstractInstaller {
}
}
private static void copyStreams(InputStream source, OutputStream destination) throws IOException {
byte[] buffer = new byte[1024];
int len;

View File

@@ -3,6 +3,7 @@ package edu.wpi.first.wpilib.plugins.core.launching;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.lang.System;
import java.net.URI;
import java.net.URISyntaxException;
@@ -15,7 +16,7 @@ import edu.wpi.first.wpilib.plugins.core.WPILibCore;
public class SimulationNotification {
private static final String URL = "https://wpilib.screenstepslive.com/s/4485/m/23353";
private static final String SIMULATION_UNSUPPORTED_MSG =
"Simulation is unsupported on your current setup.\n" +
"Simulation may not be support on your operating system.\n" +
"For more information see: " + URL;
public static void showUnsupported() {
@@ -32,12 +33,8 @@ public class SimulationNotification {
}
public static boolean supportsSimulation() {
String[] cmd = {"frcsim", "--version"};
try {
DebugPlugin.exec(cmd, new File(System.getProperty("user.home")));
return true;
} catch (CoreException e) {
return false;
}
String os = System.getProperty("os.name");
//for now this is good enough, but we still need better handling if they have this OS but have not installed FRCSim
return (os.equals("Windows 8") || os.equals("Windows 7") || os.equals("Linux") || os.equals("Windows 8.1"));
}
}