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 general behavior during closed-looping. 015 * <p> 016 * Includes Continuous Wrap features. 017 */ 018public class ClosedLoopGeneralConfigs implements ParentConfiguration 019{ 020 /** 021 * Wrap position error within [-0.5,+0.5) mechanism rotations. 022 * Typically used for continuous position closed-loops like swerve 023 * azimuth. 024 * <p> 025 * This uses the mechanism rotation value. If there is a gear ratio 026 * between the sensor and the mechanism, make sure to apply a 027 * SensorToMechanismRatio so the closed loop operates on the full 028 * rotation. 029 * 030 * <ul> 031 * <li> <b>Default Value:</b> False 032 * </ul> 033 */ 034 public boolean ContinuousWrap = false; 035 036 /** 037 * Modifies this configuration's ContinuousWrap parameter and returns itself for 038 * method-chaining and easier to use config API. 039 * <p> 040 * Wrap position error within [-0.5,+0.5) mechanism rotations. 041 * Typically used for continuous position closed-loops like swerve 042 * azimuth. 043 * <p> 044 * This uses the mechanism rotation value. If there is a gear ratio 045 * between the sensor and the mechanism, make sure to apply a 046 * SensorToMechanismRatio so the closed loop operates on the full 047 * rotation. 048 * 049 * <ul> 050 * <li> <b>Default Value:</b> False 051 * </ul> 052 * 053 * @param newContinuousWrap Parameter to modify 054 * @return Itself 055 */ 056 public ClosedLoopGeneralConfigs withContinuousWrap(boolean newContinuousWrap) 057 { 058 ContinuousWrap = newContinuousWrap; 059 return this; 060 } 061 062 063 064 @Override 065 public String toString() 066 { 067 String ss = "Config Group: ClosedLoopGeneral\n"; 068 ss += " ContinuousWrap: " + ContinuousWrap + "\n"; 069 return ss; 070 } 071 072 /** 073 * 074 */ 075 public StatusCode deserialize(String to_deserialize) 076 { 077 ContinuousWrap = ConfigJNI.Deserializeboolean(SpnValue.Config_ContinuousWrap.value, to_deserialize); 078 return StatusCode.OK; 079 } 080 081 /** 082 * 083 */ 084 public String serialize() 085 { 086 String ss = ""; 087 ss += ConfigJNI.Serializeboolean(SpnValue.Config_ContinuousWrap.value, ContinuousWrap); 088 return ss; 089 } 090} 091