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.phoenix6.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 Commutation, which uses the external sensor 014 * used for motor commutation. 015 * <p> 016 * Choose Remote* to use another sensor on the same CAN bus (this also requires 017 * setting FeedbackRemoteSensorID). Talon will update its position and velocity 018 * whenever the remote sensor publishes its information on CAN bus, and the 019 * Talon commutation sensor will not be used. 020 * <p> 021 * Choose Fused* (requires Phoenix Pro) and Talon will fuse another sensor's 022 * information with the commutation sensor, which provides the best possible 023 * position and velocity for accuracy and bandwidth (this also requires setting 024 * FeedbackRemoteSensorID). This was developed for applications such as 025 * swerve-azimuth. 026 * <p> 027 * Choose Sync* (requires Phoenix Pro) and Talon will synchronize its 028 * commutation sensor position against another sensor, then continue to use the 029 * rotor sensor for closed loop control (this also requires setting 030 * FeedbackRemoteSensorID). The Talon will report if its internal position 031 * differs significantly from the reported remote sensor position. This was 032 * developed for mechanisms where there is a risk of the sensor failing in such 033 * a way that it reports a position that does not match the mechanism, such as 034 * the sensor mounting assembly breaking off. 035 * <p> 036 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and RemotePigeon2_Roll to use 037 * another Pigeon2 on the same CAN bus (this also requires setting 038 * FeedbackRemoteSensorID). Talon will update its position to match the 039 * selected value whenever Pigeon2 publishes its information on CAN bus. Note 040 * that the Talon position will be in rotations and not degrees. 041 * <p> 042 * Choose Quadrature to use a quadrature encoder directly attached to the Talon 043 * data port. This provides velocity and relative position measurements. 044 * <p> 045 * Choose PulseWidth to use a pulse-width encoder directly attached to the Talon 046 * data port. This provides velocity and absolute position measurements. 047 * <p> 048 * Note: When the feedback source is changed to Fused* or Sync*, the Talon needs 049 * a period of time to fuse before sensor-based (soft-limit, closed loop, etc.) 050 * features are used. This period of time is determined by the update frequency 051 * of the remote sensor's Position signal. 052 */ 053public enum ExternalFeedbackSensorSourceValue 054{ 055 /** 056 * Use the external sensor used for motor commutation. 057 */ 058 Commutation(0), 059 /** 060 * Use another CANcoder on the same CAN bus (this also requires setting 061 * FeedbackRemoteSensorID). Talon will update its position and velocity 062 * whenever CANcoder publishes its information on CAN bus, and the Talon 063 * commutation sensor will not be used. 064 */ 065 RemoteCANcoder(1), 066 /** 067 * Use another Pigeon2 on the same CAN bus (this also requires setting 068 * FeedbackRemoteSensorID). Talon will update its position to match the Pigeon2 069 * yaw whenever Pigeon2 publishes its information on CAN bus. Note that the 070 * Talon position will be in rotations and not degrees. 071 */ 072 RemotePigeon2_Yaw(2), 073 /** 074 * Use another Pigeon2 on the same CAN bus (this also requires setting 075 * FeedbackRemoteSensorID). Talon will update its position to match the Pigeon2 076 * pitch whenever Pigeon2 publishes its information on CAN bus. Note that the 077 * Talon position will be in rotations and not degrees. 078 */ 079 RemotePigeon2_Pitch(3), 080 /** 081 * Use another Pigeon2 on the same CAN bus (this also requires setting 082 * FeedbackRemoteSensorID). Talon will update its position to match the Pigeon2 083 * roll whenever Pigeon2 publishes its information on CAN bus. Note that the 084 * Talon position will be in rotations and not degrees. 085 */ 086 RemotePigeon2_Roll(4), 087 /** 088 * Requires Phoenix Pro; Talon will fuse another CANcoder's information with the 089 * commutation sensor, which provides the best possible position and velocity 090 * for accuracy and bandwidth (this also requires setting 091 * FeedbackRemoteSensorID). FusedCANcoder was developed for applications such 092 * as swerve-azimuth. 093 */ 094 FusedCANcoder(5), 095 /** 096 * Requires Phoenix Pro; Talon will synchronize its commutation sensor position 097 * against another CANcoder, then continue to use the rotor sensor for closed 098 * loop control (this also requires setting FeedbackRemoteSensorID). The Talon 099 * will report if its internal position differs significantly from the reported 100 * CANcoder position. SyncCANcoder was developed for mechanisms where there is 101 * a risk of the CANcoder failing in such a way that it reports a position that 102 * does not match the mechanism, such as the sensor mounting assembly breaking 103 * off. 104 */ 105 SyncCANcoder(6), 106 /** 107 * Use a quadrature encoder directly attached to the Talon data port. This 108 * provides velocity and relative position measurements. 109 */ 110 Quadrature(7), 111 /** 112 * Use a pulse-width encoder directly attached to the Talon data port. This 113 * provides velocity and absolute position measurements. 114 */ 115 PulseWidth(8), 116 /** 117 * Use a pulse-width encoder remotely attached to the Sensor Input 1 (S1IN) on 118 * CANdi. Talon will update its position and velocity whenever CANdi publishes 119 * its information on CAN bus, and the Talon internal rotor will not be used. 120 */ 121 RemoteCANdiPWM1(9), 122 /** 123 * Use a pulse-width encoder remotely attached to the Sensor Input 2 (S2IN) on 124 * CANdi. Talon will update its position and velocity whenever CANdi publishes 125 * its information on CAN bus, and the Talon internal rotor will not be used. 126 */ 127 RemoteCANdiPWM2(10), 128 /** 129 * Use a quadrature encoder remotely attached to the two Sensor Inputs on CANdi. 130 * Talon will update its position and velocity whenever CANdi publishes its 131 * information on CAN bus, and the Talon internal rotor will not be used. 132 */ 133 RemoteCANdiQuadrature(11), 134 /** 135 * Requires Phoenix Pro; Talon will fuse a pulse-width encoder remotely attached 136 * to the Sensor Input 1 (S1IN) on CANdi, which provides the best possible 137 * position and velocity for accuracy and bandwidth (this also requires setting 138 * FeedbackRemoteSensorID). FusedCANdi was developed for applications such as 139 * swerve-azimuth. 140 */ 141 FusedCANdiPWM1(12), 142 /** 143 * Requires Phoenix Pro; Talon will fuse a pulse-width encoder remotely attached 144 * to the Sensor Input 2 (S2IN) on CANdi, which provides the best possible 145 * position and velocity for accuracy and bandwidth (this also requires setting 146 * FeedbackRemoteSensorID). FusedCANdi was developed for applications such as 147 * swerve-azimuth. 148 */ 149 FusedCANdiPWM2(13), 150 /** 151 * Requires Phoenix Pro; Talon will fuse a qaudrature encoder remotely attached 152 * to the two Sensor Inputs on CANdi. This provides velocity and relative 153 * position measurements. This also requires setting FeedbackRemoteSensorID. 154 */ 155 FusedCANdiQuadrature(14), 156 /** 157 * Requires Phoenix Pro; Talon will synchronize its internal rotor position 158 * against the pulse-width encoder attached to Sensor Input 1 (S1IN), then 159 * continue to use the rotor sensor for closed loop control (this also requires 160 * setting FeedbackRemoteSensorID). The Talon will report if its internal 161 * position differs significantly from the reported PWM position. SyncCANdi was 162 * developed for mechanisms where there is a risk of the CANdi failing in such a 163 * way that it reports a position that does not match the mechanism, such as the 164 * sensor mounting assembly breaking off. 165 */ 166 SyncCANdiPWM1(15), 167 /** 168 * Requires Phoenix Pro; Talon will synchronize its internal rotor position 169 * against the pulse-width encoder attached to Sensor Input 1 (S1IN), then 170 * continue to use the rotor sensor for closed loop control (this also requires 171 * setting FeedbackRemoteSensorID). The Talon will report if its internal 172 * position differs significantly from the reported PWM position. SyncCANdi was 173 * developed for mechanisms where there is a risk of the CANdi failing in such a 174 * way that it reports a position that does not match the mechanism, such as the 175 * sensor mounting assembly breaking off. 176 */ 177 SyncCANdiPWM2(16),; 178 179 public final int value; 180 181 ExternalFeedbackSensorSourceValue(int initValue) 182 { 183 this.value = initValue; 184 } 185 186 private static HashMap<Integer, ExternalFeedbackSensorSourceValue> _map = null; 187 static 188 { 189 _map = new HashMap<Integer, ExternalFeedbackSensorSourceValue>(); 190 for (ExternalFeedbackSensorSourceValue type : ExternalFeedbackSensorSourceValue.values()) 191 { 192 _map.put(type.value, type); 193 } 194 } 195 196 /** 197 * Gets ExternalFeedbackSensorSourceValue from specified value 198 * @param value Value of ExternalFeedbackSensorSourceValue 199 * @return ExternalFeedbackSensorSourceValue of specified value 200 */ 201 public static ExternalFeedbackSensorSourceValue valueOf(int value) 202 { 203 ExternalFeedbackSensorSourceValue retval = _map.get(value); 204 if (retval != null) return retval; 205 return ExternalFeedbackSensorSourceValue.values()[0]; 206 } 207}