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 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    @Override
057    public String toString()
058    {
059        String ss = "Config Group: MountPose\n";
060        ss += "Name: \"MountPoseYaw\" Value: \"" + MountPoseYaw + "deg\"" + "\n";
061        ss += "Name: \"MountPosePitch\" Value: \"" + MountPosePitch + "deg\"" + "\n";
062        ss += "Name: \"MountPoseRoll\" Value: \"" + MountPoseRoll + "deg\"" + "\n";
063        return ss;
064    }
065
066    /**
067     *
068     */
069    public StatusCode deserialize(String string)
070    {
071        MountPoseYaw = ConfigJNI.Deserializedouble(SpnValue.Pigeon2MountPoseYaw.value, string);
072        MountPosePitch = ConfigJNI.Deserializedouble(SpnValue.Pigeon2MountPosePitch.value, string);
073        MountPoseRoll = ConfigJNI.Deserializedouble(SpnValue.Pigeon2MountPoseRoll.value, string);
074        return  StatusCode.OK;
075    }
076
077    /**
078     *
079     */
080    public String serialize()
081    {
082        String ss = "";
083        ss += ConfigJNI.Serializedouble(952, MountPoseYaw);
084        ss += ConfigJNI.Serializedouble(953, MountPosePitch);
085        ss += ConfigJNI.Serializedouble(954, MountPoseRoll);
086        return ss;
087    }
088}
089