mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
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:
@@ -19,6 +19,8 @@ import edu.wpi.first.wpilibj.fixtures.SampleFixture;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
|
||||
import edu.wpi.first.wpilibj.hal.CanTalonSRX;
|
||||
import edu.wpi.first.wpilibj.hal.CanTalonJNI;
|
||||
import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_double;
|
||||
|
||||
/**
|
||||
* Basic test (borrowed straight from SampleTest) for running the CAN TalonSRX.
|
||||
@@ -61,6 +63,9 @@ public class CANTalonTest extends AbstractComsSetup {
|
||||
talon.SetModeSelect(0);
|
||||
// Set Talon to 50% forwards throttle.
|
||||
talon.Set(0.5);
|
||||
long currentp = CanTalonJNI.new_doublep();//new SWIGTYPE_p_double(, true);
|
||||
talon.GetTemp(new SWIGTYPE_p_double(currentp, true));
|
||||
System.out.println(CanTalonJNI.doublep_value(currentp));
|
||||
Timer.delay(1.5);
|
||||
// Turn Talon off.
|
||||
talon.Set(0.0);
|
||||
@@ -70,6 +75,7 @@ public class CANTalonTest extends AbstractComsSetup {
|
||||
CANTalon tal = new CANTalon(0);
|
||||
tal.enableControl();
|
||||
tal.set(0.5);
|
||||
System.out.println(tal.getTemp());
|
||||
Timer.delay(1.0);
|
||||
tal.disable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user