Skip to content

Commit

Permalink
Added option to use Leap Motion Controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin authored and Kevin committed Aug 31, 2014
1 parent 39228c9 commit 3ee56d1
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 90 deletions.
174 changes: 87 additions & 87 deletions nbproject/project.xml
@@ -1,92 +1,92 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
This is a sample netbeans project file for a Sun Spot Application project.
You may edit it freely, it doesn't affect the ant-powered build.
--><project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ant.freeform</type>
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<name>Fluffy</name>
<properties>
<property-file>${user.home}/.sunspotfrc.properties</property-file>
<property-file>build.properties</property-file>
<property-file>${sunspot.home}/default.properties</property-file>
</properties>
<folders>
<source-folder>
<label>src</label>
<type>java</type>
<location>src</location>
</source-folder>
</folders>
<ide-actions>
<action name="build">
<target>jar-app</target>
</action>
<action name="clean">
<target>clean</target>
</action>
<action name="run">
<target>deploy</target>
<target>run</target>
</action>
<action name="rebuild">
<target>clean</target>
<target>jar-app</target>
</action>
<action name="debug">
<target>deploy</target>
<target>debug-run</target>
</action>
<action name="javadoc">
<target>javadoc</target>
</action>
</ide-actions>
<export>
<type>folder</type>
<location>build</location>
<build-target>jar-app</build-target>
</export>
<view>
<items>
<source-folder style="packages">
<label>src</label>
<location>src</location>
</source-folder>
<source-file>
<location>build.xml</location>
</source-file>
</items>
<context-menu>
<ide-action name="build"/>
<ide-action name="clean"/>
<ide-action name="run"/>
<ide-action name="rebuild"/>
<ide-action name="debug"/>
<ide-action name="javadoc"/>
<action>
<label>Sun SPOT-deploy</label>
<target>deploy</target>
</action>
<action>
<label>Sun SPOT-jar-deploy</label>
<target>jar-deploy</target>
</action>
<separator/>
</context-menu>
</view>
<subprojects/>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
<compilation-unit>
<package-root>src</package-root>
<classpath mode="boot">${sunspot.home}\lib\squawk.jar</classpath>
<classpath mode="compile">${sunspot.home}\lib\wpilibj.jar;${sunspot.home}\lib\networktables-crio.jar</classpath>
<built-to>build</built-to>
<source-level>1.4</source-level>
</compilation-unit>
</java-data>
</configuration>
</project>
--><project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.ant.freeform</type>
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<name>Fluffy</name>
<properties>
<property-file>${user.home}/.sunspotfrc.properties</property-file>
<property-file>build.properties</property-file>
<property-file>${sunspot.home}/default.properties</property-file>
</properties>
<folders>
<source-folder>
<label>src</label>
<type>java</type>
<location>src</location>
</source-folder>
</folders>
<ide-actions>
<action name="build">
<target>jar-app</target>
</action>
<action name="clean">
<target>clean</target>
</action>
<action name="run">
<target>deploy</target>
<target>run</target>
</action>
<action name="rebuild">
<target>clean</target>
<target>jar-app</target>
</action>
<action name="debug">
<target>deploy</target>
<target>debug-run</target>
</action>
<action name="javadoc">
<target>javadoc</target>
</action>
</ide-actions>
<export>
<type>folder</type>
<location>build</location>
<build-target>jar-app</build-target>
</export>
<view>
<items>
<source-folder style="packages">
<label>src</label>
<location>src</location>
</source-folder>
<source-file>
<location>build.xml</location>
</source-file>
</items>
<context-menu>
<ide-action name="build"/>
<ide-action name="clean"/>
<ide-action name="run"/>
<ide-action name="rebuild"/>
<ide-action name="debug"/>
<ide-action name="javadoc"/>
<action>
<label>Sun SPOT-deploy</label>
<target>deploy</target>
</action>
<action>
<label>Sun SPOT-jar-deploy</label>
<target>jar-deploy</target>
</action>
<separator/>
</context-menu>
</view>
<subprojects/>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
<compilation-unit>
<package-root>src</package-root>
<classpath mode="boot">${sunspot.home}\lib\squawk.jar</classpath>
<classpath mode="compile">${sunspot.home}\lib\wpilibj.jar;${sunspot.home}\lib\networktables-crio.jar</classpath>
<built-to>build</built-to>
<source-level>1.4</source-level>
</compilation-unit>
</java-data>
</configuration>
</project>
32 changes: 29 additions & 3 deletions src/org/team484/fluffy/commands/DriveWithJoysticks.java
Expand Up @@ -4,6 +4,8 @@
*/
package org.team484.fluffy.commands;

import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

/**
*
* @author Team484
Expand All @@ -22,10 +24,34 @@ protected void initialize() {

// Called repeatedly when this Command is scheduled to run
protected void execute() {
if (oi.getDriveTrigger()) {
drivetrain.mechanumDrive(oi.getDriveX(), oi.getDriveY(), 0, false, true);
if (SmartDashboard.getNumber("Status", 0) > 0) {
if (SmartDashboard.getNumber("Status", 0) == 1) {
if (SmartDashboard.getBoolean("AllowRot", false)) {
//Rotation only
drivetrain.LeapDrive(0, 0, SmartDashboard.getNumber("Rot", 0));
} else {
if (oi.getDriveTrigger()) {
drivetrain.mechanumDrive(oi.getDriveX(), oi.getDriveY(), 0, false, true);
} else {
drivetrain.mechanumDrive(0, oi.getDriveY(), oi.getDriveX(), false, false);
}
}
} else if (SmartDashboard.getNumber("Status", 0) == 2) {
//Rotation and Drive
drivetrain.LeapDrive(SmartDashboard.getNumber("DriveX", 0), SmartDashboard.getNumber("DriveY", 0), SmartDashboard.getNumber("Rot", 0));
} else {
if (oi.getDriveTrigger()) {
drivetrain.mechanumDrive(oi.getDriveX(), oi.getDriveY(), 0, false, true);
} else {
drivetrain.mechanumDrive(0, oi.getDriveY(), oi.getDriveX(), false, false);
}
}
} else {
drivetrain.mechanumDrive(0, oi.getDriveY(), oi.getDriveX(), false, false);
if (oi.getDriveTrigger()) {
drivetrain.mechanumDrive(oi.getDriveX(), oi.getDriveY(), 0, false, true);
} else {
drivetrain.mechanumDrive(0, oi.getDriveY(), oi.getDriveX(), false, false);
}
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/org/team484/fluffy/subsystems/DriveTrain.java
Expand Up @@ -226,6 +226,8 @@ public void mechanumDrive(double x, double y, double rotation, boolean autonomou
}
if (!(autonomous && sonic.getRangeInches() < 2)) {
robotDrive.mecanumDrive_Cartesian(x, y, rotation, 0);
} else {
robotDrive.mecanumDrive_Cartesian(0, 0, 0, 0);
}

if (sonic.getRangeInches() > 30 && sonic.getRangeInches() < 70) {
Expand All @@ -241,4 +243,17 @@ public void mechanumDrive(double x, double y, double rotation, boolean autonomou
//SmartDashboard.putNumber("voltage", ds.getBatteryVoltage());
//System.out.println(SmartDashboard.getString("DriveFromWall"));
}
public void LeapDrive(double x, double y, double rot) {
robotDrive.mecanumDrive_Cartesian(x, y, rot, 0);
if (sonic.getRangeInches() > 30 && sonic.getRangeInches() < 70) {
SmartDashboard.putBoolean("Shoot", true);
SmartDashboard.putString("Can Shoot", "Ready To Shoot");
} else {
SmartDashboard.putBoolean("Shoot", false);
SmartDashboard.putString("Can Shoot", "Don't Shoot");
}
SmartDashboard.putNumber("Match Time", 230 - ds.getMatchTime());
SmartDashboard.putNumber("Gyro", gyro.getAngle());
SmartDashboard.putNumber("UltraSonic", sonic.getRangeInches());
}
}

0 comments on commit 3ee56d1

Please sign in to comment.