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.phoenixpro.configs; 008 009import com.ctre.phoenixpro.StatusCode; 010import com.ctre.phoenixpro.configs.jni.ConfigJNI; 011import com.ctre.phoenixpro.spns.*; 012 013/** 014 * Configs that directly affect motor-output. 015 * <p> 016 * Includes Motor Invert and various limit features. 017 */ 018public class MotionMagicConfigs implements ParentConfiguration 019{ 020 /** 021 * This is the maximum velocity Motion Magic® based control modes are 022 * allowed to use. 023 * 024 * <ul> 025 * <li> <b>Minimum Value:</b> 0 026 * <li> <b>Maximum Value:</b> 3.4e+38 027 * <li> <b>Default Value:</b> 0 028 * <li> <b>Units:</b> rps 029 * </ul> 030 */ 031 public double MotionMagicCruiseVelocity = 0; 032 /** 033 * This is the target acceleration Motion Magic® based control modes 034 * are allowed to use. 035 * 036 * <ul> 037 * <li> <b>Minimum Value:</b> 0 038 * <li> <b>Maximum Value:</b> 3.4e+38 039 * <li> <b>Default Value:</b> 0 040 * <li> <b>Units:</b> rot per sec² 041 * </ul> 042 */ 043 public double MotionMagicAcceleration = 0; 044 /** 045 * This is the target jerk (acceleration derivative) Motion Magic® 046 * based control modes are allowed to use. This allows Motion Magic® 047 * support of S-Curves. If this is set to zero, then Motion Magic® 048 * will not apply a Jerk limit. 049 * 050 * <ul> 051 * <li> <b>Minimum Value:</b> 0 052 * <li> <b>Maximum Value:</b> 3.4e+38 053 * <li> <b>Default Value:</b> 0 054 * <li> <b>Units:</b> rot per sec³ 055 * </ul> 056 */ 057 public double MotionMagicJerk = 0; 058 059 @Override 060 public String toString() 061 { 062 String ss = "Config Group: MotionMagic\n"; 063 ss += "Name: \"MotionMagicCruiseVelocity\" Value: \"" + MotionMagicCruiseVelocity + "rps\"" + "\n"; 064 ss += "Name: \"MotionMagicAcceleration\" Value: \"" + MotionMagicAcceleration + "rot per sec²\"" + "\n"; 065 ss += "Name: \"MotionMagicJerk\" Value: \"" + MotionMagicJerk + "rot per sec³\"" + "\n"; 066 return ss; 067 } 068 069 /** 070 * 071 */ 072 public StatusCode deserialize(String string) 073 { 074 MotionMagicCruiseVelocity = ConfigJNI.Deserializedouble(SpnValue.Config_MotionMagicCruiseVelocity.value, string); 075 MotionMagicAcceleration = ConfigJNI.Deserializedouble(SpnValue.Config_MotionMagicAcceleration.value, string); 076 MotionMagicJerk = ConfigJNI.Deserializedouble(SpnValue.Config_MotionMagicJerk.value, string); 077 return StatusCode.OK; 078 } 079 080 /** 081 * 082 */ 083 public String serialize() 084 { 085 String ss = ""; 086 ss += ConfigJNI.Serializedouble(1465, MotionMagicCruiseVelocity); 087 ss += ConfigJNI.Serializedouble(1466, MotionMagicAcceleration); 088 ss += ConfigJNI.Serializedouble(1467, MotionMagicJerk); 089 return ss; 090 } 091} 092