CTRE released an update allowing, from what I know, a gyro (Pigeon) to assist motion profiling to go where it wants to go. I’m looking at the example code here: https://github.com/CrossTheRoadElec/Phoenix-Examples-Languages/tree/master/Java/RemoteClosedLoop
I’m confused at a lot of things, such as:
_talonRght.configRemoteFeedbackFilter(_talonLeft.getDeviceID(), RemoteSensorSource.TalonSRX_SelectedSensor,Constants.REMOTE_0, Constants.kTimeoutMs);
Why is the Talon configuring a remote sensor as the other Talon?
_talonRght.config_kP(Constants.kSlot_Turning, Constants.kGains_Turning.kP, Constants.kTimeoutMs);
Why does CTRE have a PID for turning? How does that work?
What I want to implement is two-axis motion profiling, as shown in the function called “two_Axis_MotionProfile”. Example implementation:
void two_Axis_MotionProfile(boolean bFirstCall, ButtonEvent bExecuteAction, double joyForward, double joyTurn) {
/* calculate targets from gamepad inputs */
boolean bMoveForward = (joyForward >= 0) ? true : false;
double finalHeading_units = Constants.kTurnTravelUnitsPerRotation * joyTurn * -1.0; /* positive right stick => negative heading target (turn to right) */
if (bFirstCall) {
System.out.print("[13]two_Axis_MotionProfile selected, ");
System.out.println("Press Button 6 to fire the profile. ");
neutralMotors("Target not set yet.
");
/* slots are selected in the profile, not via selectProfileSlot() */
} else if (bExecuteAction == ButtonEvent.ButtonOnToOff) {
} else if (bExecuteAction == ButtonEvent.ButtonOffToOn) {
neutralMotors("Button let go
");
zeroSensors();
_motProfExample.reset();
_motProfExample.start(finalHeading_units, bMoveForward);
} else if (bExecuteAction == ButtonEvent.ButtonOn) {
_talonRght.set(ControlMode.MotionProfileArc, _motProfExample.getSetValue().value);
_talonLeft.follow(_talonRght, FollowerType.AuxOutput1);
}
/* call this periodically, and catch the output. Only apply it if user wants to run MP. */
_motProfExample.control();
}
What I don’t get it why is finalHeading_units calculated by the joystick turn value? Shouldn’t it use the Pigeon gyro somewhere to get the current yaw value?
And finally, in MotionProfileExample.java, there’s a variable called endHeading that’s used during motion profiling. Why is only the end heading specified? Shouldn’t the heading and gyro yaw value be pulled periodically to ensure exact angles during motion profiling?
Thanks.