REVLib'e Geçiş
SPARK MAX API ve/veya Renk Sensörü V3 API'den geçiş
2022'den itibaren, SPARK MAX API ve Renk Sensörü V3 API, REVLib adı verilen birleşik bir kütüphanede birleştirildi. REVLib'i yüklemeden önce bu eski kütüphaneleri kaldırdığınızdan emin olmanız gerekir.
LabVIEW'e geçiş
Eski SPARK MAX API ve/veya Color Sensor V3 API paketlerinin kaldırıldığından emin olun.
Eski API'leri kullanan bir projeyi açmak iyi çalışmalıdır. Yüklenirken, bazı eksik VI'lar olduğunu gösterebilir, ancak sonunda LabVIEW yeni VI'ları otomatik olarak bulmalıdır.
C++/Java'ya geçiş
Robot projenizi VSCode'da açın.
WPI Komut Paletini açmak için köşedeki WPI simgesine tıklayın.
Manage Vendor Libraries'i seçin.
Manage Current Libraries'i seçin.
REVRoboticsve/veyaREVColorSensorV3öğelerini kontrol edin (hangisi mevcutsa)Bunları kaldırmak için
OKdüğmesine tıklayın.C++ ve Java için REVLib'i yükleyin.
CTRE Phoenix'ten geçiş
Birçok ekip Talon SRX ve Talon SPX gibi çeşitli CTRE motor kontrolörleri kullanıyor ve platformlar arasında yazılım taşıma konusunda endişeleri var. Neyse ki gerekli özellik seti ve kod ikisi arasında benzerdir ve birinden diğerine geçiş kolaydır. Aşağıda, CTRE Phoenix cihazlarının kodundan SPARK MAX'a dönüştürmek için gereken ortak görevler ve değişiklikler gösterilmektedir.
CTRE Phoenix'ten geçiş: Java
Kütüphaneyi Dahil Etme
import com.revrobotics.CANEncoder;
import com.revrobotics.CANPIDController;
import com.revrobotics.CANSparkMax;
import com.revrobotics.ControlType;
import com.revrobotics.CANSparkMaxLowLevel.MotorType;import com.ctre.phoenix.motorcontrol.can.*;
import com.ctre.phoenix.motorcontrol.*;CAN ID 1 Nesnesi Oluştur
private CANSparkMax sparkMax = new CANSparkMax(deviceID, MotorType.kBrushless);TalonSRX talonSRX = new TalonSRX(1);Fabrika Varsayılanlarını Sıfırla
sparkMax.restoreFactoryDefaults();talonSRX.configFactoryDefault();Enkoder Seçimi
Bu bir fırçalı motor özelliğidir ve fırçasız motorları SPARK MAX ile kullanmak için gerekmez
encoder = sparkMax.getEncoder();
encoder.setInverted(false);
sparkMax.setFeedbackDevice(encoder);talonSRX.configSelectedFeedbackSensor(FeedbackDevice.CTRE_MagEncoder_Relative, kPIDLoopIdx, Constants.kTimeoutMs);
talonSRX.setSensorPhase(true);Kapalı döngü sabitlerini ayarlama
pidController.setP(kP);
pidController.setI(kI);
pidController.setD(kD);
pidController.setIZone(kIz);
pidController.setFF(kFF);
pidController.setOutputRange(kMinOutput, kMaxOutput);talonSRX.configNominalOutputForward(0, kTimeoutMs);
talonSRX.configNominalOutputReverse(0, kTimeoutMs);
talonSRX.configPeakOutputForward(kMaxOutput, kTimeoutMs);
talonSRX.configPeakOutputReverse(kMinOutput, kTimeoutMs);
talonSRX.config_kF(kPIDLoopIdx, kP, kTimeoutMs);
talonSRX.config_kP(kPIDLoopIdx, kI, kTimeoutMs);
talonSRX.config_kI(kPIDLoopIdx, kD, kTimeoutMs);
talonSRX.config_kD(kPIDLoopIdx, kF, kTimeoutMs);Kapalı Döngü Hız Kontrolünü Çalıştırma
Bu örnek için hız 500 RPM olarak ayarlanmıştır
pidController.setReference(500.0, ControlType.kVelocity);// Convert from 500 RPM to 'native units'
double VelocityinUnitsPer100ms = 500.0 * 4096 / 600;
talonSRX.set(ControlMode.Velocity, VelocityinUnitsPer100ms ); Motor Devir Sayısını Okuma
encoder.getVelocity();talonSRX.getSelectedSensorVelocity(kPIDLoopIdx) * 600 / 4096;Uygulanan Çıkış Yüzdesini Okuma
sparkMax.getAppliedOutput();talonSRX.getMotorOutputPercent();Kapalı Döngü Pozisyon Kontrolünü Çalıştırma
Bu örnek, 10 devir için bir konum kontrol döngüsü çalıştırır.
pidController.setReference(10.0, ControlType.kPosition);targetPositionRoations = 10.0 * 4096;
talonSRX.set(ControlMode.Position, targetPositionRotations);Birimleri 'rotasyon' yerine 'inç' olarak değiştirme
Bu örnekte 15:1 redüksiyon üzerinde 4” tekerlek varsayılmıştır
encoder.setPositionFactor(M_PI * 4/15);// No EquivellantBelirli bir mesafe için Kapalı Döngü Konum Kontrolünü çalıştırma
Bu örnekte, 2 fit (24 inç) hareket etmek için 15:1 redüksiyon üzerinde 4 inçlik bir tekerlek varsayılmıştır.
pidController.setReference(24.0, ControlType.kPosition);targetPositionRotations = (M_PI * 4 / 15 * 4096) * 24;
talonSRX.set(ControlMode.Position, targetPositionRotations);Parametreleri Kaydetme
// Run after all parameters are set in RobotInit()
sparkMax.burnFlash();//AutomaticBaşka bir cihazı takip etme
sparkMax1.follow(sparkMax2);talonSRX1.follow(talonSRX2);Bir cihazı ters çevirme
sparkMax.setInverted(true);talonSRX.setInverted(true);Bir limit anahtarı yapılandırma
forwardLimit = sparkMax.getForwardLimitSwitch(LimitSwitchPolarity.kNormallyOpen);talonSRX.configForwardLimitSwitchSource(
LimitSwitchSource.LimitSwitchSource_FeedbackConnector,
LimitSwitchNormal.LimitSwitchNormal_NormallyOpen,
kTimeoutMs);Bir limit anahtarını devre dışı bırakma
forwardLimit.EnableLimitSwitch(false);talonSRX.overrideLimitSwitchesEnable(true);CTRE Phoenix'ten geçiş: C++
Kütüphaneyi Dahil Etme
#include "rev/CANSparkMax.h"#include "ctre/Phoenix.h"CAN ID 1 Nesnesi Oluştma
rev::CANSparkMax sparkMax{1, rev::CANSparkMax::MotorType::kBrushless};TalonSRX* talon = new TalonSRX(1);Fabrika Varsayılanlarına Sıfırlama
sparkMax.RestoreFactoryDefaults();talon->ConfigFactoryDefault();Enkoder Seçme
Bu bir fırçalı motor özelliğidir ve SPARK MAX ile fırçasız motorları kullanmak için gerekmez.
rev::CANEncoder encoder = sparkMax.GetEncoder(rev::CANEncoder::EncoderType::kQuadrature, 4096);
encoder.SetInverted(true);
sparkMax.SetFeedbackDevice(encoder);talonSRX->ConfigSelectedFeedbackSensor(FeedbackDevice::CTRE_MagEncoder_Relative, 0, kTimeoutMs);
talonSRX->SetSensorPhase(true);Kapalı döngü sabitlerini ayarlama
rev::CANPIDController pidController = sparkMax.GetPIDController();
pidController.SetFeedbackDevice(encoder);
pidController.SetP(kP);
pidController.SetI(kI);
pidController.SetD(kD);
pidController.SetIZone(kIz);
pidController.SetFF(kFF);
pidController.SetOutputRange(kMinOutput, kMaxOutput);talonSRX->ConfigNominalOutputForward(0, kTimeoutMs);
talonSRX->ConfigNominalOutputReverse(0, kTimeoutMs);
talonSRX->ConfigPeakOutputForward(1, kTimeoutMs);
talonSRX->ConfigPeakOutputReverse(-1, kTimeoutMs);
talonSRX->Config_kF(kPIDLoopIdx, 0.1097, kTimeoutMs);
talonSRX->Config_kP(kPIDLoopIdx, 0.22, kTimeoutMs);
talonSRX->Config_kI(kPIDLoopIdx, 0.0, kTimeoutMs);
talonSRX->Config_kD(kPIDLoopIdx, 0.0, kTimeoutMs);Kapalı Döngü Hız Kontrolünü Çalıştırma
Bu örnek için hız 500 RPM olarak ayarlanmıştır
pidController.SetReference(500.0, rev::ControlType::kVelocity);"// Convert from 500 RPM to 'native units'
double VelocityinUnitsPer100ms = 500.0 * 4096 / 600;
talonSRX->Set(ControlMode::Velocity, VelocityinUnitsPer100ms ); Motor Devir Sayısını Okuma
encoder.GetVelocity();talonSRX->GetSelectedSensorVelocity(kPIDLoopIdx) * 600 / 4096;Uygulanan Çıkış Yüzdesini Okuma
sparkMax.GetAppliedOutput();talonSRX->GetMotorOutputPercent();Kapalı Döngü Pozisyon Kontrolünü Çalıştırma
Bu örnek, 10 dönüş için bir konum kontrol döngüsü çalıştırır.
pidController.SetReference(10.0, rev::ControlType::kPosition);targetPositionRotations = 10.0 * 4096;
talonSRX->Set(ControlMode::Position, targetPositionRotations);;Birimleri 'rotasyon' yerine 'inç' olarak değiştirme
Bu örnekte 15:1 redüksiyon üzerinde 4” tekerlek varsayılmıştır
encoder.SetPositionFactor( M_PI * 4 / 15 );// No EquivellantBelirli bir mesafe için Kapalı Döngü Konum Kontrolünü Çalıştırma
Bu örnekte, 2 fit (24 inç) hareket etmek için 15:1 redüksiyon üzerinde 4 inçlik bir tekerlek varsayılmıştır.
pidController.SetReference(24.0, rev::ControlType::kPosition);targetPositionRotations = (M_PI * 4 / 15 * 4096) * 24;
talonSRX->Set(ControlMode::Position, targetPositionRotations);Parametreleri Kaydetme
// Run after all parameters are set in RobotInit()
sparkMax.BurnFlash();//AutomaticBaşka bir cihazı takip etme
sparkMax1.Follow(sparkMax2);talonSRX1->Follow(*talon2);Bir cihazı ters çevirme
sparkMax.SetInverted(true);talonSRX->SetInverted(true);Bir limit anahtarı yapılandırma
rev::CANDigitalInput forwardLimit = sparkMax.GetForwardLimitSwitch(rev::CANDigitalInput::LimitSwitchPolarity::kNormallyOpen);talonSRX->ConfigForwardLimitSwitchSource(
LimitSwitchSource::LimitSwitchSource_FeedbackConnector,
LimitSwitchNormal::LimitSwitchNormal_NormallyOpen,
kTimeoutMs);Bir limit anahtarını devre dışı bırakma
forwardLimit.EnableLimitSwitch(false);talonSRX->OverrideLimitSwitchesEnable(true);Last updated
Was this helpful?