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;
010
011/**
012 * Class description for the Pigeon 2 IMU sensor that measures orientation.
013 *
014 * This handles the configurations for the {@link com.ctre.phoenixpro.hardware.Pigeon2}
015 */
016public class Pigeon2Configuration implements ParentConfiguration
017{
018    /**
019     * True if we should factory default newer unsupported configs,
020     * false to leave newer unsupported configs alone.
021     * <p>
022     * This flag addresses a corner case where the device may have
023     * firmware with newer configs that didn't exist when this
024     * version of the API was built. If this occurs and this
025     * flag is true, unsupported new configs will be factory
026     * defaulted to avoid unexpected behavior.
027     * <p>
028     * This is also the behavior in Phoenix 5, so this flag
029     * is defaulted to true to match.
030     */
031    public boolean FutureProofConfigs = true;
032
033    
034    /**
035     *  Configs for Pigeon 2's Mount Pose configuration.
036     * <p>
037     *  These configs allow the Pigeon2 to be mounted in whatever
038     *  orientation that's desired and ensure the reported Yaw/Pitch/Roll
039     *  is from the robot's reference.
040     */
041    public MountPoseConfigs MountPose = new MountPoseConfigs();
042    
043    /**
044     *  Configs to trim the Pigeon2's gyroscope.
045     * <p>
046     *  Pigeon2 allows the user to trim the gyroscope's sensitivity. While
047     *  this isn't necessary for the Pigeon2, as it comes calibrated
048     *  out-of-the-box, users can make use of this to make the Pigeon2
049     *  even more accurate for their application.
050     */
051    public GyroTrimConfigs GyroTrim = new GyroTrimConfigs();
052    
053    /**
054     *  Configs to enable/disable various features of the Pigeon2.
055     * <p>
056     *  These configs allow the user to enable or disable various aspects
057     *  of the Pigeon2.
058     */
059    public Pigeon2FeaturesConfigs Pigeon2Features = new Pigeon2FeaturesConfigs();
060
061    @Override
062    public String toString()
063    {
064        String ss = "";
065        ss += MountPose.toString();
066        ss += GyroTrim.toString();
067        ss += Pigeon2Features.toString();
068        return ss;
069    }
070
071    /**
072     * Get the serialized form of this configuration
073     *
074     * @return Serialized form of this config group
075     */
076    public String serialize()
077    {
078        String ss = "";
079        ss += MountPose.serialize();
080        ss += GyroTrim.serialize();
081        ss += Pigeon2Features.serialize();
082        return ss;
083    }
084
085    /**
086     * Take a string and deserialize it to this configuration
087     *
088     * @return Return code of the deserialize method
089     */
090    public StatusCode deserialize(String string)
091    {
092        StatusCode err = StatusCode.OK;
093        err = MountPose.deserialize(string);
094        err = GyroTrim.deserialize(string);
095        err = Pigeon2Features.deserialize(string);
096        return err;
097    }
098};