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 for Pigeon 2's Mount Pose configuration.
015 * <p>
016 * These configs allow the Pigeon2 to be mounted in whatever
017 * orientation that's desired and ensure the reported Yaw/Pitch/Roll
018 * is from the robot's reference.
019 */
020public class MountPoseConfigs implements ParentConfiguration
021{
022    /**
023     * The mounting calibration yaw-component
024     * 
025     * <ul>
026     *   <li> <b>Minimum Value:</b> -360
027     *   <li> <b>Maximum Value:</b> 360
028     *   <li> <b>Default Value:</b> 0
029     *   <li> <b>Units:</b> deg
030     * </ul>
031     */
032    public double MountPoseYaw = 0;
033    /**
034     * The mounting calibration pitch-component
035     * 
036     * <ul>
037     *   <li> <b>Minimum Value:</b> -360
038     *   <li> <b>Maximum Value:</b> 360
039     *   <li> <b>Default Value:</b> 0
040     *   <li> <b>Units:</b> deg
041     * </ul>
042     */
043    public double MountPosePitch = 0;
044    /**
045     * The mounting calibration roll-component
046     * 
047     * <ul>
048     *   <li> <b>Minimum Value:</b> -360
049     *   <li> <b>Maximum Value:</b> 360
050     *   <li> <b>Default Value:</b> 0
051     *   <li> <b>Units:</b> deg
052     * </ul>
053     */
054    public double MountPoseRoll = 0;
055    
056    /**
057     * Modifies this configuration's MountPoseYaw parameter and returns itself for
058     * method-chaining and easier to use config API.
059     * <p>
060     * The mounting calibration yaw-component
061     * 
062     * <ul>
063     *   <li> <b>Minimum Value:</b> -360
064     *   <li> <b>Maximum Value:</b> 360
065     *   <li> <b>Default Value:</b> 0
066     *   <li> <b>Units:</b> deg
067     * </ul>
068     *
069     * @param newMountPoseYaw Parameter to modify
070     * @return Itself
071     */
072    public MountPoseConfigs withMountPoseYaw(double newMountPoseYaw)
073    {
074        MountPoseYaw = newMountPoseYaw;
075        return this;
076    }
077    /**
078     * Modifies this configuration's MountPosePitch parameter and returns itself for
079     * method-chaining and easier to use config API.
080     * <p>
081     * The mounting calibration pitch-component
082     * 
083     * <ul>
084     *   <li> <b>Minimum Value:</b> -360
085     *   <li> <b>Maximum Value:</b> 360
086     *   <li> <b>Default Value:</b> 0
087     *   <li> <b>Units:</b> deg
088     * </ul>
089     *
090     * @param newMountPosePitch Parameter to modify
091     * @return Itself
092     */
093    public MountPoseConfigs withMountPosePitch(double newMountPosePitch)
094    {
095        MountPosePitch = newMountPosePitch;
096        return this;
097    }
098    /**
099     * Modifies this configuration's MountPoseRoll parameter and returns itself for
100     * method-chaining and easier to use config API.
101     * <p>
102     * The mounting calibration roll-component
103     * 
104     * <ul>
105     *   <li> <b>Minimum Value:</b> -360
106     *   <li> <b>Maximum Value:</b> 360
107     *   <li> <b>Default Value:</b> 0
108     *   <li> <b>Units:</b> deg
109     * </ul>
110     *
111     * @param newMountPoseRoll Parameter to modify
112     * @return Itself
113     */
114    public MountPoseConfigs withMountPoseRoll(double newMountPoseRoll)
115    {
116        MountPoseRoll = newMountPoseRoll;
117        return this;
118    }
119
120    
121
122    @Override
123    public String toString()
124    {
125        String ss = "Config Group: MountPose\n";
126        ss += "Name: \"MountPoseYaw\" Value: \"" + MountPoseYaw + "deg\"" + "\n";
127        ss += "Name: \"MountPosePitch\" Value: \"" + MountPosePitch + "deg\"" + "\n";
128        ss += "Name: \"MountPoseRoll\" Value: \"" + MountPoseRoll + "deg\"" + "\n";
129        return ss;
130    }
131
132    /**
133     *
134     */
135    public StatusCode deserialize(String to_deserialize)
136    {
137        MountPoseYaw = ConfigJNI.Deserializedouble(SpnValue.Pigeon2MountPoseYaw.value, to_deserialize);
138        MountPosePitch = ConfigJNI.Deserializedouble(SpnValue.Pigeon2MountPosePitch.value, to_deserialize);
139        MountPoseRoll = ConfigJNI.Deserializedouble(SpnValue.Pigeon2MountPoseRoll.value, to_deserialize);
140        return  StatusCode.OK;
141    }
142
143    /**
144     *
145     */
146    public String serialize()
147    {
148        String ss = "";
149        ss += ConfigJNI.Serializedouble(SpnValue.Pigeon2MountPoseYaw.value, MountPoseYaw);
150        ss += ConfigJNI.Serializedouble(SpnValue.Pigeon2MountPosePitch.value, MountPosePitch);
151        ss += ConfigJNI.Serializedouble(SpnValue.Pigeon2MountPoseRoll.value, MountPoseRoll);
152        return ss;
153    }
154}
155