2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-08-23 22:06:13 -07:00
|
|
|
/* Copyright (c) 2008-2017 FIRST. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "Talon.h"
|
|
|
|
|
|
2016-05-25 22:38:11 -07:00
|
|
|
#include "HAL/HAL.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
#include "LiveWindow/LiveWindow.h"
|
|
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
2016-05-20 17:30:37 -07:00
|
|
|
* Constructor for a Talon (original or Talon SR).
|
|
|
|
|
*
|
2015-06-29 02:43:44 -07:00
|
|
|
* @param channel The PWM channel number that the Talon is attached to. 0-9 are
|
2016-05-20 17:30:37 -07:00
|
|
|
* on-board, 10-19 are on the MXP port
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
Talon::Talon(int channel) : PWMSpeedController(channel) {
|
2015-06-29 02:43:44 -07:00
|
|
|
/* Note that the Talon uses the following bounds for PWM values. These values
|
|
|
|
|
* should work reasonably well for most controllers, but if users experience
|
|
|
|
|
* issues such as asymmetric behavior around the deadband or inability to
|
|
|
|
|
* saturate the controller in either direction, calibration is recommended.
|
|
|
|
|
* The calibration procedure can be found in the Talon User Manual available
|
|
|
|
|
* from CTRE.
|
|
|
|
|
*
|
|
|
|
|
* 2.037ms = full "forward"
|
|
|
|
|
* 1.539ms = the "high end" of the deadband range
|
|
|
|
|
* 1.513ms = center of the deadband range (off)
|
|
|
|
|
* 1.487ms = the "low end" of the deadband range
|
|
|
|
|
* 0.989ms = full "reverse"
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
SetBounds(2.037, 1.539, 1.513, 1.487, .989);
|
|
|
|
|
SetPeriodMultiplier(kPeriodMultiplier_1X);
|
2016-07-08 21:29:29 -07:00
|
|
|
SetSpeed(0.0);
|
2015-06-25 15:07:55 -04:00
|
|
|
SetZeroLatch();
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-07-09 00:24:26 -07:00
|
|
|
HAL_Report(HALUsageReporting::kResourceType_Talon, GetChannel());
|
Revert changes preventing old user code from compiling.
I'm not 100% sure whether we want these, but they are a quick
find and replace to do.
Basically, there are two primary things that we have done
this summer that break existing user code:
-Changing GetInstance() calls to return references instead
of pointers. This forces users to change from doing something
like LiveWindow::GetInstance()->AddSensor() to LiveWindow::GetInstance().AddSensor().
-Making PIDGet() and related calls const, forcing users to change
the function signatures wherever they override them.
The GetInstance() calls don't really matter to me either way,
especially since there are no real ownership issues going on there,
unlike the rest of the smart pointer-related changes.
For the const stuff, it is certainly more correct to mandate that
user PIDGet() functions be const and the such, but at the same time,
I'm not sure that there is any strong need for it, and the errors
generated are not the most helpful. While this wouldn't necessarily
be an issue for more experienced teams or completely new teams (who
don't have any old code to be reusing), it may cause issues for more
average teams who aren't familiar with the intricacies of C++ anything.
Change-Id: I6e7007982069292ea70e6d0fc8ca40203340df1b
2015-07-24 19:19:40 -04:00
|
|
|
LiveWindow::GetInstance()->AddActuator("Talon", GetChannel(), this);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|