Added support for CAN Talon SRX in C++ and Java.

Currently, the JNI bindings are generated by Swig and, unfortunately,
  the interface available through Java is lower-level than that for C++
  (ie, direct access to the ctre code through the JNI bindings, rather
   than an interface on top of that), but it does work.
See eclipse plugins for some short samples.
There are a couple of short unit tests as placeholders.
Still needs some cleaning up.

Change-Id: Iae2f74693ca6b80bf7d5aca0625c66aa6e0b7f85

Added quick samples for C++/Java CAN Talon stuff.

Change-Id: I3acb27d6fd5568d88931e0d678c09973d436735d
This commit is contained in:
James Kuszmaul
2014-11-17 16:02:41 -05:00
parent f590cda8f9
commit 28a41e4ac2
36 changed files with 3883 additions and 538 deletions

View File

@@ -0,0 +1,39 @@
package $package;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.hal.CanTalonSRX;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Timer;
/**
* This is a short sample program demonstrating how to use the basic throttle
* mode of the new CAN Talon. As of when this was made, the basic throttle mode
* is all that is supported.
*/
public class Robot extends SampleRobot {
CanTalonSRX motor;
private final double k_updatePeriod = 0.005; // update every 0.005 seconds/5 milliseconds (200Hz)
public Robot() {
motor = new CanTalonSRX(1); // Initialize the CanTalonSRX on device 1.
}
/**
* Runs the motor from a joystick.
*/
public void operatorControl() {
motor.SetModeSelect(0);
while (isOperatorControl() && isEnabled()) {
// Set the motor's output.
// This takes a number from -1 (100% speed in reverse) to +1 (100% speed
// going forward)
motor.Set(0.5);
Timer.delay(k_updatePeriod); // wait 5ms to the next update
}
motor.Set(0.0);
}
}

View File

@@ -154,6 +154,23 @@
</files>
</example>
<example>
<name>CAN Talon SRX</name>
<description>Demonstrate running a Talon SRX with the basic throttle mode.</description>
<tags>
<tag>Actuators</tag>
<tag>Complete List</tag>
<tag>Robot and Motor</tag>
</tags>
<packages>
<package>src/$package-dir</package>
</packages>
<files>
<file source="examples/CANTalon/src/org/usfirst/frc/team190/robot/Robot.java"
destination="src/$package-dir/Robot.java"></file>
</files>
</example>
<tagDescription>
<name>CommandBased Robot</name>