001/* 002 * Copyright (C) Cross The Road Electronics. All rights reserved. 003 * License information can be found in CTRE_LICENSE.txt 004 * For support and suggestions contact support@ctr-electronics.com or file 005 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases 006 */ 007package com.ctre.phoenixpro.signals; 008 009import java.util.HashMap; 010 011/** 012 * Choose what sensor source is reported via API and used by closed-loop and 013 * limit features. The default is RotorSensor, which uses the internal rotor 014 * sensor in the Talon FX. Choose RemoteCANcoder to use another CANcoder on 015 * the same CAN bus (this also requires setting FeedbackRemoteSensorID). Talon 016 * FX will update its position and velocity whenever CANcoder publishes its 017 * information on CAN bus. Choose FusedCANcoder and Talon FX will fuse another 018 * CANcoder's information with the internal rotor, which provides the best 019 * possible position and velocity for accuracy and bandwidth (note this 020 * requires setting FeedbackRemoteSensorID). FusedCANcoder was developed for 021 * applications such as swerve-azimuth. 022 * <p> 023 * Note: When the Talon Source is changed to FusedCANcoder, the Talon needs a 024 * period of time to fuse before sensor-based (soft-limit, closed loop, etc.) 025 * features are used. This period of time is determined by the update frequency 026 * of the CANcoder's Position signal. 027 * 028 * @deprecated Classes in the phoenixpro package will be removed in 2024. 029 * Users should instead use classes from the phoenix6 package. 030 */ 031@Deprecated(forRemoval = true) 032public enum FeedbackSensorSourceValue 033{ 034 RotorSensor(0), 035 RemoteCANcoder(1), 036 FusedCANcoder(5),; 037 038 public final int value; 039 040 FeedbackSensorSourceValue(int initValue) 041 { 042 this.value = initValue; 043 } 044 045 private static HashMap<Integer, FeedbackSensorSourceValue> _map = null; 046 static 047 { 048 _map = new HashMap<Integer, FeedbackSensorSourceValue>(); 049 for (FeedbackSensorSourceValue type : FeedbackSensorSourceValue.values()) 050 { 051 _map.put(type.value, type); 052 } 053 } 054 055 /** 056 * Gets FeedbackSensorSourceValue from specified value 057 * @param value Value of FeedbackSensorSourceValue 058 * @return FeedbackSensorSourceValue of specified value 059 */ 060 public static FeedbackSensorSourceValue valueOf(int value) 061 { 062 FeedbackSensorSourceValue retval = _map.get(value); 063 if(retval != null) return retval; 064 return FeedbackSensorSourceValue.values()[0]; 065 } 066}