public ModuleStateObject GetModuleStateObject(bool forConfiguration)
    {
        ModuleStateObject mso = new ModuleStateObject();

        mso.name     = gameObject.name;
        mso.position = mo2MaComController.moduleRefPointerController.GetPartPointerByName(ModuleRefPointerController.PartNames.BackPlate.ToString()).transform.position;
        mso.rotation = mo2MaComController.moduleRefPointerController.GetPartPointerByName(ModuleRefPointerController.PartNames.BackPlate.ToString()).transform.rotation;
        foreach (JointCommandObject jco in jointCommandObjectDict.Values)
        {
            JointCommandObject jcoClone = jco.Clone(forConfiguration);
            mso.listOfJointCommands.Add(jcoClone);
            if (mso.period < jcoClone.period)
            {
                mso.period = jcoClone.period;
            }
        }
        foreach (Transform part in transform)
        {
            PartStateObject pso = new PartStateObject();
            pso.name     = part.name;
            pso.position = part.position;
            pso.rotation = part.rotation;
            mso.listOfPartStates.Add(pso);
        }
        return(mso);
    }
 // Load the JointCommandObject of all joints
 void LoadJointCommandObjectDict()
 {
     foreach (string jointName in mo2MaComController.moduleRefPointerController.GetAllHingeJointNames())
     {
         JointCommandObject jco = new JointCommandObject(jointName);
         jointCommandObjectDict.Add(jointName, jco);
     }
 }
    public JointCommandObject Clone(bool forConfiguration)
    {
        JointCommandObject newJco = new JointCommandObject();

        newJco.name        = name;
        newJco.commandType = commandType;
        newJco.targetValue = targetValue;
        if (forConfiguration)
        {
            newJco.period = 0.0f;
        }
        else
        {
            newJco.period = period;
        }
        return(newJco);
    }
 public void SetJointFromJointCommandObject(JointCommandObject jco, bool reset = false)
 {
     if (jco.commandType == JointCommandObject.CommandTypes.Position)
     {
         UpdateJointAngle(jco.targetValue, jco.name);
     }
     else if (jco.commandType == JointCommandObject.CommandTypes.Velocity)
     {
         if (reset)
         {
             StopJoint(jco.name);
         }
         else
         {
             UpdateJointVelocity(jco.targetValue, jco.name, jco.period);
         }
     }
 }