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.configs; 008 009import com.ctre.phoenix6.StatusCode; 010import com.ctre.phoenix6.configs.jni.ConfigJNI; 011import com.ctre.phoenix6.spns.*; 012 013/** 014 * Configs that affect Torque Current control types. 015 * <p> 016 * Includes the maximum and minimum applied torque output and the 017 * neutral deadband used during TorqueCurrentFOC requests. 018 */ 019public class TorqueCurrentConfigs implements ParentConfiguration 020{ 021 /** 022 * Maximum (forward) output during torque current based control modes. 023 * 024 * <ul> 025 * <li> <b>Minimum Value:</b> -800 026 * <li> <b>Maximum Value:</b> 800 027 * <li> <b>Default Value:</b> 800 028 * <li> <b>Units:</b> A 029 * </ul> 030 */ 031 public double PeakForwardTorqueCurrent = 800; 032 /** 033 * Minimum (reverse) output during torque current based control modes. 034 * 035 * <ul> 036 * <li> <b>Minimum Value:</b> -800 037 * <li> <b>Maximum Value:</b> 800 038 * <li> <b>Default Value:</b> -800 039 * <li> <b>Units:</b> A 040 * </ul> 041 */ 042 public double PeakReverseTorqueCurrent = -800; 043 /** 044 * Configures the output deadband during torque current based control 045 * modes. 046 * 047 * <ul> 048 * <li> <b>Minimum Value:</b> 0 049 * <li> <b>Maximum Value:</b> 25 050 * <li> <b>Default Value:</b> 0.0 051 * <li> <b>Units:</b> A 052 * </ul> 053 */ 054 public double TorqueNeutralDeadband = 0.0; 055 056 /** 057 * Modifies this configuration's PeakForwardTorqueCurrent parameter and returns itself for 058 * method-chaining and easier to use config API. 059 * <p> 060 * Maximum (forward) output during torque current based control modes. 061 * 062 * <ul> 063 * <li> <b>Minimum Value:</b> -800 064 * <li> <b>Maximum Value:</b> 800 065 * <li> <b>Default Value:</b> 800 066 * <li> <b>Units:</b> A 067 * </ul> 068 * 069 * @param newPeakForwardTorqueCurrent Parameter to modify 070 * @return Itself 071 */ 072 public TorqueCurrentConfigs withPeakForwardTorqueCurrent(double newPeakForwardTorqueCurrent) 073 { 074 PeakForwardTorqueCurrent = newPeakForwardTorqueCurrent; 075 return this; 076 } 077 /** 078 * Modifies this configuration's PeakReverseTorqueCurrent parameter and returns itself for 079 * method-chaining and easier to use config API. 080 * <p> 081 * Minimum (reverse) output during torque current based control modes. 082 * 083 * <ul> 084 * <li> <b>Minimum Value:</b> -800 085 * <li> <b>Maximum Value:</b> 800 086 * <li> <b>Default Value:</b> -800 087 * <li> <b>Units:</b> A 088 * </ul> 089 * 090 * @param newPeakReverseTorqueCurrent Parameter to modify 091 * @return Itself 092 */ 093 public TorqueCurrentConfigs withPeakReverseTorqueCurrent(double newPeakReverseTorqueCurrent) 094 { 095 PeakReverseTorqueCurrent = newPeakReverseTorqueCurrent; 096 return this; 097 } 098 /** 099 * Modifies this configuration's TorqueNeutralDeadband parameter and returns itself for 100 * method-chaining and easier to use config API. 101 * <p> 102 * Configures the output deadband during torque current based control 103 * modes. 104 * 105 * <ul> 106 * <li> <b>Minimum Value:</b> 0 107 * <li> <b>Maximum Value:</b> 25 108 * <li> <b>Default Value:</b> 0.0 109 * <li> <b>Units:</b> A 110 * </ul> 111 * 112 * @param newTorqueNeutralDeadband Parameter to modify 113 * @return Itself 114 */ 115 public TorqueCurrentConfigs withTorqueNeutralDeadband(double newTorqueNeutralDeadband) 116 { 117 TorqueNeutralDeadband = newTorqueNeutralDeadband; 118 return this; 119 } 120 121 122 123 @Override 124 public String toString() 125 { 126 String ss = "Config Group: TorqueCurrent\n"; 127 ss += "Name: \"PeakForwardTorqueCurrent\" Value: \"" + PeakForwardTorqueCurrent + "A\"" + "\n"; 128 ss += "Name: \"PeakReverseTorqueCurrent\" Value: \"" + PeakReverseTorqueCurrent + "A\"" + "\n"; 129 ss += "Name: \"TorqueNeutralDeadband\" Value: \"" + TorqueNeutralDeadband + "A\"" + "\n"; 130 return ss; 131 } 132 133 /** 134 * 135 */ 136 public StatusCode deserialize(String to_deserialize) 137 { 138 PeakForwardTorqueCurrent = ConfigJNI.Deserializedouble(SpnValue.Config_PeakForTorqCurr.value, to_deserialize); 139 PeakReverseTorqueCurrent = ConfigJNI.Deserializedouble(SpnValue.Config_PeakRevTorqCurr.value, to_deserialize); 140 TorqueNeutralDeadband = ConfigJNI.Deserializedouble(SpnValue.Config_TorqueNeutralDB.value, to_deserialize); 141 return StatusCode.OK; 142 } 143 144 /** 145 * 146 */ 147 public String serialize() 148 { 149 String ss = ""; 150 ss += ConfigJNI.Serializedouble(SpnValue.Config_PeakForTorqCurr.value, PeakForwardTorqueCurrent); 151 ss += ConfigJNI.Serializedouble(SpnValue.Config_PeakRevTorqCurr.value, PeakReverseTorqueCurrent); 152 ss += ConfigJNI.Serializedouble(SpnValue.Config_TorqueNeutralDB.value, TorqueNeutralDeadband); 153 return ss; 154 } 155} 156