001/* Copyright (C) Cross The Road Electronics 2024 */ 002package com.ctre.phoenix.motorcontrol; 003 004/** 005 * Choose the control mode for a TalonSRX. 006 */ 007public enum TalonSRXControlMode 008{ 009 /** 010 * Percent output [-1,1] 011 */ 012 PercentOutput(0), 013 /** 014 * Position closed loop 015 */ 016 Position(1), 017 /** 018 * Velocity closed loop 019 */ 020 Velocity(2), 021 /** 022 * Input current closed loop 023 */ 024 Current(3), 025 /** 026 * Follow other motor controller 027 */ 028 Follower(5), 029 /** 030 * Motion Profile 031 */ 032 MotionProfile(6), 033 /** 034 * Motion Magic 035 */ 036 MotionMagic(7), 037 /** 038 * Motion Profile with auxiliary output 039 */ 040 MotionProfileArc(10), 041 042 /** 043 * Disable Motor Controller 044 */ 045 Disabled(15); 046 047 /** 048 * Value of control mode 049 */ 050 public final int value; 051 052 /** 053 * Create TalonSRXControlMode of initValue 054 * @param initValue Value of TalonSRXControlMode 055 */ 056 TalonSRXControlMode(int initValue) 057 { 058 this.value = initValue; 059 } 060 061 /** 062 * Helper method to convert to generic ControlMode enum. 063 * @return value cast as ControlMode 064 */ 065 public ControlMode toControlMode(){ 066 switch(value){ 067 case 0: return ControlMode.PercentOutput; 068 case 1: return ControlMode.Position; 069 case 2: return ControlMode.Velocity; 070 case 3: return ControlMode.Current; 071 case 5: return ControlMode.Follower; 072 case 6: return ControlMode.MotionProfile; 073 case 7: return ControlMode.MotionMagic; 074 case 10: return ControlMode.MotionProfileArc; 075 case 15: return ControlMode.Disabled; 076 default: return ControlMode.PercentOutput; 077 } 078 } 079};