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 * Static Feedforward Sign during position closed loop. 013 * <p> 014 * This determines the sign of the applied kS during position closed-loop modes. 015 * The default behavior uses the velocity reference sign. This works well with 016 * velocity closed loop, Motion MagicĀ® controls, and position closed loop when 017 * velocity reference is specified (motion profiling). 018 * <p> 019 * However, when using position closed loop with zero velocity reference (no 020 * motion profiling), the application may want to apply static feedforward based 021 * on the sign of closed loop error instead. When doing so, we recommend using 022 * the minimal amount of kS, otherwise the motor output may dither when closed 023 * loop error is near zero. 024 */ 025public enum StaticFeedforwardSignValue 026{ 027 /** 028 * Use the velocity reference sign. This works well with velocity closed loop, 029 * Motion MagicĀ® controls, and position closed loop when velocity reference is 030 * specified (motion profiling). 031 */ 032 UseVelocitySign(0), 033 /** 034 * Use the sign of closed loop error. This is useful when using position closed 035 * loop with zero velocity reference (no motion profiling). We recommend the 036 * minimal amount of kS, otherwise the motor output may dither when closed loop 037 * error is near zero. 038 */ 039 UseClosedLoopSign(1),; 040 041 public final int value; 042 043 StaticFeedforwardSignValue(int initValue) 044 { 045 this.value = initValue; 046 } 047 048 private static HashMap<Integer, StaticFeedforwardSignValue> _map = null; 049 static 050 { 051 _map = new HashMap<Integer, StaticFeedforwardSignValue>(); 052 for (StaticFeedforwardSignValue type : StaticFeedforwardSignValue.values()) 053 { 054 _map.put(type.value, type); 055 } 056 } 057 058 /** 059 * Gets StaticFeedforwardSignValue from specified value 060 * @param value Value of StaticFeedforwardSignValue 061 * @return StaticFeedforwardSignValue of specified value 062 */ 063 public static StaticFeedforwardSignValue valueOf(int value) 064 { 065 StaticFeedforwardSignValue retval = _map.get(value); 066 if (retval != null) return retval; 067 return StaticFeedforwardSignValue.values()[0]; 068 } 069}