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 used for differential control of a mechanism. 013 * The default is Disabled. All other options require setting the 014 * DifferentialTalonFXSensorID, as the average of this Talon FX's sensor and the 015 * remote TalonFX's sensor is used for the differential controller's primary 016 * targets. 017 * <p> 018 * Choose RemoteTalonFX_Diff to use another TalonFX on the same CAN bus. Talon 019 * FX will update its differential position and velocity whenever the remote 020 * TalonFX publishes its information on CAN bus. The differential controller 021 * will use the difference between this TalonFX's sensor and the remote Talon 022 * FX's sensor for the differential component of the output. 023 * <p> 024 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and RemotePigeon2_Roll to use 025 * another Pigeon2 on the same CAN bus (this also requires setting 026 * DifferentialRemoteSensorID). Talon FX will update its differential position 027 * to match the selected value whenever Pigeon2 publishes its information on CAN 028 * bus. Note that the Talon FX differential position will be in rotations and 029 * not degrees. 030 * <p> 031 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus (this also 032 * requires setting DifferentialRemoteSensorID). Talon FX will update its 033 * differential position and velocity to match the CANcoder whenever CANcoder 034 * publishes its information on CAN bus. 035 */ 036public enum DifferentialSensorSourceValue 037{ 038 Disabled(0), 039 RemoteTalonFX_Diff(1), 040 RemotePigeon2_Yaw(2), 041 RemotePigeon2_Pitch(3), 042 RemotePigeon2_Roll(4), 043 RemoteCANcoder(5),; 044 045 public final int value; 046 047 DifferentialSensorSourceValue(int initValue) 048 { 049 this.value = initValue; 050 } 051 052 private static HashMap<Integer, DifferentialSensorSourceValue> _map = null; 053 static 054 { 055 _map = new HashMap<Integer, DifferentialSensorSourceValue>(); 056 for (DifferentialSensorSourceValue type : DifferentialSensorSourceValue.values()) 057 { 058 _map.put(type.value, type); 059 } 060 } 061 062 /** 063 * Gets DifferentialSensorSourceValue from specified value 064 * @param value Value of DifferentialSensorSourceValue 065 * @return DifferentialSensorSourceValue of specified value 066 */ 067 public static DifferentialSensorSourceValue valueOf(int value) 068 { 069 DifferentialSensorSourceValue retval = _map.get(value); 070 if (retval != null) return retval; 071 return DifferentialSensorSourceValue.values()[0]; 072 } 073}