Added Omar's new CanTalonSRX code.

I also updated the C++ and Java code some. For C++, this meant making it
compile and adding in the framework for the closed-loop control of the
motor. For Java, I updated the JNI bindings with SWIG and created an
GetTemperature accessor function to demonstrate how to use the accessors
because swig does funny stuff with pass-by-reference functions.

Change-Id: If51bf61d0a9bc65a8d497f8d91a5be8d6ff4fdcc
This commit is contained in:
James Kuszmaul
2014-11-26 15:15:52 -05:00
parent 6ec2d262c8
commit 7b371f6d7c
25 changed files with 3636 additions and 270 deletions

View File

@@ -2,7 +2,7 @@ package $package;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.hal.CanTalonSRX;
import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Timer;
@@ -13,27 +13,27 @@ import edu.wpi.first.wpilibj.Timer;
*/
public class Robot extends SampleRobot {
CanTalonSRX motor;
CANTalon 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.
motor = new CANTalon(1); // Initialize the CanTalonSRX on device 1.
}
/**
* Runs the motor from a joystick.
*/
public void operatorControl() {
motor.SetModeSelect(0);
motor.enableControl();
while (isOperatorControl() && isEnabled()) {
// Set the motor's output.
// Set the motor's output to half power.
// This takes a number from -1 (100% speed in reverse) to +1 (100% speed
// going forward)
motor.Set(0.5);
motor.set(0.5);
Timer.delay(k_updatePeriod); // wait 5ms to the next update
}
motor.Set(0.0);
motor.disable();
}
}