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    /**
039     * Disable differential control.
040     */
041    Disabled(0),
042    /**
043     * Use another TalonFX on the same CAN bus.  Talon FX will update its
044     * differential position and velocity whenever the remote TalonFX publishes its
045     * information on CAN bus.  The differential controller will use the difference
046     * between this TalonFX's sensor and the remote Talon FX's sensor for the
047     * differential component of the output.
048     */
049    RemoteTalonFX_Diff(1),
050    /**
051     * Use another Pigeon2 on the same CAN bus (this also requires setting
052     * DifferentialRemoteSensorID).  Talon FX will update its differential position
053     * to match the Pigeon2 yaw whenever Pigeon2 publishes its information on CAN
054     * bus. Note that the Talon FX differential position will be in rotations and
055     * not degrees.
056     */
057    RemotePigeon2_Yaw(2),
058    /**
059     * Use another Pigeon2 on the same CAN bus (this also requires setting
060     * DifferentialRemoteSensorID).  Talon FX will update its differential position
061     * to match the Pigeon2 pitch whenever Pigeon2 publishes its information on CAN
062     * bus. Note that the Talon FX differential position will be in rotations and
063     * not degrees.
064     */
065    RemotePigeon2_Pitch(3),
066    /**
067     * Use another Pigeon2 on the same CAN bus (this also requires setting
068     * DifferentialRemoteSensorID).  Talon FX will update its differential position
069     * to match the Pigeon2 roll whenever Pigeon2 publishes its information on CAN
070     * bus. Note that the Talon FX differential position will be in rotations and
071     * not degrees.
072     */
073    RemotePigeon2_Roll(4),
074    /**
075     * Use another CANcoder on the same CAN bus (this also requires setting
076     * DifferentialRemoteSensorID).  Talon FX will update its differential position
077     * and velocity to match the CANcoder whenever CANcoder publishes its
078     * information on CAN bus.
079     */
080    RemoteCANcoder(5),;
081
082    public final int value;
083
084    DifferentialSensorSourceValue(int initValue)
085    {
086        this.value = initValue;
087    }
088
089    private static HashMap<Integer, DifferentialSensorSourceValue> _map = null;
090    static
091    {
092        _map = new HashMap<Integer, DifferentialSensorSourceValue>();
093        for (DifferentialSensorSourceValue type : DifferentialSensorSourceValue.values())
094        {
095            _map.put(type.value, type);
096        }
097    }
098
099    /**
100     * Gets DifferentialSensorSourceValue from specified value
101     * @param value Value of DifferentialSensorSourceValue
102     * @return DifferentialSensorSourceValue of specified value
103     */
104    public static DifferentialSensorSourceValue valueOf(int value)
105    {
106        DifferentialSensorSourceValue retval = _map.get(value);
107        if (retval != null) return retval;
108        return DifferentialSensorSourceValue.values()[0];
109    }
110}