mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Add 2020 speed controllers (#2188)
Add CTRE TalonFX (PWMTalonFX) Add Playing with Fusion Venom (PWMVenom)
This commit is contained in:
committed by
Peter Johnson
parent
635882a9f7
commit
1ce24a7a2f
24
wpilibc/src/main/native/cpp/PWMTalonFX.cpp
Normal file
24
wpilibc/src/main/native/cpp/PWMTalonFX.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "frc/PWMTalonFX.h"
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
PWMTalonFX::PWMTalonFX(int channel) : PWMSpeedController(channel) {
|
||||
SetBounds(2.004, 1.52, 1.50, 1.48, 0.997);
|
||||
SetPeriodMultiplier(kPeriodMultiplier_1X);
|
||||
SetSpeed(0.0);
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_TalonFX, GetChannel() + 1);
|
||||
SendableRegistry::GetInstance().SetName(this, "PWMTalonFX", GetChannel());
|
||||
}
|
||||
24
wpilibc/src/main/native/cpp/PWMVenom.cpp
Normal file
24
wpilibc/src/main/native/cpp/PWMVenom.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "frc/PWMVenom.h"
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
PWMVenom::PWMVenom(int channel) : PWMSpeedController(channel) {
|
||||
SetBounds(2.004, 1.52, 1.50, 1.48, 0.997);
|
||||
SetPeriodMultiplier(kPeriodMultiplier_1X);
|
||||
SetSpeed(0.0);
|
||||
SetZeroLatch();
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_FusionVenom, GetChannel() + 1);
|
||||
SendableRegistry::GetInstance().SetName(this, "PWMVenom", GetChannel());
|
||||
}
|
||||
45
wpilibc/src/main/native/include/frc/PWMTalonFX.h
Normal file
45
wpilibc/src/main/native/include/frc/PWMTalonFX.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "frc/PWMSpeedController.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Cross the Road Electronics (CTRE) Talon FX Speed Controller with PWM
|
||||
* control.
|
||||
*
|
||||
* Note that the Talon FX 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 FX User
|
||||
* Manual available from Cross The Road Electronics.
|
||||
*
|
||||
* \li 2.004ms = full "forward"
|
||||
* \li 1.520ms = the "high end" of the deadband range
|
||||
* \li 1.500ms = center of the deadband range (off)
|
||||
* \li 1.480ms = the "low end" of the deadband range
|
||||
* \li 0.997ms = full "reverse"
|
||||
*/
|
||||
class PWMTalonFX : public PWMSpeedController {
|
||||
public:
|
||||
/**
|
||||
* Construct a Talon FX connected via PWM.
|
||||
*
|
||||
* @param channel The PWM channel that the Talon FX is attached to. 0-9 are
|
||||
* on-board, 10-19 are on the MXP port
|
||||
*/
|
||||
explicit PWMTalonFX(int channel);
|
||||
|
||||
PWMTalonFX(PWMTalonFX&&) = default;
|
||||
PWMTalonFX& operator=(PWMTalonFX&&) = default;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
43
wpilibc/src/main/native/include/frc/PWMVenom.h
Normal file
43
wpilibc/src/main/native/include/frc/PWMVenom.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "frc/PWMSpeedController.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Playing with Fusion Venom Smart Motor with PWM control.
|
||||
*
|
||||
* Note that the Venom 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.
|
||||
*
|
||||
* \li 2.004ms = full "forward"
|
||||
* \li 1.520ms = the "high end" of the deadband range
|
||||
* \li 1.500ms = center of the deadband range (off)
|
||||
* \li 1.480ms = the "low end" of the deadband range
|
||||
* \li 0.997ms = full "reverse"
|
||||
*/
|
||||
class PWMVenom : public PWMSpeedController {
|
||||
public:
|
||||
/**
|
||||
* Construct a Venom connected via PWM.
|
||||
*
|
||||
* @param channel The PWM channel that the Venom is attached to. 0-9 are
|
||||
* on-board, 10-19 are on the MXP port
|
||||
*/
|
||||
explicit PWMVenom(int channel);
|
||||
|
||||
PWMVenom(PWMVenom&&) = default;
|
||||
PWMVenom& operator=(PWMVenom&&) = default;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
49
wpilibj/src/main/java/edu/wpi/first/wpilibj/PWMTalonFX.java
Normal file
49
wpilibj/src/main/java/edu/wpi/first/wpilibj/PWMTalonFX.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
|
||||
|
||||
/**
|
||||
* Cross the Road Electronics (CTRE) Talon FX Speed Controller with PWM control.
|
||||
*
|
||||
* <p>Note that the TalonFX 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 TalonFX User Manual
|
||||
* available from CTRE.
|
||||
*
|
||||
* <p><ul>
|
||||
* <li>2.004ms = full "forward"
|
||||
* <li>1.520ms = the "high end" of the deadband range
|
||||
* <li>1.500ms = center of the deadband range (off)
|
||||
* <li>1.480ms = the "low end" of the deadband range
|
||||
* <li>0.997ms = full "reverse"
|
||||
* </ul>
|
||||
*/
|
||||
public class PWMTalonFX extends PWMSpeedController {
|
||||
/**
|
||||
* Constructor for a TalonFX connected via PWM.
|
||||
*
|
||||
* @param channel The PWM channel that the Talon FX is attached to. 0-9 are on-board, 10-19 are
|
||||
* on the MXP port
|
||||
*/
|
||||
public PWMTalonFX(final int channel) {
|
||||
super(channel);
|
||||
|
||||
setBounds(2.004, 1.52, 1.50, 1.48, 0.997);
|
||||
setPeriodMultiplier(PeriodMultiplier.k1X);
|
||||
setSpeed(0.0);
|
||||
setZeroLatch();
|
||||
|
||||
HAL.report(tResourceType.kResourceType_TalonFX, getChannel() + 1);
|
||||
SendableRegistry.setName(this, "PWMTalonFX", getChannel());
|
||||
}
|
||||
}
|
||||
48
wpilibj/src/main/java/edu/wpi/first/wpilibj/PWMVenom.java
Normal file
48
wpilibj/src/main/java/edu/wpi/first/wpilibj/PWMVenom.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import edu.wpi.first.hal.FRCNetComm.tResourceType;
|
||||
import edu.wpi.first.hal.HAL;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SendableRegistry;
|
||||
|
||||
/**
|
||||
* Playing with Fusion Venom Smart Motor with PWM control.
|
||||
*
|
||||
* <p>Note that the Venom 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.
|
||||
*
|
||||
* <p><ul>
|
||||
* <li>2.004ms = full "forward"
|
||||
* <li>1.520ms = the "high end" of the deadband range
|
||||
* <li>1.500ms = center of the deadband range (off)
|
||||
* <li>1.480ms = the "low end" of the deadband range
|
||||
* <li>0.997ms = full "reverse"
|
||||
* </ul>
|
||||
*/
|
||||
public class PWMVenom extends PWMSpeedController {
|
||||
/**
|
||||
* Constructor for a Venom connected via PWM.
|
||||
*
|
||||
* @param channel The PWM channel that the Venom is attached to. 0-9 are on-board, 10-19 are
|
||||
* on the MXP port
|
||||
*/
|
||||
public PWMVenom(final int channel) {
|
||||
super(channel);
|
||||
|
||||
setBounds(2.004, 1.52, 1.50, 1.48, 0.997);
|
||||
setPeriodMultiplier(PeriodMultiplier.k1X);
|
||||
setSpeed(0.0);
|
||||
setZeroLatch();
|
||||
|
||||
HAL.report(tResourceType.kResourceType_FusionVenom, getChannel() + 1);
|
||||
SendableRegistry.setName(this, "PWMVenom", getChannel());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user