Initial commit of the WPILib simulation support in an alpha quality state.

Fixes to deal with the switch to .hpp files in the HAL and other misc problems due to rebasing.

Added Omar's changes to the compressor interface

Fixes to make C++ plugin compile on linux.

Added import of the WPILibSim code from the graduate class. It shows up as wpilibJavaSim to follow the convention set by wpilibJava, wpilibJavaJNI and wpilibJavaFinal.

Fixed wpilibJavaSim artifactId to mirror the new convention.

Modified the build of the java plugin to pull in the simulation dependencies.

Added stacktrace printing.

Fixed support for creating projects.

Added support for the isReal() and isSimulation() methods along with the AnalogPotentiometer object to support simulating GearsBot.

Added support for a "WPILib Simulate" button.

Added GearsBot to the built in examples.

Added support for specifying the world file during project creation and switched the default from BluntObjectBot to GearsBot.

Removed unused import.

Added file browser for world files.

Added support for debugging in simulation.

Change simulate icon to be a Gazebo icon.

Switched over to the gazebo messaging system.

Updated location of default world file.

Reverted cmake change.

Fixed bug in WPILibJSim, added better logging and cleaned up code.

Made the frc_gazebo_plugin build using raw cmake instead of catkin, breaking the final ROS dependencies.

Added installation to frc_gazebo_plugin Makefile.

Fixed running of simulation to actually use frcsim.

Initial commit of simulation library for C++. Has the minimal subset of features necessary for having a Simple Robot run in teleoperated mode.

Added notes for generating protobuf messages.

Import of the debuild process into the main repository.

Moved frc_gazebo_plugin under simulation and removed the gazebo folder.

Updated the gazebo plugin to remove excessive printing and limit motor signal to [-1,1].

Updated WPILibJSim to support latching messages and to sleep for 20ms in iterative robot.

Reduced delay between starting frcsim and the users program to 1 second.

Updated GearsBot example.

Fixed a few minor issues for demoable state.

Added simulator support for Victors, Jaguars and Talons.

Added NetworkTables, SmartDashboard and LiveWindow to the simulator.

Added AnalogPotentiometer for simulation.

Added support for simulating encoders.

Added simulation support for Gyro.

Added IterativeRobot, Fixed Timers, Notifiers, PIDControllers and other minor fixes + cleanup.

Added RobotDrive support to simulation.

Separated out JavaGazebo so that SimDS will be able to reuse it.

Separated out SimDS into its own application..

Fixes so that the SimDS is distributed and runs properly for Java with the eclipse plugins.

Added DriverStation support to WPILibCSim

Cleanup of DriverStation, WaitUntilCommand and AnalogPotentiometer for WPILibCSim.

Cleanup of includes for WPILibCSim

Added AnalogPotentiometer to the real WPILibC.

Added AnalogPotentiometer to the real WPILibC.

Added GearsBot example to C++ eclipse plugin.

WPILibCSim fixes to work with launching from the plugin.

Package libwpilibsim in a deb file.

Added includes to plugin distribution.

Added support for external-limit-switches to Gazebo, Java and C++.

Added support for Gazebo Rangefinders and Analog channels to read their values in C++ and Java.

Added support for internal limit switches.

Updated GearsBot programs to use limit switches + range finders.

Added disabling of motors when robot is disabled to more closely mimic the real robot.

Fixes to deal with the switch to .hpp files in the HAL and other misc problems due to rebasing.

Change-Id: I624c5f4d0f28282616a7c92083575bf68adcdce2
This commit is contained in:
Alex Henning
2014-06-12 11:02:26 -07:00
committed by thomasclark
parent d5a509c7e7
commit cb56c9a144
425 changed files with 38450 additions and 335 deletions

View File

@@ -73,6 +73,7 @@ public class WPILibJavaPlugin extends AbstractUIPlugin implements IStartup {
return props.getProperty("version");
}
} catch (CoreException e) {
e.printStackTrace(System.err);
return "DEVELOPMENT";
}
}

View File

@@ -1,39 +1,6 @@
package edu.wpi.first.wpilib.plugins.java.launching;
import java.io.File;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import org.eclipse.core.internal.resources.Resource;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.ILaunchShortcut;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IVMConnector;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
import com.sun.jdi.connect.Connector.Argument;
import edu.wpi.first.wpilib.plugins.core.WPILibCore;
import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher;
/**
* Launch shortcut base functionality, common for deploying to the robot.
@@ -43,58 +10,7 @@ import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher;
* @author Ryan O'Meara
* @author Alex Henning
*/
@SuppressWarnings("restriction")
public class DeployLaunchShortcut implements ILaunchShortcut {
//Class constants - used to delineate types for launch shortcuts
public static final String DEPLOY_TYPE = "edu.wpi.first.wpilib.plugins.core.deploy";
private static final String ANT_SERVER_THREAD_NAME = "Ant Build Server Connection";
// NOTE: This string must be changed if the port is changed.
private static final String DEBUG_START_TEXT = "Listening for transport dt_socket at address: 8348";
private static ILaunch lastDeploy = null;
/**
* Returns the launch type of the shortcut that was used, one of the constants
* defined in BaseLaunchShortcut
* @return Launch shortcut type
*/
public String getLaunchType() {return DEPLOY_TYPE;}
@Override
public void launch(ISelection selection, String mode) {
//Extract resource from selection
StructuredSelection sel = (StructuredSelection)selection;
IProject activeProject = null;
//NOTE: This caused issues earlier, as the sel return was treated as a workspace, instead of a project
//When it is a valid FIRST project, the selection is always a JavaProject
if(sel.getFirstElement() instanceof IJavaProject){
activeProject = ((IJavaProject)sel.getFirstElement()).getProject();
}else if(sel.getFirstElement() instanceof IJavaElement){
activeProject = ((IJavaElement)sel.getFirstElement()).getJavaProject().getProject();
}else{
return;
}
//Run config using project found in extracted resource, with indicated mode
runConfig(activeProject, mode);
}
@Override
public void launch(IEditorPart editor, String mode) {
//Extract resource from editor
if(editor != null){
IFileEditorInput input = (IFileEditorInput)editor.getEditorInput();
IFile file = input.getFile();
IProject activeProject = file.getProject();
//If editor existed, run config using extracted resource in indicated mode
runConfig(activeProject, mode);
}else{
System.err.println("editor was null");
}
}
public class DeployLaunchShortcut extends JavaLaunchShortcut {
/**
* Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile)
@@ -102,106 +18,7 @@ public class DeployLaunchShortcut implements ILaunchShortcut {
* @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE)
*/
public void runConfig(IProject activeProj, String mode){
String targets = "deploy";
if(mode.equals(ILaunchManager.RUN_MODE)){
if(getLaunchType().equals(DEPLOY_TYPE)){
targets = "deploy";
}
} else if ((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) {
targets = "debug-deploy";
try{
PlatformUI.getWorkbench().showPerspective(IDebugUIConstants.ID_DEBUG_PERSPECTIVE,
PlatformUI.getWorkbench().getActiveWorkbenchWindow());
}catch(Exception e){}
}
if((lastDeploy != null)&&(!lastDeploy.isTerminated())){
System.out.println("Last deploy running");
//Find the server connection thread and kill it
Vector<ThreadGroup> threadGroups = new Vector<ThreadGroup>();
ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
while (root.getParent() != null) {root = root.getParent();}
threadGroups.add(root);
ThreadGroup threadGroup = threadGroups.remove(0);
int numThreads = threadGroup.activeCount();
Thread[] threads = new Thread[numThreads*100];
numThreads = threadGroup.enumerate(threads, true);
for(Thread current: threads){
if(current != null){
if(current.getName().equals(ANT_SERVER_THREAD_NAME)){
try{
//Manually end thread and then try terminating launch
Method stopMethod = current.getClass().getMethod("stop");
stopMethod.invoke(current);
lastDeploy.terminate();
break;
}catch(Exception e){e.printStackTrace();}
}
}
}
System.out.println("Waiting");
try{wait(1000);}catch(Exception e){}
}
System.out.println("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml");
System.out.println("Targets: " + targets + ", Mode: " + mode);
lastDeploy = AntLauncher.runAntFile(new File (activeProj.getLocation().toOSString() + File.separator + "build.xml"), targets, null, mode);
if((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) {
ILaunchConfigurationWorkingCopy config;
try {
config = getRemoteDebugConfig(activeProj);
startDebugConfig(config, lastDeploy);
} catch (CoreException e) {
System.err.println("Debug attach failed.");
e.printStackTrace();
}
}
try {
activeProj.refreshLocal(Resource.DEPTH_INFINITE, null);
} catch (Exception e) {}
}
private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException {
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION);
ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName());
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName());
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, true);
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR);
IVMConnector connector = JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR);
Map<String, Argument> def = connector.getDefaultArguments();
Map<String, String> argMap = new HashMap<String, String>(def.size());
argMap.put("hostname", WPILibCore.getDefault().getTargetIP(activeProj));
argMap.put("port", "8348");
System.out.println(argMap);
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, argMap);
return config;
}
private void startDebugConfig(final ILaunchConfigurationWorkingCopy config, ILaunch deploy) throws CoreException {
IStreamListener listener = new IStreamListener() {
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
if (text.contains(DEBUG_START_TEXT)) {
try {
config.launch(ILaunchManager.DEBUG_MODE, null);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
monitor.removeListener(this);
}
}
};
deploy.getProcesses()[0].getStreamsProxy().getOutputStreamMonitor().addListener(listener);
runConfigHelper(activeProj, mode, "deploy", "debug-deploy");
}
}

View File

@@ -0,0 +1,208 @@
package edu.wpi.first.wpilib.plugins.java.launching;
import java.io.File;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import org.eclipse.core.internal.resources.Resource;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.ILaunchShortcut;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IVMConnector;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
import com.sun.jdi.connect.Connector.Argument;
import edu.wpi.first.wpilib.plugins.core.WPILibCore;
import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher;
@SuppressWarnings("restriction")
public abstract class JavaLaunchShortcut implements ILaunchShortcut {
//Class constants - used to delineate types for launch shortcuts
public static final String DEPLOY_TYPE = "edu.wpi.first.wpilib.plugins.core.deploy";
private static final String ANT_SERVER_THREAD_NAME = "Ant Build Server Connection";
// NOTE: This string must be changed if the port is changed.
private static final String DEBUG_START_TEXT = "Listening for transport dt_socket at address: 8348";
private static ILaunch lastDeploy = null;
/**
* Returns the launch type of the shortcut that was used, one of the constants
* defined in BaseLaunchShortcut
* @return Launch shortcut type
*/
public String getLaunchType() {return DEPLOY_TYPE;}
public void launch(ISelection selection, String mode) {
//Extract resource from selection
StructuredSelection sel = (StructuredSelection)selection;
IProject activeProject = null;
//NOTE: This caused issues earlier, as the sel return was treated as a workspace, instead of a project
//When it is a valid FIRST project, the selection is always a JavaProject
if(sel.getFirstElement() instanceof IJavaProject){
activeProject = ((IJavaProject)sel.getFirstElement()).getProject();
}else if(sel.getFirstElement() instanceof IJavaElement){
activeProject = ((IJavaElement)sel.getFirstElement()).getJavaProject().getProject();
}else{
return;
}
//Run config using project found in extracted resource, with indicated mode
runConfig(activeProject, mode);
}
@Override
public void launch(IEditorPart editor, String mode) {
//Extract resource from editor
if(editor != null){
IFileEditorInput input = (IFileEditorInput)editor.getEditorInput();
IFile file = input.getFile();
IProject activeProject = file.getProject();
//If editor existed, run config using extracted resource in indicated mode
runConfig(activeProject, mode);
}else{
System.err.println("editor was null");
}
}
/**
* Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile)
* @param activeProj The project that the script will be run on/from
* @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE)
* @return
*/
public abstract void runConfig(IProject activeProj, String mode);
/**
* Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile)
* @param activeProj The project that the script will be run on/from
* @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE)
*/
protected void runConfigHelper(IProject activeProj, String mode, String runTarget, String debugTarget){
String targets = runTarget;
if(mode.equals(ILaunchManager.RUN_MODE)){
if(getLaunchType().equals(DEPLOY_TYPE)){
targets = runTarget;
}
} else if ((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) {
targets = debugTarget;
try{
PlatformUI.getWorkbench().showPerspective(IDebugUIConstants.ID_DEBUG_PERSPECTIVE,
PlatformUI.getWorkbench().getActiveWorkbenchWindow());
}catch(Exception e){}
}
if((lastDeploy != null)&&(!lastDeploy.isTerminated())){
System.out.println("Last deploy running");
//Find the server connection thread and kill it
Vector<ThreadGroup> threadGroups = new Vector<ThreadGroup>();
ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
while (root.getParent() != null) {root = root.getParent();}
threadGroups.add(root);
ThreadGroup threadGroup = threadGroups.remove(0);
int numThreads = threadGroup.activeCount();
Thread[] threads = new Thread[numThreads*100];
numThreads = threadGroup.enumerate(threads, true);
for(Thread current: threads){
if(current != null){
if(current.getName().equals(ANT_SERVER_THREAD_NAME)){
try{
//Manually end thread and then try terminating launch
Method stopMethod = current.getClass().getMethod("stop");
stopMethod.invoke(current);
lastDeploy.terminate();
break;
}catch(Exception e){e.printStackTrace();}
}
}
}
System.out.println("Waiting");
try{wait(1000);}catch(Exception e){}
}
System.out.println("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml");
System.out.println("Targets: " + targets + ", Mode: " + mode);
lastDeploy = AntLauncher.runAntFile(new File (activeProj.getLocation().toOSString() + File.separator + "build.xml"), targets, null, mode);
if((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) {
ILaunchConfigurationWorkingCopy config;
try {
config = getRemoteDebugConfig(activeProj);
startDebugConfig(config, lastDeploy);
} catch (CoreException e) {
System.err.println("Debug attach failed.");
e.printStackTrace();
}
}
try {
activeProj.refreshLocal(Resource.DEPTH_INFINITE, null);
} catch (Exception e) {}
}
private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException {
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION);
ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName());
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName());
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, true);
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR);
IVMConnector connector = JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR);
Map<String, Argument> def = connector.getDefaultArguments();
Map<String, String> argMap = new HashMap<String, String>(def.size());
argMap.put("hostname", getHostname(activeProj));
argMap.put("port", "8348");
System.out.println(argMap);
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, argMap);
return config;
}
protected String getHostname(IProject proj) {
return WPILibCore.getDefault().getTargetIP(proj);
}
private void startDebugConfig(final ILaunchConfigurationWorkingCopy config, ILaunch deploy) throws CoreException {
IStreamListener listener = new IStreamListener() {
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
if (text.contains(DEBUG_START_TEXT)) {
try {
config.launch(ILaunchManager.DEBUG_MODE, null);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
monitor.removeListener(this);
}
}
};
deploy.getProcesses()[0].getStreamsProxy().getOutputStreamMonitor().addListener(listener);
}
}

View File

@@ -0,0 +1,20 @@
package edu.wpi.first.wpilib.plugins.java.launching;
import org.eclipse.core.resources.IProject;
public class SimulateLaunchShortcut extends JavaLaunchShortcut {
/**
* Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile)
* @param activeProj The project that the script will be run on/from
* @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE)
*/
public void runConfig(IProject activeProj, String mode){
runConfigHelper(activeProj, mode, "simulate", "debug-simulate");
}
protected String getHostname(IProject proj) {
return "localhost";
}
}

View File

@@ -35,7 +35,8 @@ public class ExampleJavaWizard extends ExampleWizard {
final String projectName = detailsPage.getProjectName();
final String packageName = detailsPage.getPackage();
ProjectCreationUtils.createProject(new WPIRobotJavaProjectCreator(projectName, packageName, ex));
final String worldName = detailsPage.getWorld();
ProjectCreationUtils.createProject(new WPIRobotJavaProjectCreator(projectName, packageName, ex, worldName));
}
@Override

View File

@@ -72,11 +72,12 @@ public class NewJavaWizard extends Wizard implements INewWizard {
final String teamNumber = TeamNumberPage.getTeamNumberFromPage(teamNumberPage);
final String packageName = page.getPackage();
final ProjectType projectType = page.getProjectType();
final String worldName = page.getWorld();
System.out.println("Project: "+projectName+" Package: "+packageName+" Project Type: "+projectType);
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
doFinish(projectName, teamNumber, packageName, projectType, monitor);
doFinish(projectName, teamNumber, packageName, projectType, worldName, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
} finally {
@@ -102,11 +103,11 @@ public class NewJavaWizard extends Wizard implements INewWizard {
* the editor on the newly created file.
*/
private void doFinish(String projectName, String teamNumber, String packageName, ProjectType projectType, IProgressMonitor monitor) throws CoreException {
private void doFinish(String projectName, String teamNumber, String packageName, ProjectType projectType, String worldName, IProgressMonitor monitor) throws CoreException {
Properties props = WPILibCore.getDefault().getProjectProperties(null);
props.setProperty("team-number", teamNumber);
WPILibCore.getDefault().saveGlobalProperties(props);
ProjectCreationUtils.createProject(new WPIRobotJavaProjectCreator(projectName, packageName, projectType));
ProjectCreationUtils.createProject(new WPIRobotJavaProjectCreator(projectName, packageName, projectType, worldName));
}
/**

View File

@@ -15,13 +15,14 @@ import edu.wpi.first.wpilib.plugins.core.wizards.ProjectType;
import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin;
public class WPIRobotJavaProjectCreator implements IProjectCreator {
String projectName, packageName;
String projectName, packageName, worldName;
ProjectType projectType;
public WPIRobotJavaProjectCreator(String projectName, String packageName, ProjectType projectType) {
public WPIRobotJavaProjectCreator(String projectName, String packageName, ProjectType projectType, String worldName) {
this.projectName = projectName;
this.packageName = packageName;
this.projectType = projectType;
this.worldName = worldName;
}
@Override
@@ -39,6 +40,7 @@ public class WPIRobotJavaProjectCreator implements IProjectCreator {
Map<String, String> vals = new HashMap<String, String>();
vals.put("$project", projectName);
vals.put("$package", packageName);
vals.put("$world", worldName);
return vals;
}

View File

@@ -28,4 +28,10 @@ src.dir=src
build.dir=build
build.jars=${build.dir}/jars
dist.dir=dist
dist.jar=${dist.dir}/${jar}
dist.jar=${dist.dir}/${jar}
# Simulation Information
simulation.dist.jar=${dist.dir}/FRCUserProgramSim.jar
wpilib.sim=${wpilib}/sim
wpilib.sim.lib=${wpilib.sim}/lib
wpilib.sim.tools=${wpilib.sim}/tools

View File

@@ -55,9 +55,9 @@
<jar destfile="${dist.jar}" update="false">
<manifest>
<attribute name="Main-Class" value="edu.wpi.first.wpilibj.RobotBase"/>
<attribute name="Robot-Class" value="${main}"/>
<attribute name="Class-Path" value="."/>
<attribute name="Main-Class" value="edu.wpi.first.wpilibj.RobotBase"/>
<attribute name="Robot-Class" value="${robot.class}"/>
<attribute name="Class-Path" value="."/>
</manifest>
<fileset dir="${build.dir}" includes="**/*.class"/>
@@ -96,4 +96,73 @@
trust="true"
command="chmod a+x debug*program; ${deploy.debug.command}"/>
</target>
<!-- Simulate -->
<target name="jar-for-simulation" depends="compile">
<echo>[jar-for-simulation] Building jar.</echo>
<jar destfile="${simulation.dist.jar}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Robot-Class" value="${robot.class}"/>
<attribute name="Main-Class" value="edu.wpi.first.wpilibj.RobotBase"/>
</manifest>
<fileset dir="${build.dir}" />
<zipgroupfileset dir="${wpilib.sim.lib}">
<include name="**/*.jar" />
</zipgroupfileset>
</jar>
</target>
<target name="simulate" depends="jar-for-simulation">
<parallel>
<sequential>
<echo>[simulate] Running Gazebo.</echo>
<exec executable="frcsim">
<arg value="${simulation.world.file}"/>
</exec>
</sequential>
<sequential>
<sleep seconds="5"/>
<echo>[simulate] Running DriverStation.</echo>
<java jar="${wpilib.sim.tools}/SimDS.jar" fork="true">
<jvmarg value="-Djava.library.path=${wpilib.sim.lib}" />
</java>
</sequential>
<sequential>
<sleep seconds="5"/>
<echo>[simulate] Running Code.</echo>
<java jar="${simulation.dist.jar}" fork="true">
<jvmarg value="-Djava.library.path=${wpilib.sim.lib}" />
</java>
</sequential>
</parallel>
</target>
<target name="debug-simulate" depends="jar-for-simulation">
<parallel>
<sequential>
<echo>[debug-simulate] Running Gazebo.</echo>
<exec executable="frcsim">
<arg value="${simulation.world.file}"/>
</exec>
</sequential>
<sequential>
<sleep seconds="5"/>
<echo>[debug-simulate] Running DriverStation.</echo>
<java jar="${wpilib.sim.tools}/SimDS.jar" fork="true">
<jvmarg value="-Djava.library.path=${wpilib.sim.lib}" />
</java>
</sequential>
<sequential>
<sleep seconds="5"/>
<echo>[debug-simulate] Running Code.</echo>
<java jar="${simulation.dist.jar}" fork="true">
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8348" />
<jvmarg value="-Djava.library.path=${wpilib.sim.lib}" />
</java>
</sequential>
</parallel>
</target>
</project>